annotate src/simulator.asm @ 631:185ba2f91f59

3.09 beta 1 release
author heinrichsweikamp
date Fri, 28 Feb 2020 15:45:07 +0100
parents cd58f7fc86db
children 4050675965ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
3 ; File simulator.asm combined next generation V3.08.8
0
heinrichsweikamp
parents:
diff changeset
4 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
5 ; Deco Calculator
0
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
10 ; 2011-07-09 : [jDG] Creation...
0
heinrichsweikamp
parents:
diff changeset
11
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
12 #include "hwos.inc" ; Mandatory include
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
13 #include "convert.inc" ; output_*
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
14 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
15 #include "strings.inc" ; STRCPY,...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
16 #include "tft.inc" ; WIN_LEFT,...
0
heinrichsweikamp
parents:
diff changeset
17 #include "start.inc"
heinrichsweikamp
parents:
diff changeset
18 #include "divemode.inc"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
19 #include "sleepmode.inc"
0
heinrichsweikamp
parents:
diff changeset
20 #include "math.inc"
heinrichsweikamp
parents:
diff changeset
21 #include "eeprom_rs232.inc"
50
ec4d8503ec45 NEW: user-selectable color schemes
heinrichsweikamp
parents: 46
diff changeset
22 #include "tft_outputs.inc"
298
2fe34fc0e2ae new submenu for gas consumption, show actual mix instead of GAS1-GAS5 in deco planner
heinrichsweikamp
parents: 296
diff changeset
23 #include "gaslist.inc"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
24 #include "surfmode.inc"
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
25 #include "wait.inc"
0
heinrichsweikamp
parents:
diff changeset
26
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
27
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
28 extern deco_push_tissues_to_vault
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
29 extern deco_calc_dive_interval
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
30 extern deco_calc_hauptroutine
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
31 extern deco_pull_tissues_from_vault
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
32 extern TFT_decotype_logbook
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
33 extern do_return_demo_planner
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
34 extern convert_meter_to_feet
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
35 extern dive_boot_oc
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
36 extern get_first_gas_to_WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
37
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
38 IFDEF _ccr_pscr
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
39 extern dive_boot_cc
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
40 extern get_first_dil_to_WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
41 ENDIF
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
42
0
heinrichsweikamp
parents:
diff changeset
43
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
44 ;---- Private local Variables -------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
45
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
46 CBLOCK local3 ; max size is 16 Byte !!!
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
47 decoplan_index ; within each page
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
48 decoplan_gindex ; global index
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
49 decoplan_last ; depth of last stop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
50 decoplan_flags ; private flags
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
51 decoplan_page ; page number
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
52 decoplan_warnings ; deco engine warnings
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
53 gas_index ; counter for looping through the gases
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
54 output_row ; used for positioning of the results output
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
55 real_CNS ; real CNS value from before simulated dive
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
56 ENDC ; used: 8 byte, remaining: 8 byte
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
57
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
58
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
59 ;---- Private local Flags ----------------------------------------------------
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
60
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
61 #define decoplan_abort decoplan_flags,0 ; =1: deco calculations were aborted
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
62 #define decoplan_last_stop_shown decoplan_flags,1 ; =1: last deco stop is shown
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
63 #define decoplan_pressures_shown decoplan_flags,2 ; =1: show gas volumes in bar as per tank sizes
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
64 #define decoplan_overflow decoplan_flags,3 ; =1: result > 999
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
65 #define decoplan_toggleflag decoplan_flags,4 ; used to show calculation progress
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
66 ; decoplan_flags,5 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
67 ; decoplan_flags,6 ; --- unused
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
68 ; decoplan_flags,7 ; --- unused
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
69
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
70
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
71 simulator CODE
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
72
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
73 ;-----------------------------------------------------------------------------
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
74
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
75 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
76 ; Deco Calculator Main Function
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
77 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
78 global do_demo_planner
0
heinrichsweikamp
parents:
diff changeset
79 do_demo_planner:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
80 btfsc FLAG_gauge_mode ; in gauge mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
81 bra do_demo_planner_exit ; YES - abort
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
82 btfsc FLAG_apnoe_mode ; in apnea mode?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
83 bra do_demo_planner_exit ; YES - abort
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
84
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
85 clrf decoplan_flags ; clear all local flags
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
86 bsf simulatormode ; activate simulator mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
87 bsf reset_timebase ; request ISR to reset the timebase
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
88 ; btfsc reset_timebase ; has the ISR confirmed reset of the timebase?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
89 ; bra $-2 ; NO - not yet, loop waiting for the ISR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
90 call deco_push_tissues_to_vault ; back-up the state of the real tissues (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
91 banksel common ; back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
92
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
93 MOVII int_O_CNS_current,real_CNS ; memorize real CNS value from before simulated dive
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
94
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
95 rcall deco_calculate ; calculate deco plan
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
96
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
97 btfss decoplan_abort ; was the deco plan calculation aborted?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
98 rcall deco_results ; NO - show results
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
99
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
100 movff simulator_time,char_I_dive_interval ; get the deco calculator runtime
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
101 call deco_pull_tissues_from_vault ; restore the status of the real tissues (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
102 call deco_calc_dive_interval ; catch up with tissue desaturation (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
103 call deco_calc_desaturation_time ; calculate desaturation and no-fly/no-altitude time after catch-up (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
104 banksel common ; back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
105
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
106 bcf switch_left ; clear left button event (may be left over from abort/exit)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
107 bcf simulatormode ; terminate simulator mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
108 bsf reset_timebase ; request ISR to reset the timebase
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
109 ; btfsc reset_timebase ; has the ISR confirmed reset of timebase?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
110 ; bra $-2 ; NO - not yet, loop waiting for the ISR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
111
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
112 btfsc divemode ; shall go into dive mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
113 goto restart ; YES - goto restart which will dispatch further on to dive mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
114
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
115 btfss trigger_timeout ; timeout on any button press?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
116 bra do_demo_planner_exit ; NO - take normal exit into surface menu
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
117 bcf trigger_timeout ; YES - clear timeout flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
118 bcf restart_fast ; - set next restart to be done slow, i.e. with logos
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
119 goto sleeploop ; - goto sleep mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
120
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
121 do_demo_planner_exit:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
122 goto do_return_demo_planner ; return to simulator menu
0
heinrichsweikamp
parents:
diff changeset
123
heinrichsweikamp
parents:
diff changeset
124
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
125 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
126 ; Calculate the Deco Plan
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
127 ;
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
128 deco_calculate:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
129 call request_speed_fastest ; request CPU speed change to fastest speed
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
130 call TFT_ClearScreen ; clear screen to show that calculator is starting up
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
131
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
132 ; initialization of the deco engine
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
133 btfsc update_surface_pressure ; is there a pending surface pressure update?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
134 bra $-2 ; YES - loop waiting for the ISR to kick in
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
135
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
136 ; calculate absolute pressure at selected depth
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
137 movff char_I_bottom_depth,WREG ; get selected depth in meters
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
138 movwf depth_meter ; store depth for check_gas_best code
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
139
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
140 movwf xA+0 ; copy depth in [m] to xA, low byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
141 clrf xA+1 ; clear xA, high byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
142
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
143 movff opt_salinity,WREG ; get salinity setting (0 - 4 %)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
144 addlw d'100' ; add density of fresh water (1.00 kg/l)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
145 mullw .100 ; multiply by 100 to counteract the x 100 with the freshwater conversion factor
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
146 MOVII PRODL,xB ; copy result to xB
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
147 call mult16x16 ; xC:4 = xA:2 * xB:2
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
148
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
149 MOVLI .102,xB ; load conversion factor x 100 for fresh water (1.02 cm per each 1 mbar)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
150 call div32x16 ; xC:4 = xC:4 / xB:2 with xA as remainder = relative pressure [mbar] at depth
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
151
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
152 movff int_I_pres_surface+0,WREG ; get surface pressure, low byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
153 addwf xC+0,W ; add relative pressure, low byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
154 movff WREG,int_I_pres_respiration+0 ; store as absolute pressure, low byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
155 movff int_I_pres_surface+1,WREG ; get surface pressure, high byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
156 addwfc xC+1,W ; add relative pressure, high byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
157 movff WREG,int_I_pres_respiration+1 ; store as absolute pressure, high byte
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
158
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
159 ; compute absolute pressure / 10, will be used by check_gas_best
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
160 MOVII int_I_pres_respiration,xA ; get absolute pressure at depth
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
161 MOVLI .10,xB ; divide by 10
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
162 call div16x16 ; xC = xA / xB = absolute pressure / 10
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
163 MOVII xC,pressure_abs_10 ; store result for later use
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
164
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
165 ; set up gas / diluent to be used on bottom segment
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
166 clrf WREG ; reset the deco info vector / deco flag so that ...
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
167 movff WREG,char_O_deco_info ; ... check_gas_best will not pick any deco gases
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
168
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
169 call get_first_gas_to_WREG ; find first gas
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
170 movwf active_gas ; set first gas
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
171 IFDEF _ccr_pscr
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
172 call get_first_dil_to_WREG ; find first diluent
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
173 movwf active_dil ; set first diluent
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
174 ENDIF
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
175 call check_gas_best ; check if first gas & dil are usable, if not replace by usable gas / dil
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
176
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
177 IFDEF _ccr_pscr
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
178 btfsc FLAG_oc_mode ; in OC mode?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
179 bra deco_calculate_0_oc ; YES - set up OC mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
180 ;bra deco_calculate_0_loop ; NO - set up CCR/pSCR mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
181
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
182 deco_calculate_0_loop:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
183 movf best_dil_number,W ; get best diluent into WREG
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
184 bz deco_calculate_0_error ; any usable diluent found? if NO do error handling
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
185 call setup_dil_registers ; set-up of diluent parameters for currently breathed diluent
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
186 call deco_setup_cc_diluents ; set-up of diluent list for deco calculations
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
187 bra deco_calculate_0_com ; continue with common part
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
188 ENDIF
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
189
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
190 deco_calculate_0_oc:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
191 movf best_gas_number,W ; get best gas into WREG
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
192 bz deco_calculate_0_error ; any usable gas found? if NO do error handling
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
193 call setup_gas_registers ; set-up of gas parameters of currently breathed gas
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
194 call deco_setup_oc_gases ; set-up of gas list for deco calculations
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
195 bra deco_calculate_0_com ; continue with common part
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
196
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
197 deco_calculate_0_error:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
198 call request_speed_normal ; request switch back to normal speed
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
199 WIN_COLOR color_red ; select color for error message
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
200 TEXT_SMALL .0, .80, tNoBottomGas1 ; print error message, line 1
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
201 TEXT_SMALL .0, .105, tNoBottomGas2 ; print error message, line 2
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
202 bsf decoplan_abort ; set abort flag
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
203 call wait_1s ; wait up to a full second
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
204 call wait_1s ; wait a full second
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
205 call wait_1s ; wait another full second
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
206 bcf switch_left ; clear potential button event
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
207 return ; return to deco calculator main function
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
208
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
209 deco_calculate_0_com:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
210 ; set deco stop settings
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
211 movff opt_last_stop,char_I_last_stop_depth ; write last stop depth to deco engine
0
heinrichsweikamp
parents:
diff changeset
212
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
213 ; set GF factors
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
214 movff opt_GF_low, char_I_GF_Low_percentage ; load normal GF factors by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
215 movff opt_GF_high,char_I_GF_High_percentage ; ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
216 TSTOSS opt_sim_use_aGF ; shall use alternative GF factors in simulation?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
217 bra deco_calculate_1 ; NO - keep normal GF factors
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
218 movff opt_aGF_low ,char_I_GF_Low_percentage ; YES - overwrite with alternative GF factors
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
219 movff opt_aGF_high,char_I_GF_High_percentage ; - ...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
220
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
221 deco_calculate_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
222
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
223 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
224 ; set char_I_const_ppO2 for pSCR/CCR mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
225 clrf WREG ; load coding for pSCR calculated ppO2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
226 btfsc FLAG_pscr_mode ; in pSCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
227 movff WREG,char_I_const_ppO2 ; YES - configure pSCR computations to calculated ppO2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
228 btfss FLAG_ccr_mode ; in CCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
229 bra deco_calculate_2 ; NO - skip next
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
230 movff opt_sim_setpoint_number,WREG ; YES - get selected setpoint
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
231 decf WREG,W ; - 1-5 -> 0-4
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
232 lfsr FSR1,opt_setpoint_cbar ; - set base address of setpoint list
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
233 movff PLUSW1,char_I_const_ppO2 ; - configure setpoint value
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
234 ENDIF
0
heinrichsweikamp
parents:
diff changeset
235
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
236 deco_calculate_2:
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
237
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
238 ; configure the deco engine - char_O_main_status
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
239 movff char_O_main_status,hi ; get the configuration set by dive_boot_oc / dive_boot_cc
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
240 bsf hi,DECO_VOLUME_FLAG ; enable gas volume calculation
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
241 bsf hi,DECO_BOTTOM_FLAG ; include bottom segment into gas needs
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
242
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
243 IFDEF _cave_mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
244 bcf hi,DECO_CAVE_MODE ; cave mode not supported in deco calculator
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
245 ENDIF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
246
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
247 IFDEF _gas_contingency
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
248 bcf hi,DECO_GAS_CONTINGENCY ; disable gas contingency mode by default
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
249 TSTOSC opt_gas_contingency_sim ; gas contingency switched on?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
250 bsf hi,DECO_GAS_CONTINGENCY ; YES - activate gas contingency mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
251 ENDIF
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
252
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
253 bcf hi,DECO_EXTENDED_STOPS ; disable extended stops by default
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
254 TSTOSC opt_ext_stops ; shall make extended stops?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
255 bsf hi,DECO_EXTENDED_STOPS ; YES - activate extended stops
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
256 bcf hi,DECO_TR_FUNCTIONS ; execution of TR functions is not needed in deco calculator mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
257 movff hi,char_O_main_status ; bank-safe copy to deco engine control
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
258
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
259 ; configure the deco engine - char_O_deco_status
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
260 movff char_O_deco_status,lo ; get the configuration set by dive_boot_oc / dive_boot_cc
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
261 bcf lo,DECO_START_NORM ; clear flag for normal plan mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
262 bcf lo,DECO_START_ALT ; clear flag for alternative plan mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
263 bsf lo,DECO_INITIALIZE ; set flag for once-per-dive initialization
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
264 bsf lo,DECO_CALCULATOR_MODE ; signal that the deco engine is run from the deco calculator
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
265 bcf lo,DECO_BAILOUT_FLAG ; no gas switches before first deco stop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
266 bcf lo,DECO_DELAY_FLAG ; no delayed ascent
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
267 movff lo,char_O_deco_status ; bank-safe copy to deco engine control
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
268
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
269 deco_calculate_redo:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
270
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
271 call request_speed_fastest ; request CPU speed change to fastest speed (again, if in redo)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
272
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
273 ; show that the deco calculation is in progress
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
274 call TFT_ClearScreen ; clear screen from last results
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
275 WIN_COLOR color_lightblue ; select color for abort label
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
276 TEXT_SMALL .1,.215, tAbort ; print abort label
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
277 WIN_COLOR color_white ; select color for title and progress outputs
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
278 TEXT_SMALL .0, .40, tCalculating ; print "Calculating..."
0
heinrichsweikamp
parents:
diff changeset
279
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
280 ; calculate the surface interval
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
281 TSTOSS opt_surface_interval ; surface interval > 0 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
282 bra deco_calculate_bottom ; NO - continue with bottom segment
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
283 TEXT_SMALL .20,.75, tCalcSurfInter ; YES - print what we are doing
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
284 movff opt_surface_interval,char_I_dive_interval ; - copy surface interval to deco engine
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
285 call deco_calc_dive_interval ; - calculate surface interval (C-code)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
286 banksel common ; - back to bank common
0
heinrichsweikamp
parents:
diff changeset
287
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
288 ; calculate the bottom segment
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
289 deco_calculate_bottom:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
290 ; advance tissues by selected bottom time,
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
291 ; char_I_sim_advance_time is cleared by deco engine after execution
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
292 movff char_I_bottom_time,char_I_sim_advance_time
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
293
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
294 TEXT_SMALL .20,.100,tCalcBotSeg ; print what we are doing
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
295
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
296 ; invoke the deco engine once to condition the real tissues
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
297 ; to their pressure state at the end of the bottom segment
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
298 call deco_calc_hauptroutine ; (C-code)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
299 banksel common
0
heinrichsweikamp
parents:
diff changeset
300
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
301 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
302 ; conditional switch to bailout mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
303 btfss bailout_mode ; shall calculate a bailout plan?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
304 bra deco_calculate_ascent ; NO - skip next
111
c61b7a4e317c Bugfix: CNS in planner
heinrichsweikamp
parents: 97
diff changeset
305
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
306 call dive_boot_oc ; YES - switch to OC mode, configure OC gases and switch to gas set as 'First'
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
307 movff char_O_main_status,hi ; - bank-safe copy from deco engine control (main status)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
308 bcf hi,DECO_BOTTOM_FLAG ; - exclude bottom segment from gas needs, i.e. calculate ascent needs only
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
309 movff hi,char_O_main_status ; - bank-safe copy back to deco engine control
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
310 movff char_O_deco_status,lo ; - bank-safe copy from deco engine control (deco status)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
311 bsf lo,DECO_BAILOUT_FLAG ; - allow gas switches before first deco stop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
312 bsf lo,DECO_DELAY_FLAG ; - allow delayed ascent
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
313 movff lo,char_O_deco_status ; - bank-safe copy back to deco engine control
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
314
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
315 TEXT_SMALL .20,.125, tCalcBailout ; - print what we are doing
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
316 ENDIF
0
heinrichsweikamp
parents:
diff changeset
317
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
318 ; calculate ascent
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
319 deco_calculate_ascent:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
320 movff char_O_deco_status,lo ; bank-safe copy from deco engine control
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
321 bsf lo,DECO_START_NORM ; start calculation of a normal plan
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
322 movff lo,char_O_deco_status ; bank-safe copy back to deco engine control
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
323 TEXT_SMALL .20,.150, tCalcAscent ; print what we are doing
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
324 deco_calculate_loop:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
325 btfsc switch_left ; was the left button pressed?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
326 bra deco_calculate_abort ; YES - set abort flag, do some clean-up and return
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
327 call deco_calc_hauptroutine ; NO - invoke the deco engine so that it can do the deco calculation (C-code)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
328 banksel common ; - back to bank common
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
329 movff char_O_depth_sim,lo ; - get the depth reached (in meters)
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
330 WIN_SMALL .75,.150 ; - set output position
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
331
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
332 TSTOSS opt_units ; check depth units
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
333 bra deco_calculate_loop_metric ; 0 - use Meters
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
334 ;bra deco_calculate_loop_imperial ; 1 - use Feet
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
335
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
336 deco_calculate_loop_imperial:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
337 call convert_meter_to_feet ; convert value in lo from [m] to [feet]
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
338 output_16_3 ; print depth reached
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
339 STRCAT_TEXT tFeets ; print unit (feet)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
340 bra deco_calculate_loop_0
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
341
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
342 deco_calculate_loop_metric:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
343 output_8 ; print depth reached (in meters)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
344 STRCAT_TEXT tMeters ; print unit (meters)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
345 ;bra deco_calculate_loop_0 ; continue
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
346
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
347 deco_calculate_loop_0:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
348 btg decoplan_toggleflag ; - toggle the toggle flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
349 btfsc decoplan_toggleflag ; - toggle flag set?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
350 bra deco_calculate_loop_1 ; YES - print ". "
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
351 STRCAT_PRINT " ." ; NO - print " ."
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
352 bra deco_calculate_loop_2 ;
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
353 deco_calculate_loop_1: ;
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
354 STRCAT_PRINT ". " ;
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
355 deco_calculate_loop_2: ;
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
356 movff char_O_deco_status,lo ; - get deco calculation status
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
357 btfss lo,DECO_COMPLETED_NORM ; - deco calculation completed?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
358 bra deco_calculate_loop ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
359 movff char_O_deco_warnings,decoplan_warnings; YES - copy warnings for later display
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
360 bra deco_calculate_finish ; - do some clean-up and return
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
361 deco_calculate_abort:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
362 bcf switch_left ; clear button event
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
363 bsf decoplan_abort ; set abort flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
364 deco_calculate_finish:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
365 goto request_speed_normal ; request switch back to normal speed and return to deco calculator main function
0
heinrichsweikamp
parents:
diff changeset
366
heinrichsweikamp
parents:
diff changeset
367
heinrichsweikamp
parents:
diff changeset
368 ;-----------------------------------------------------------------------------
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
369 ; Draw a stop of the deco plan (simulator or dive)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
370 ; Inputs: lo = depth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
371 ; hi = minutes
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
372 ; win_top = line to draw on screen.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
373 ;
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
374 ; Trashed: hi, lo,
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
375 ; win_height, win_leftx2, win_width, win_color*,
0
heinrichsweikamp
parents:
diff changeset
376 ; WREG, PROD, TBLPTR TABLAT.
heinrichsweikamp
parents:
diff changeset
377 ;
heinrichsweikamp
parents:
diff changeset
378 deco_plan_show_stop:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
379 ; print depth
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
380 lfsr FSR2,char_O_deco_gas ; needed to be initialized here every time because...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
381 movf decoplan_gindex,W ; ...FSR2 is also used for string operations
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
382 movff PLUSW2,WREG ; get current gas and copy it to WREG for color-coding
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
383 call TFT_color_code_gas ; set output color dependent on gas (1-5)
0
heinrichsweikamp
parents:
diff changeset
384
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
385 lfsr FSR2,buffer ; set up output buffer
0
heinrichsweikamp
parents:
diff changeset
386
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
387 TSTOSS opt_units ; 0=Meter, 1=Feet
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
388 bra deco_plan_show_nstd_stop_metric ; 0 - do metric
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
389 ; 1 - do imperial
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
390 movff hi,ul ; back-up hi (minutes)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
391 WIN_LEFT .80
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
392 call convert_meter_to_feet ; convert value in lo from meters to feet
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
393 output_16_3 ; limit output to 0...999
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
394 STRCAT_PRINT "ft"
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
395 movff ul,hi ; restore hi (minutes)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
396 bra deco_plan_show_nstd_stop_common
0
heinrichsweikamp
parents:
diff changeset
397
heinrichsweikamp
parents:
diff changeset
398 deco_plan_show_nstd_stop_metric:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
399 WIN_LEFT .85
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
400 output_8 ; outputs into postinc2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
401 STRCAT_PRINT "m"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
402
0
heinrichsweikamp
parents:
diff changeset
403 deco_plan_show_nstd_stop_common:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
404
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
405 ; print duration
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
406 WIN_LEFT .135
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
407 lfsr FSR2,buffer
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
408 movff hi,lo
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
409 output_99dd ; stop entries are 99 minutes at max., prints double dots if duration is zero
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
410 STRCAT_PRINT "'"
0
heinrichsweikamp
parents:
diff changeset
411
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
412 ; draw the bar graph used for deco stops (lo = minutes)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
413 incf win_top,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
414 movlw .19
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
415 movwf win_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
416 movlw .118
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
417 movwf win_leftx2 ; column left (0-159)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
418 MOVLI .16,win_width ; column max width
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
419 incf lo,W ; add 1 for a minimum visible active bargraph area
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
420 movwf win_bargraph ; set width of the active bargraph area
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
421 call TFT_box ; draw bargraph
0
heinrichsweikamp
parents:
diff changeset
422
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
423 ; restore win_top
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
424 call TFT_standard_color
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
425 decf win_top,F ; restore win_top
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
426 return
0
heinrichsweikamp
parents:
diff changeset
427
heinrichsweikamp
parents:
diff changeset
428
heinrichsweikamp
parents:
diff changeset
429 ;-----------------------------------------------------------------------------
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
430 ; Display the deco plan (simulator)
0
heinrichsweikamp
parents:
diff changeset
431 ; Inputs: char_O_deco_table (array of stop times, in minutes)
heinrichsweikamp
parents:
diff changeset
432 ; decoplan_page = page number.
heinrichsweikamp
parents:
diff changeset
433 ;
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
434 deco_results_page:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
435 bcf win_invert ; reset invert flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
436 WIN_COLOR color_greenish
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
437 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
438 btfss bailout_mode ; bailout results?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
439 bra deco_results_page_1 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
440 TEXT_SMALL .80,.1, tDiveBailout ; YES
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
441 bra deco_results_page_2
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
442 ENDIF
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
443 deco_results_page_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
444 TEXT_SMALL .80,.1, tDivePlan
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
445 deco_results_page_2:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
446 movff char_O_deco_info,WREG ; get the deco info vector
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
447 btfsc WREG,deco_stops_norm ; are there deco stops?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
448 bra deco_plan_show_1 ; YES
0
heinrichsweikamp
parents:
diff changeset
449
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
450 ;---- no deco --------------------------------------------------------
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
451 call TFT_standard_color
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
452 TEXT_SMALL .80, .25, tNoDeco
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
453
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
454 ; output of remaining NDL time
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
455 WIN_SMALL .80, .50 ; same line as bottom time
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
456 PUTC "+"
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
457 movff int_O_NDL_norm+0,lo ; get NDL time in normal plan
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
458 bsf leftbind
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
459 output_8
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
460 bcf leftbind
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
461 PUTC "'"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
462 PUTC " "
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
463 STRCAT_TEXT_PRINT tNDLleft ; "NDL"
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
464
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
465 bsf decoplan_last_stop_shown
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
466 return
0
heinrichsweikamp
parents:
diff changeset
467
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
468 ;---- deco stops ---------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
469 deco_plan_show_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
470 lfsr FSR0,char_O_deco_depth ; initialize indexed addressing
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
471 lfsr FSR1,char_O_deco_time ; ...
0
heinrichsweikamp
parents:
diff changeset
472
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
473 clrf decoplan_index ; start with index = 0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
474 movlw .24
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
475 movwf win_top ; and row = 0 at position 24
0
heinrichsweikamp
parents:
diff changeset
476
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
477 ; read stop parameters, indexed by decoplan_index and decoplan_page
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
478 movf decoplan_page,W ; decoplan_gindex = 6*decoplan_page + decoplan_index
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
479 mullw .8 ; 8 lines/page in deco plan
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
480 movf decoplan_index,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
481 addwf PRODL,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
482 movwf decoplan_gindex ; --> decoplan_gindex
0
heinrichsweikamp
parents:
diff changeset
483
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
484 bcf decoplan_last_stop_shown ; not done yet...
0
heinrichsweikamp
parents:
diff changeset
485
heinrichsweikamp
parents:
diff changeset
486 deco_plan_show_2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
487 btfsc decoplan_gindex,5 ; reached table length (32) ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
488 bra deco_plan_show_99 ; YES - done
0
heinrichsweikamp
parents:
diff changeset
489
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
490 ; read stop parameters, indexed by decoplan_index
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
491 movf decoplan_gindex,W ; index
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
492 movff PLUSW0,lo ; char_O_deco_depth[decoplan_gindex]
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
493 movff PLUSW1,hi ; char_O_deco_time [decoplan_gindex]
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
494 movf lo,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
495 bz deco_plan_show_99 ; depth == 0 -> done
0
heinrichsweikamp
parents:
diff changeset
496
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
497 ; display the stop line
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
498 rcall deco_plan_show_stop
0
heinrichsweikamp
parents:
diff changeset
499
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
500 ; next
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
501 movlw .24
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
502 addwf win_top,F ; row: += 24
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
503 incf decoplan_index,F ; local index += 1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
504 incf decoplan_gindex,F ; global index += 1
0
heinrichsweikamp
parents:
diff changeset
505
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
506 ; max number of lines/page reached?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
507 movlw .8 ; 8 lines/page in deco plan
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
508 cpfseq decoplan_index
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
509 bra deco_plan_show_2 ; NO - loop
0
heinrichsweikamp
parents:
diff changeset
510
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
511 ; check if next stop is end-of-list?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
512 movf decoplan_gindex,W
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
513 movf PLUSW0,W ; char_O_deco_depth[decoplan_gindex]
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
514 bz deco_plan_show_99 ; end of list
0
heinrichsweikamp
parents:
diff changeset
515
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
516 call TFT_standard_color
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
517 WIN_SMALL .135,.212
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
518 STRCAT_PRINT ">>>"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
519 return
0
heinrichsweikamp
parents:
diff changeset
520
heinrichsweikamp
parents:
diff changeset
521 deco_plan_show_99:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
522 bsf decoplan_last_stop_shown ; nothing more in table to display
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
523 call TFT_standard_color
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
524 return
0
heinrichsweikamp
parents:
diff changeset
525
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
526 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
527 ; Show Deco Calculation Results
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
528 ;
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
529 deco_results:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
530 call TFT_ClearScreen
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
531 call TFT_standard_color
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
532
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
533 ; print interval
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
534 WIN_SMALL .0,.25
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
535 STRCPY "Int. :"
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
536 movff opt_surface_interval,lo
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
537 output_8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
538 STRCAT_PRINT "'"
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
539
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
540 ; print bottom time
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
541 WIN_SMALL .0,.50
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
542 STRCPY_TEXT tBtTm_short
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
543 movff char_I_bottom_time,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
544 output_8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
545 STRCAT_PRINT "'"
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
546
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
547 ; print bottom depth
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
548 WIN_SMALL .0,.75
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
549 STRCPY_TEXT tDepth
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
550 PUTC ":"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
551 movff char_I_bottom_depth,lo
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
552
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
553 TSTOSS opt_units ; check depth units
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
554 bra deco_results_metric ; 0 - use Meters
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
555 ;bra deco_results_imperial ; 1 - use Feet
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
556
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
557 deco_results_imperial:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
558 call convert_meter_to_feet ; convert value in lo from [m] to [feet]
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
559 output_16_3 ; print depth reached
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
560 STRCAT_TEXT tFeets ; print unit (feet)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
561 bra deco_results_0 ; continue
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
562
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
563 deco_results_metric:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
564 output_8 ; print depth reached (in meters)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
565 STRCAT_TEXT tMeters ; print unit (meters)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
566 ;bra deco_results_0 ; continue
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
567
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
568 deco_results_0:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
569 STRCAT_PRINT "" ; finalize bottom depth output
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
570
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
571 ; print warnings or sat/dsat factors
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
572 WIN_SMALL .0,.105
208
53771bd3d567 NEW: Show plan parameters in decoplan result page
heinrichsweikamp
parents: 197
diff changeset
573
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
574 ; check for stop table overflow
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
575 btfss decoplan_warnings,deco_plan_incomplete ; check if deco plan is incomplete
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
576 bra deco_results_0a ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
577
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
578 ; display overflow warning
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
579 call TFT_warning_color ; YES - show overflow warning
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
580 STRCAT_PRINT "incomplete" ; max 10 characters
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
581 bra deco_results_m1 ; skip displaying sat/dsat factors
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
582
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
583 deco_results_0a:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
584
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
585 IFDEF _helium
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
586 ; check for IBCD warning
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
587 btfss decoplan_warnings,IBCD_warning_lock ; check if we have a locked IBCD warning
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
588 bra deco_results_2b ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
589
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
590 ; display IBCD warning
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
591 call TFT_attention_color ; YES - show IBCD warning
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
592 STRCAT_PRINT "IBCD!" ; max 10 characters
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
593 bra deco_results_m1 ; skip displaying sat/dsat factors
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
594 ENDIF
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
595
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
596 deco_results_2b:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
597
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
598 ; display Sat/Desat factors --> omitted if there were warnings
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
599 STRCAT_PRINT "SD:"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
600 WIN_SMALL .25,.105
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
601 movff char_I_saturation_multiplier,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
602 output_8
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
603 STRCAT "/"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
604 movff char_I_desaturation_multiplier,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
605 output_8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
606 STRCAT_PRINT ""
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
607
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
608 deco_results_m1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
609
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
610 call TFT_standard_color ; clean-up from warnings
0
heinrichsweikamp
parents:
diff changeset
611
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
612 ; get model
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
613 movff char_I_model,WREG ; 0: straight Buhlmann, 1: with GF
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
614 iorwf WREG ; GF factors in use?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
615 bz deco_results_m2 ; NO
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
616
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
617 ; display GF low/high factors
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
618 WIN_SMALL .0,.130
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
619 STRCAT_PRINT "GF:"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
620 WIN_SMALL .25,.130
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
621 movff char_I_GF_Low_percentage,lo
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
622 output_8
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
623 STRCAT "/"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
624 movff char_I_GF_High_percentage,lo
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
625 output_8
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
626 STRCAT_PRINT ""
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
627
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
628 deco_results_m2:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
629
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
630 ; display deco mode
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
631 WIN_SMALL .0,.155
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
632 lfsr FSR2,buffer
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
633 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
634 call TFT_decotype_logbook
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
635
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
636 IFDEF _ccr_pscr
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
637 btfss FLAG_ccr_mode ; current dive mode = CCR ?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
638 bra deco_results_2c ; NO - skip
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
639 WIN_SMALL .25,.155
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
640 STRCPY "SP:" ; output setpoint used for calculation
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
641 movff opt_sim_setpoint_number,lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
642 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
643 output_8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
644 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
645 STRCAT_PRINT ""
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
646 ENDIF
0
heinrichsweikamp
parents:
diff changeset
647
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
648 deco_results_2c:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
649
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
650 btfss FLAG_oc_mode ; current dive mode = OC ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
651 bra deco_results_2d ; NO - skip
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
652 TSTOSS opt_ext_stops ; YES - extended stops activated?
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
653 bra deco_results_2d ; NO - skip
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
654 WIN_SMALL .18,.155 ; YES - set position
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
655 STRCAT_PRINT "ext.Stop" ; - print notice
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
656
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
657 deco_results_2d:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
658
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
659 ; display TTS result
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
660 WIN_SMALL .0,.180
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
661 STRCPY_TEXT tTTS
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
662 STRCAT ": "
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
663 MOVII int_O_TTS_norm,mpr
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
664 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
665 output_16
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
666 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
667 STRCAT_PRINT "'"
0
heinrichsweikamp
parents:
diff changeset
668
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
669 ; display CNS result
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
670 WIN_TOP .205
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
671 STRCPY_TEXT tCNS2 ; "CNS:"
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
672 MOVII real_CNS,mpr ; recall real CNS from before simulated dive
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
673 call TFT_color_code_cns ; color-code CNS output
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
674 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
675 output_16_3 ; limit to 999 and display only (0-999)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
676 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
677 STRCAT "%\x92" ; "->"
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
678 MOVII int_O_CNS_norm,mpr ; get CNS at end of simulated dive in normal plan
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
679 call TFT_color_code_cns ; color-code CNS output
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
680 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
681 output_16_3 ; limit to 999 and display only (0-999)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
682 bcf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
683 STRCAT_PRINT "%"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
684 call TFT_standard_color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
685
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
686 ; loop through deco plan pages
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
687 deco_results_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
688 clrf decoplan_page ; start from first page
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
689 bcf decoplan_pressures_shown ; when showing the gas needs, start with volumes (liter)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
690 deco_results_1a:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
691 WIN_BOX_BLACK .0, .239, .80, .159 ; clear the complete right part of the result column (top, bottom, left, right)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
692 rcall deco_results_page ; show a results page
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
693 incf decoplan_page,F ; increment results page number
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
694 call reset_timeout_surfmode ; reset timeout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
695 bcf switch_right ; clear left-over right button event
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
696 bcf switch_left ; clear left-over left button event
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
697 deco_results_2:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
698 btfsc switch_right ; right button pressed?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
699 bra deco_results_3 ; YES - show further results
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
700 btfsc switch_left ; left button pressed?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
701 return ; YES - return to deco calculator main function
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
702 call housekeeping ; NO to both - handle screen dump request, timeout and need to enter dive mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
703 btfsc divemode ; shall go into dive mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
704 bsf decoplan_abort ; YES - set abort flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
705 btfsc trigger_timeout ; timeout on any button press?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
706 bsf decoplan_abort ; YES - set abort flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
707 btfss decoplan_abort ; shall abort?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
708 bra deco_results_2 ; NO - loop
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
709 return ; YES
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
710
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
711 deco_results_3:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
712 btfss decoplan_last_stop_shown ; was the last stop shown already?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
713 bra deco_results_1a ; NO - loop
284
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
714
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
715 IFDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
716 movff char_O_deco_status,WREG ; YES - get deco calculation status
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
717 btfss WREG,DECO_MODE_LOOP_FLAG ; - check if calculation was made for loop mode (CCR/pSCR)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
718 bra deco_results_gas_volumes ; NO - normal OC mode or bailout mode, show gas needs
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
719 bsf bailout_mode ; YES - do a 2nd deco-plan in bailout mode
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
720 call deco_pull_tissues_from_vault ; - restore the status of the real tissues (C-code)
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
721 banksel common ; - back to bank common
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
722 rcall deco_calculate_redo ; - redo complete deco calculation
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
723 btfss decoplan_abort ; - was the calculation aborted?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
724 bra deco_results ; NO - redo display of deco stops
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
725 return ; YES - return to deco calculator main function
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
726 ENDIF
284
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
727
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
728 ;---- show the gas needs (OC and bailout only) ---------------------------
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
729 deco_results_gas_volumes:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
730 lfsr FSR0,int_O_gas_need_vol ; load base address of gas needs in volume
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
731
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
732 deco_results_gas_common:
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
733 WIN_BOX_BLACK .0, .239, .80, .159 ; clear the complete right part of the result column (top, bottom, left, right)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
734 movlw .25 ; output row is 25 (fixed offset set here) + n*25 (line increment, see below)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
735 movwf output_row ; set fixed vertical offset for output row
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
736 WIN_LEFT .80 ; set column
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
737 call TFT_standard_color
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
738 clrf gas_index ; initialize gas counter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
739 bcf is_diluent_menu ; working on OC gases
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
740
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
741 deco_results_gas_loop:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
742 movff gas_index,PRODL ; copy gas index to PRODL (interface to gaslist_strcat_gas)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
743 incf gas_index,F ; increment gas index
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
744
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
745 movf gas_index,W ; copy gas index to WREG for color-coding
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
746 call TFT_color_code_gas ; set output color according to gas (1-5)
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
747
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
748 lfsr FSR2,buffer ; set base address of output buffer
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
749 bsf short_gas_descriptions ; configure gaslist_strcat_gas output format
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
750 bsf divemode ; configure gaslist_strcat_gas output format
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
751 call gaslist_strcat_gas ; write "Nxlo", "Txlo/hi", "Air" or "O2" into output buffer
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
752 bcf divemode ; cleanup above
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
753
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
754 movlw .25 ; spacing between outputs
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
755 addwf output_row,F ; increase row position
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
756 movff output_row,win_top ; set row position
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
757
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
758 movff POSTINC0,lo ; read gas volume low byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
759 movff POSTINC0,hi ; high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
760
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
761 bcf decoplan_overflow ; no overflow in gas needs by default
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
762
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
763 btfsc decoplan_pressures_shown ; results in bar?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
764 bra deco_results_gas_volumes_1 ; YES
284
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
765
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
766 ; output of gas needs in liter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
767 movf lo,W ; check if hi:lo = 65535: copy low byte to WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
768 andwf hi,W ; and do a bitwise AND with the high byte
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
769 incfsz WREG ; add 1, result zero now?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
770 bra deco_results_gas_volumes_2 ; NO - print volume
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
771 STRCAT_PRINT ">65500" ; YES - print ">65500"
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
772 bra deco_results_gas_volumes_3 ; - continue checking if all gases are shown
284
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
773
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
774 ; output of gas needs in bar
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
775 deco_results_gas_volumes_1:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
776 btfsc hi,int_high_flag ; overflow in result?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
777 bsf decoplan_overflow ; YES - remember it
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
778 bcf hi,int_high_flag ; clear flag for overflow in result
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
779 btfsc hi,int_warning_flag ; gas needs above available amount?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
780 bsf win_invert ; YES - print in inverse
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
781 bcf hi,int_warning_flag ; clear flag for gas needs above available amount
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
782 bcf hi,int_attention_flag ; clear flag for gas needs close to available amount
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
783 bcf hi,int_invalid_flag ; clear flag for invalid data
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
784 bcf hi,int_is_zero ; clear flag for zero
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
785
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
786 deco_results_gas_volumes_2:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
787 PUTC ":" ; print ":"
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
788 output_16 ; print 16 bit number
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
789 movlw '>' ; load coding of ">" sign into WREG
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
790 btfsc decoplan_overflow ; overflow in result?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
791 movff WREG,buffer+.7 ; YES - place ">" before number
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
792 STRCAT_PRINT "" ; finalize output
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
793 bcf win_invert ; back to none-inverse printing
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
794
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
795 deco_results_gas_volumes_3:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
796 movlw NUM_GAS ; 5 gases to show
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
797 cpfseq gas_index ; all gases shown?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
798 bra deco_results_gas_loop ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
799
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
800 WIN_COLOR color_greenish ; set color
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
801 TEXT_SMALL .80,.01,tGasUsage ; "Gas Usage"
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
802
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
803 btfsc decoplan_pressures_shown ; results shown in bar?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
804 bra deco_results_gas_volumes_4 ; YES
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
805 TEXT_SMALL .120,.25,tLiterLong ; NO - in Liter then
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
806 bra deco_results_gas_volumes_5 ; - continue with initialization of housekeeping
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 598
diff changeset
807
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
808 deco_results_gas_volumes_4:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
809 TEXT_SMALL .120,.25,tbar ; " bar" (with leading space)
284
d1117b99fd99 preperations to compute gas consumtion in simulator
heinrichsweikamp
parents: 275
diff changeset
810
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
811 deco_results_gas_volumes_5:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
812 call TFT_standard_color ; revert to standard color
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
813 call reset_timeout_surfmode ; reset timeout
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
814 bcf switch_right ; clear left-over right button event
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
815 bcf switch_left ; clear left-over left button event
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
816 deco_results_gas_volumes_6:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
817 btfsc switch_right ; right button pressed?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
818 bra deco_results_gas_volumes_7 ; YES - show results in bar or restart with deco stops again
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
819 btfsc switch_left ; left button pressed?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
820 return ; YES - return to deco calculator main function
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
821 call housekeeping ; NO to both - handle screen dump request, timeout and need to enter dive mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
822 btfsc divemode ; shall go into dive mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
823 bsf decoplan_abort ; YES - set abort flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
824 btfsc trigger_timeout ; timeout on any button press?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
825 bsf decoplan_abort ; YES - set abort flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
826 btfss decoplan_abort ; shall abort?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
827 bra deco_results_gas_volumes_6 ; NO - loop
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
828 return ; YES
560
b7eb98dbd800 bump to 2.96beta (REFACTORED VERSION)
heinrichsweikamp
parents: 549
diff changeset
829
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
830 deco_results_gas_volumes_7:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
831 btfsc decoplan_pressures_shown ; results shown in bar?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
832 bra deco_results_1 ; YES - show deco stops again
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
833 bsf decoplan_pressures_shown ; NO - but now
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
834 lfsr FSR0,int_O_gas_need_pres ; - set base address of gas needs in bar
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
835 bra deco_results_gas_common ; - re-run gas needs output in pressure mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 604
diff changeset
836
0
heinrichsweikamp
parents:
diff changeset
837
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 560
diff changeset
838 END