annotate src/simulator.asm @ 648:aeca5717d9eb

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