annotate code_part1/OSTC_code_c_part2/p2_deco_main.c @ 12:588a969a0cae

1.53 beta rc
author heinrichsweikamp
date Wed, 24 Mar 2010 20:26:09 +0100
parents 96a35aeda5f2
children 3691ea95a34d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1 /*
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2 * p2_deco_main.c
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3 *
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
4 * Created on: 31.08.2009
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
5 * Author: christian.w @ heinrichsweikamp.com
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
6 *
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
7 */
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
8
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
9 //#include <p2_deco_header_c_v102d.h>
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
10
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
11 // OSTC - diving computer code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
12 // Copyright (C) 2009 HeinrichsWeikamp GbR
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
13
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
14 // This program is free software: you can redistribute it and/or modify
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
15 // it under the terms of the GNU General Public License as published by
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
16 // the Free Software Foundation, either version 3 of the License, or
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
17 // (at your option) any later version.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
18
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
19 // This program is distributed in the hope that it will be useful,
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
22 // GNU General Public License for more details.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
23
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
24 // You should have received a copy of the GNU General Public License
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
25 // along with this program. If not, see <http://www.gnu.org/licenses/>.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
26
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
27
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
28 // *****************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
29 // ** I N T R O D U C T I O N **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
30 // *****************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
31 //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
32 // OSTC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
33 //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
34 // code:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
35 // p2_deco_main_c_v101.c
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
36 // part2 of the OSTC code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
37 // code with constant O2 partial pressure routines
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
38 // under construction !!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
39 //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
40 // summary:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
41 // decompression routines
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
42 // for the OSTC experimental project
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
43 // written by Christian Weikamp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
44 // last revision __________
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
45 // comments added _________
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
46 //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
47 // additional files:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
48 // p2_tables_v100.romdata (other files)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
49 // 18f4685_ostc_v100.lkr (linker script)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
50 //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
51 // history:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
52 // 01/03/08 v100: first release candidate
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
53 // 03/13/08 v101: start of programming ppO2 code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
54 // 03/13/25 v101a: backup of interrim version with ppO2 calculation
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
55 // 03/13/25 v101: open circuit gas change during deco
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
56 // 03/13/25 v101: CNS_fraction calculation
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
57 // 03/13/26 v101: optimization of tissue calc routines
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
58 // 07/xx/08 v102a: debug of bottom time routine
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
59 // 09/xx/08 v102d: Gradient Factor Model implemenation
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
60 // 10/10/08 v104: renamed to build v103 for v118 stable
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
61 // 10/14/08 v104: integration of temp_depth_last_deco for Gradient Model
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
62 // 03/31/090 v107: integration of FONT Incon24
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
63
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
64 //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
65 // literature:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
66 // B"uhlmann, Albert: Tauchmedizin; 4. Auflage;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
67 // Schr"oder, Kai & Reith, Steffen; 2000; S"attigungsvorg"ange beim Tauchen, das Modell ZH-L16, Funktionsweise von Tauchcomputern; http://www.achim-und-kai.de/kai/tausim/saett_faq
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
68 // Morrison, Stuart; 2000; DIY DECOMPRESSION; http://www.lizardland.co.uk/DIYDeco.html
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
69 // Balthasar, Steffen; Dekompressionstheorie I: Neo Haldane Modelle; http://www.txfreak.de/dekompressionstheorie_1.pdf
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
70 // Baker, Erik C.; Clearing Up The Confusion About "Deep Stops"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
71 // Baker, Erik C.; Understanding M-values; http://www.txfreak.de/understanding_m-values.pdf
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
72
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
73
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
74 // *********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
75 // ** I N C L U D E S **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
76 // *********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
77 #include <p18f4685.h>
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
78 #include <math.h>
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
79
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
80 // ********************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
81 // ** C O N F I G U R A T I O N **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
82 // ** for simulation without asm **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
83 // ********************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
84 #pragma config OSC = IRCIO67
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
85 #pragma config FCMEN = OFF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
86 #pragma config IESO = OFF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
87 #pragma config PWRT = ON
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
88 #pragma config BOREN = OFF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
89 #pragma config WDT = OFF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
90 #pragma config WDTPS = 128
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
91 #pragma config MCLRE = ON
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
92 #pragma config LPT1OSC = OFF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
93 #pragma config PBADEN = OFF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
94 #pragma config DEBUG = OFF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
95 #pragma config XINST = OFF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
96 #pragma config LVP = OFF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
97 #pragma config STVREN = OFF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
98
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
99 // ****************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
100 // ** D E F I N E S **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
101 // ** missing in p18f4685.h **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
102 // ****************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
103 /*
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
104 #define INT0IF 1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
105 #define INT1IF 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
106 #define TMR1IF 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
107 */
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
109 # define DBG_c_gas 0b0000000000000001
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
110 # define DBG_c_ppO2 0b0000000000000010
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
111 # define DBG_RUN 0b0000000000000100
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
112 # define DBG_RESTART 0b0000000000001000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
113
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
114 # define DBG_CdeSAT 0b0000000000010000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
115 # define DBG_C_MODE 0b0000000000100000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
116 # define DBG_C_SURF 0b0000000001000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
117 # define DBG_HEwoHE 0b0000000010000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
118
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
119 # define DBG_C_DPPO2 0b0000000100000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
120 # define DBG_C_DGAS 0b0000001000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
121 # define DBG_C_DIST 0b0000010000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
122 # define DBG_C_LAST 0b0000100000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
123
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
124 # define DBG_C_GF 0b0001000000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
125 # define DBG_ZH16ERR 0b0010000000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
126 # define DBG_PHIGH 0b0100000000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
127 # define DBG_PLOW 0b1000000000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
128
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
129
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
130 # define DBS_mode 0b0000000000000001
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
131 # define DBS_ppO2 0b0000000000000010
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
132 # define DBS_HE_sat 0b0000000000000100
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
133 # define DBS_ppO2chg 0b0000000000001000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
134
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
135 # define DBS_SAT2l 0b0000000000010000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
136 # define DBS_SAT2h 0b0000000000100000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
137 # define DBS_GFLOW2l 0b0000000001000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
138 # define DBS_GFLOW2h 0b0000000010000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
139
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
140 # define DBS_GFHGH2l 0b0000000100000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
141 # define DBS_GFHGH2h 0b0000001000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
142 # define DBS_GASO22l 0b0000010000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
143 # define DBS_GASO22h 0b0000100000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
144
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
145 # define DBS_DIST2h 0b0001000000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
146 # define DBS_LAST2h 0b0010000000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
147 # define DBS_DECOO2l 0b0100000000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
148 # define DBS_DECOO2h 0b1000000000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
149
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
150
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
151 # define DBS2_PRES2h 0b0000000000000001
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
152 # define DBS2_PRES2l 0b0000000000000010
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
153 # define DBS2_SURF2l 0b0000000000000100
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
154 # define DBS2_SURF2h 0b0000000000001000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
155
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
156 # define DBS2_DESAT2l 0b0000000000010000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
157 # define DBS2_DESAT2h 0b0000000000100000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
158 # define DBS2_GFDneg 0b0000000001000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
159 # define DBS2_ 0b000000000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
160
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
161 # define DBS2_ 0b000000000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
162 # define DBS2_ 0b000000000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
163 # define DBS2_ 0b000000000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
164 # define DBS2_ 0b000000000000000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
165
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
166 // NDL_at_20mtr
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
167
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
168
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
169
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
170 // ***********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
171 // ** V A R I A B L E S **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
172 // ***********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
173 // prefixes etc:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
174 // _O_ = output for use in the assembler code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
175 // _I_ = input from the assembler code for the c code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
176 // char_ and int_ = used to identify output and input size
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
177 // var = variable (from b"uhlmann)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
178 // pres = pressure
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
179 // gtissue = guiding tissue, the one limiting the ascent
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
180 // e2secs = exp of the b"uhlmann formula precalculated for a 2 second step
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
181 // e1min = same for 1 minute step
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
182 // sim = used in simulating the ascent to the surface
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
183 // nullzeit = remaining ground/bottom time for "no deco"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
184 // hauptroutine = main
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
185
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
186 #define WP_FONT_SMALL_HEIGHT 24
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
187 #define WP_FONT_MEDIUM_HEIGHT 32
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
188 #define WP_FONT_LARGE_HEIGHT 58
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
189
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
190 #define oled_rw PORTA,2,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
191 #define oled_rs PORTE,0,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
192
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
193 #define U8 unsigned char
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
194 #define U16 unsigned int
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
195
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
196 // IO assembler
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
197 #pragma udata bank0a=0x060
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
198 volatile unsigned char wp_stringstore[26];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
199 volatile U8 wp_color1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
200 volatile U8 wp_color2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
201 volatile U8 wp_top;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
202 volatile U8 wp_leftx2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
203 volatile U8 wp_font;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
204 volatile U8 wp_invert;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
205 volatile U8 wp_temp_U8;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
206 // internal C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
207 #pragma udata bank0b=0x081
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
208 volatile U8 wp_txtptr;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
209 volatile unsigned char wp_char;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
210 volatile U8 wp_command;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
211 volatile U16 wp_data_16bit;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
212 volatile U8 wp_data_8bit_one;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
213 volatile U8 wp_data_8bit_two;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
214 volatile U16 wp_start;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
215 volatile U16 wp_end;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
216 volatile U16 wp_i;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
217 volatile U8 wp_black;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
218 // some spare
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
219 volatile U8 wp_debug_U8;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
220
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
221 // asm only
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
222 #pragma udata bank0c=0x0D0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
223 #define LENGTH_kf_bank0 48
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
224 volatile unsigned char keep_free_bank0[LENGTH_kf_bank0];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
225
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
226
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
227 #pragma udata bank1=0x100
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
228 #define LENGTH_kf_bank1 256
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
229 volatile unsigned char keep_free_bank1[LENGTH_kf_bank1]; // used by the assembler code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
230
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
231 #pragma udata bank2a=0x200
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
232 // output:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
233 static unsigned int int_O_tissue_for_debug[32];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
234 static unsigned int int_O_GF_spare____; // 0x240
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
235 static unsigned int int_O_GF_step; // 0x242
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
236 static unsigned int int_O_gtissue_limit; // 0x244
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
237 static unsigned int int_O_gtissue_press; // 0x246
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
238 static unsigned int int_O_limit_GF_low; // 0x248
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
239 static unsigned int int_O_gtissue_press_at_GF_low; // 0x24A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
240 // 0x24C + 0x24D noch unbenutzt
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
241
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
242 #pragma udata bank2b=0x24E
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
243 static unsigned char char_O_GF_low_pointer; // 0x24E
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
244 static unsigned char char_O_actual_pointer; // 0x24F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
245 #pragma udata bank2c=0x250
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
246 static unsigned char char_O_deco_table[32]; // 0x250
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
247 #pragma udata bank2d=0x270
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
248 static unsigned char char_I_table_deco_done[32];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
249 #pragma udata bank2e=0x290
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
250 static unsigned int int_O_calc_tissue_call_counter; // 0x290
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
251 // internal:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
252 unsigned char lock_GF_depth_list;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
253 static float temp_limit;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
254 static float GF_low;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
255 static float GF_high;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
256 static float GF_delta;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
257 static float GF_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
258 static float GF_step;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
259 static float GF_step2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
260 static float temp_pres_gtissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
261 static float temp_pres_gtissue_diff;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
262 static float temp_pres_gtissue_limit_GF_low;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
263 static float temp_pres_gtissue_limit_GF_low_below_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
264 static unsigned int temp_depth_limit;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
265 static unsigned char temp_decotime;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
266 static unsigned char temp_gtissue_no;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
267 static unsigned int temp_depth_last_deco; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
268
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
269 static unsigned char temp_depth_GF_low_meter;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
270 static unsigned char temp_depth_GF_low_number;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
271 static unsigned char internal_deco_pointer;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
272 static unsigned char internal_deco_table[32];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
273 static float temp_pres_deco_GF_low;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
274
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
275 static unsigned int debug_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
276
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
277
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
278 #pragma udata bank3a=0x300
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
279 static char output[32];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
280 // used by the math routines
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
281 #pragma udata bank3b=0x380
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
282 volatile float pres_tissue_vault[32];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
283 #pragma udata bank4a=0x400
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
284 // internal:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
285 unsigned char ci ; // don't move - used in _asm routines - if moved then modify movlb commands
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
286 unsigned char x;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
287 unsigned int main_i;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
288 unsigned int int_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
289 unsigned int int_temp_decostatus;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
290 static float pres_respiration;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
291 static float pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
292 static float temp1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
293 static float temp2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
294 static float temp3;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
295 static float temp4;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
296 static float temp_deco;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
297 static float temp_atem;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
298 static float temp2_atem;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
299 static float temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
300 static float temp_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
301 static float N2_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
302 static float He_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
303 static float temp_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
304 static float var_a;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
305 static float var2_a;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
306 static float var_b;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
307 static float var2_b;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
308 static float var_t05nc;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
309 static float var2_t05nc;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
310 static float var_e2secs;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
311 static float var2_e2secs;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
312 static float var_e1min;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
313 static float var2_e1min;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
314 static float var_halftimes;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
315 static float var2_halftimes;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
316 static float pres_gtissue_limit;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
317 static float temp_pres_gtissue_limit;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
318 static float actual_ppO2; // new in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
319 #pragma udata bank4b=0x480
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
320 static float pres_tissue[32];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
321
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
322 #pragma udata bank5=0x500
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
323 // don't move positions in this bank, the registers are addressed directly from assembler code
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
324 // input:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
325 static unsigned int int_I_pres_respiration; // 0x500
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
326 static unsigned int int_I_pres_surface; // 0x502
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
327 static unsigned int int_I_temp; // 0x504 new in v101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
328 static unsigned char char_I_temp; // 0x506 new in v101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
329 static unsigned char char_I_actual_ppO2; // 0x507
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
330 static unsigned int int_I_spare_3;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
331 static unsigned int int_I_spare_4;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
332 static unsigned int int_I_spare_5;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
333 static unsigned int int_I_spare_6;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
334 static unsigned char char_I_N2_ratio; // 0x510
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
335 static unsigned char char_I_He_ratio; // 0x511
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
336 static unsigned char char_I_saturation_multiplier; // for conservatism/safety values 1.0 (no conservatism) to 1.5 (50% faster saturation
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
337 static unsigned char char_I_desaturation_multiplier; // for conservatism/safety values 0.66 (50% slower desaturation) to 1.0 (no conservatism)// consveratism used in calc_tissue(), calc_tissue_step_1_min() and sim_tissue_1min()
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
338 static unsigned char char_I_GF_High_percentage; // 0x514 new in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
339 static unsigned char char_I_GF_Low_percentage; // 0x515 new in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
340 static unsigned char char_I_spare; // 0x516
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
341 static unsigned char char_I_deco_distance; // 0x517
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
342 static unsigned char char_I_const_ppO2; // 0x518 new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
343 static unsigned char char_I_deco_ppO2_change; // 0x519 new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
344 static unsigned char char_I_deco_ppO2; // 0x51A new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
345 static unsigned char char_I_deco_gas_change; // 0x51B new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
346 static unsigned char char_I_deco_N2_ratio; // 0x51C new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
347 static unsigned char char_I_deco_He_ratio; // 0x51D new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
348 static unsigned char char_I_depth_last_deco; // 0x51E new in v.101 unit: [m]
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
349 static unsigned char char_I_deco_model; // 0x51F new in v.102 ( 1 = MultiGraF, sonst Std. mit (de-)saturation_multiplier)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
350 // output:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
351 static unsigned int int_O_desaturation_time; // 0x520
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
352 static unsigned char char_O_nullzeit; // 0x522
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
353 static unsigned char char_O_deco_status; // 0x523
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
354 static unsigned char char_O_array_decotime[7]; // 0x524
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
355 static unsigned char char_O_array_decodepth[6]; // 0x52B
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
356 static unsigned char char_O_ascenttime; // 0x531
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
357 static unsigned char char_O_gradient_factor; // 0x532
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
358 static unsigned char char_O_tissue_saturation[32]; // 0x533
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
359 static unsigned char char_O_array_gradient_weighted[16]; // 0x553
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
360 static unsigned char char_O_gtissue_no; // 0x563
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
361 static unsigned char char_O_diluent; // 0x564 new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
362 static unsigned char char_O_CNS_fraction; // 0x565 new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
363 static unsigned char char_O_relative_gradient_GF; // 0x566 new in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
364
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
365 // internal:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
366 static float pres_tissue_limit[16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
367 static float sim_pres_tissue_limit[16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
368 static float pres_diluent; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
369 static float deco_diluent; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
370 static float const_ppO2; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
371 static float deco_ppO2_change; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
372 static float deco_ppO2; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
373
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
374
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
375
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
376 #pragma udata bank6=0x600
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
377 // internal:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
378 static float sim_pres_tissue[32];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
379 static float sim_pres_tissue_backup[32];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
380
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
381 //#pragma udata bank7=0x700
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
382 //const unsigned char keep_free_bank7[256]; // used by the assembler code (DD font2display)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
383
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
384 #pragma udata bank8=0x800
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
385 static char md_pi_subst[256];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
386
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
387 #pragma udata bank9a=0x900
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
388 // output:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
389 static char md_state[48]; // DONT MOVE !! // has to be at the beginning of bank 9 for the asm code!!!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
390 #pragma udata bank9b=0x930
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
391 // output:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
392 static unsigned int int_O_DBS_bitfield; // 0x930 new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
393 static unsigned int int_O_DBS2_bitfield; // 0x932 new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
394 static unsigned int int_O_DBG_pre_bitfield; // 0x934 new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
395 static unsigned int int_O_DBG_post_bitfield; // 0x936 new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
396 static char char_O_NDL_at_20mtr; // 0x938 new in v.108 // 0xFF == undefined, max. 254
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
397 // internal:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
398 static char md_t;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
399 static char md_buffer[16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
400 static char md_cksum[16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
401 static char md_i;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
402 static char md_j;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
403 static char md_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
404 static unsigned int md_pointer;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
405 static float deco_N2_ratio; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
406 static float deco_He_ratio; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
407 static float calc_N2_ratio; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
408 static float calc_He_ratio; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
409 static float deco_gas_change; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
410 static float CNS_fraction; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
411 static float float_saturation_multiplier; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
412 static float float_desaturation_multiplier; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
413 static float float_deco_distance; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
414 // internal, dbg:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
415 static unsigned char DBG_char_I_deco_model; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
416 static unsigned char DBG_char_I_depth_last_deco; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
417 static float DBG_pres_surface; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
418 static float DBG_GF_low; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
419 static float DBG_GF_high; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
420 static float DBG_const_ppO2; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
421 static float DBG_deco_ppO2_change; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
422 static float DBG_deco_ppO2; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
423 static float DBG_deco_N2_ratio; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
424 static float DBG_deco_He_ratio; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
425 static float DBG_deco_gas_change; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
426 static float DBG_float_saturation_multiplier; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
427 static float DBG_float_desaturation_multiplier; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
428 static float DBG_float_deco_distance; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
429 static float DBG_deco_N2_ratio; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
430 static float DBG_deco_He_ratio; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
431 static float DBG_N2_ratio; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
432 static float DBG_He_ratio; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
433 static char flag_in_divemode; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
434 static int int_dbg_i; // new in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
435 unsigned int temp_DBS;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
436
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
437 // *************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
438 // ** P R O T O T Y P E S **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
439 // *************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
440 void main_calc_hauptroutine(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
441 void main_calc_without_deco(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
442 void main_clear_tissue(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
443 void main_calc_percentage(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
444 void main_calc_wo_deco_step_1_min(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
445 void main_debug(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
446 void main_gradient_array(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
447 void main_hash(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
448
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
449 void calc_hauptroutine(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
450 void calc_tissue(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
451 void calc_nullzeit(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
452 void backup_sim_pres_tissue(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
453 void restore_sim_pres_tissue(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
454
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
455 void calc_without_deco(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
456 void clear_tissue(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
457 void calc_ascenttime(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
458 void update_startvalues(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
459 void clear_decoarray(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
460 void update_decoarray(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
461 void sim_tissue_1min(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
462 void sim_tissue_10min(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
463 void calc_gradient_factor(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
464 void calc_gradient_array_only(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
465 void calc_desaturation_time(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
466 void calc_wo_deco_step_1_min(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
467 void calc_tissue_step_1_min(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
468 void hash(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
469 void clear_CNS_fraction(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
470 void calc_CNS_fraction(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
471 void calc_CNS_decrease_15min(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
472 void calc_percentage(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
473 void main(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
474 void calc_hauptroutine_data_input(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
475 void calc_hauptroutine_update_tissues(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
476 void calc_hauptroutine_calc_deco(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
477 void calc_hauptroutine_calc_ascend_to_deco(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
478 void calc_nextdecodepth_GF(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
479 void copy_deco_table_GF(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
480 void clear_internal_deco_table_GF(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
481 void update_internal_deco_table_GF(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
482 void DD2_write(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
483 void DD2_write_incon42(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
484 void DD2_get_pointer_to_char(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
485 void DD2_set_column(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
486 void DD2_load_background(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
487 void DD2_build_one_line_of_char(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
488 void DD2_print_column(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
489 void DD2_CmdWrite(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
490 void DD2_DataWrite(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
491 void push_tissues_to_vault(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
492 void pull_tissues_from_vault(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
493 void main_push_tissues_to_vault(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
494 void main_pull_tissues_from_vault(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
495 void wordprocessor(void);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
496
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
497 // *******************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
498 // ** start **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
499 // ** necessary for compilation **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
500 // *******************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
501 #pragma romdata der_code = 0x0000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
502 #pragma code der_start = 0x0000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
503 void der_start(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
504 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
505 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
506 goto main
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
507 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
508 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
509
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
510 // ***********************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
511 // ** main code for simulation / **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
512 // ** tests without assembler code **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
513 // ** is NOT a part of the OSTC **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
514 // ***********************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
515 #pragma code main = 0x9000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
516 void main(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
517 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
518 for(wp_temp_U8=0;wp_temp_U8<LENGTH_kf_bank0 - 1;wp_temp_U8++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
519 keep_free_bank0[wp_temp_U8] = 7;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
520 keep_free_bank0[LENGTH_kf_bank0 - 1] = 7;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
521
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
522 for(wp_temp_U8=0;wp_temp_U8<LENGTH_kf_bank1 - 1;wp_temp_U8++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
523 keep_free_bank1[wp_temp_U8] = 7;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
524 keep_free_bank1[LENGTH_kf_bank1 - 1] = 7;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
525
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
526 #if 1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
527 // new main to test DR-5
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
528
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
529 wp_top = 10;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
530 wp_leftx2 = 10;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
531 wp_color1 = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
532 wp_color2 = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
533 wp_font = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
534 wp_invert = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
535 wp_stringstore[0] = ' ';
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
536 wp_stringstore[1] = ' ';
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
537 wp_stringstore[2] = '1';
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
538 wp_stringstore[3] = ':';
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
539 wp_stringstore[4] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
540 wordprocessor();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
541
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
542 GF_low = 1.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
543 GF_high = 1.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
544
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
545 GF_temp = GF_low * GF_high;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
546
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
547 clear_CNS_fraction();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
548 //char_I_const_ppO2 = 100;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
549 //for (main_i=0;main_i<255;main_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
550 //{
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
551 //calc_CNS_fraction();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
552 //} //for
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
553
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
554
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
555
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
556
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
557 int_I_pres_respiration = 1000;//980;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
558 int_I_pres_surface = 1000;//980;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
559 char_I_N2_ratio = 39; //38;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
560 char_I_He_ratio = 40; //50;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
561 char_I_deco_distance = 0; // 10 = 1 meter
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
562 char_I_depth_last_deco = 3; // values below 3 (meter) are ignored
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
563
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
564 char_I_const_ppO2 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
565 char_I_deco_ppO2_change = 0; // [dm] 10 = 1 meter
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
566 char_I_deco_ppO2 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
567
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
568 char_I_deco_gas_change = 0; // [m] 1 = 1 meter
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
569 char_I_deco_N2_ratio = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
570 char_I_deco_He_ratio = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
571
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
572 //char_I_actual_ppO2; // 0x507
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
573 char_I_GF_High_percentage = 100; // 0x514 new in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
574 char_I_GF_Low_percentage = 100; // 0x515 new in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
575
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
576 char_I_saturation_multiplier = 110;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
577 char_I_desaturation_multiplier = 90;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
578
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
579 char_I_deco_model = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
580
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
581 main_clear_tissue();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
582
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
583 int_I_pres_respiration = 1000 + int_I_pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
584 main_calc_wo_deco_step_1_min();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
585 int_I_pres_respiration = 3000 + int_I_pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
586 main_calc_wo_deco_step_1_min();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
587 int_I_pres_respiration = 5000 + int_I_pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
588 main_calc_wo_deco_step_1_min();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
589
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
590 /*
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
591 int_I_pres_respiration = 6000 + int_I_pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
592 for (main_i=0;main_i<27;main_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
593 main_calc_wo_deco_step_1_min();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
594 */
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
595
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
596 char_O_deco_status = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
597 while (char_O_deco_status)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
598 main_calc_hauptroutine();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
599 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
600 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
601 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
602
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
603 for (main_i=0;main_i<50;main_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
604 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
605 main_calc_hauptroutine();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
606 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
607 int_I_pres_respiration = 10000;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
608 for (main_i=0;main_i<1500;main_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
609 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
610 main_calc_hauptroutine();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
611 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
612
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
613 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
614 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
615 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
616
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
617
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
618 int_I_pres_respiration = 3000;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
619 for (main_i=0;main_i<150;main_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
620 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
621 calc_hauptroutine_data_input();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
622 calc_hauptroutine_update_tissues();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
623 } //for
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
624
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
625 update_startvalues();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
626 clear_decoarray();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
627 clear_internal_deco_table_GF();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
628 calc_hauptroutine_calc_ascend_to_deco();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
629 if (char_O_deco_status > 15) // can't go up to first deco, too deep to calculate in the given time slot
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
630 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
631 char_O_deco_status = 2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
632 // char_O_lock_depth_list = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
633 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
634 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
635 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
636 // char_O_lock_depth_list = lock_GF_depth_list;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
637 calc_hauptroutine_calc_deco();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
638 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
639 // build_debug_output();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
640
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
641 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
642 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
643 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
644 while (char_O_deco_status == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
645 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
646 char_O_deco_status = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
647 // char_O_lock_depth_list = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
648 calc_hauptroutine_calc_deco();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
649 // build_debug_output();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
650 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
651 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
652 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
653 };
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
654 debug_temp = 60; // [mtr Aufstieg in 10 mtr/min (30steps'2sec/min]
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
655 int_I_pres_respiration = 9980;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
656 for (main_i=0;main_i<debug_temp;main_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
657 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
658 int_I_pres_respiration = int_I_pres_respiration - 33;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
659 calc_hauptroutine_data_input();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
660 calc_hauptroutine_update_tissues();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
661 int_I_pres_respiration = int_I_pres_respiration - 33;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
662 calc_hauptroutine_data_input();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
663 calc_hauptroutine_update_tissues();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
664 int_I_pres_respiration = int_I_pres_respiration - 34;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
665 calc_hauptroutine_data_input();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
666 calc_hauptroutine_update_tissues();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
667 } //for
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
668 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
669 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
670 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
671
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
672 update_startvalues();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
673 clear_decoarray();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
674 clear_internal_deco_table_GF();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
675 calc_hauptroutine_calc_ascend_to_deco();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
676 if (char_O_deco_status > 15) // can't go up to first deco, too deep to calculate in the given time slot
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
677 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
678 char_O_deco_status = 2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
679 // char_O_lock_depth_list = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
680 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
681 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
682 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
683 // char_O_lock_depth_list = lock_GF_depth_list;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
684 calc_hauptroutine_calc_deco();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
685 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
686 // build_debug_output();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
687
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
688 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
689 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
690 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
691 while (char_O_deco_status == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
692 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
693 char_O_deco_status = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
694 // char_O_lock_depth_list = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
695 calc_hauptroutine_calc_deco();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
696 // build_debug_output();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
697 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
698 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
699 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
700 };
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
701 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
702 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
703 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
704 debug_temp = 60; // [mtr Aufstieg in 10 mtr/min (30steps'2sec/min]
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
705 int_I_pres_respiration = 9980;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
706 debug_temp = debug_temp * 3;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
707 for (main_i=0;main_i<debug_temp;main_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
708 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
709 calc_hauptroutine_data_input();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
710 calc_hauptroutine_update_tissues();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
711 } //for
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
712 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
713 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
714 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
715 #endif
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
716 // -----------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
717
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
718 } // main
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
719
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
720 // ******************************************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
721 // ******************************************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
722 // ** THE FOLLOWING CODE HAS TO BE COPPIED TO THE OSTC **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
723 // ******************************************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
724 // ******************************************************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
725
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
726 // ***************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
727 // ***************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
728 // ** THE FONTS **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
729 // ***************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
730 // ***************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
731 // all new for bigscreen
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
732
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
733 #pragma romdata font_data_large = 0x09A00
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
734 rom const rom U16 wp_large_data[] =
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
735 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
736 #include "ostc90.drx.txt" // length 0x59A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
737 };
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
738
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
739 #pragma romdata font_table_large = 0x09FA0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
740 rom const rom U16 wp_large_table[] =
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
741 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
742 #include "ostc90.tbl.txt" // length 0x18
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
743 };
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
744
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
745 #pragma romdata font_table_medium = 0x0A000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
746 rom const rom U16 wp_medium_table[] =
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
747 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
748 #include "ostc48.tbl.txt" // length 0x22
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
749 };
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
750
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
751 #pragma romdata font_data_medium = 0x0A024
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
752 rom const rom U16 wp_medium_data[] =
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
753 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
754 #include "ostc48.drx.txt" // length 0x374 // geht bis einschl. 0xA398
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
755 };
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
756
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
757 #pragma romdata font_table_small = 0x0A39A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
758 rom const rom U16 wp_small_table[] =
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
759 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
760 #include "ostc28.tbl.txt" // length 0xE8
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
761 };
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
762
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
763 #pragma romdata font_data_small = 0x0A484
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
764 rom const rom U16 wp_small_data[] =
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
765 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
766 #include "ostc28.drx.txt"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
767 };
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
768
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
769
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
770 // ***********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
771 // ***********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
772 // ** THE SUBROUTINES 2 **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
773 // ***********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
774 // ***********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
775 // all new in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
776 // moved from 0x0D000 to 0x0C000 in v.108
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
777
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
778 #pragma code subroutines2 = 0x0C000 // can be adapted to fit the romdata tables ahead
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
779
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
780 // -------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
781 // DBS - debug on start of dive //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
782 // -------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
783 void create_dbs_set_dbg_and_ndl20mtr(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
784 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
785 int_O_DBS_bitfield = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
786 int_O_DBS2_bitfield = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
787 if(int_O_DBG_pre_bitfield & DBG_RUN)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
788 int_O_DBG_pre_bitfield = DBG_RESTART;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
789 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
790 int_O_DBG_pre_bitfield = DBG_RUN;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
791 int_O_DBG_post_bitfield = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
792 char_O_NDL_at_20mtr = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
793
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
794 DBG_N2_ratio = N2_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
795 DBG_He_ratio = He_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
796 DBG_char_I_deco_model = char_I_deco_model;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
797 DBG_char_I_depth_last_deco = char_I_depth_last_deco;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
798 DBG_pres_surface = pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
799 DBG_GF_low = GF_low;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
800 DBG_GF_high = GF_high;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
801 DBG_const_ppO2 = const_ppO2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
802 DBG_deco_ppO2_change = deco_ppO2_change;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
803 DBG_deco_ppO2 = deco_ppO2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
804 DBG_deco_N2_ratio = deco_N2_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
805 DBG_deco_He_ratio = deco_He_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
806 DBG_deco_gas_change = deco_gas_change;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
807 DBG_float_saturation_multiplier = float_saturation_multiplier;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
808 DBG_float_desaturation_multiplier = float_desaturation_multiplier;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
809 DBG_float_deco_distance = float_deco_distance;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
810
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
811 if(char_I_deco_model)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
812 int_O_DBS_bitfield |= DBS_mode;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
813 if(const_ppO2)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
814 int_O_DBS_bitfield |= DBS_ppO2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
815 for(int_dbg_i = 16; int_dbg_i < 32; int_dbg_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
816 if(pres_tissue[int_dbg_i])
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
817 int_O_DBS_bitfield |= DBS_HE_sat;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
818 if(deco_ppO2_change)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
819 int_O_DBS_bitfield |= DBS_ppO2chg;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
820 if(float_saturation_multiplier < 0.99)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
821 int_O_DBS_bitfield |= DBS_SAT2l;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
822 if(float_saturation_multiplier > 1.3)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
823 int_O_DBS_bitfield |= DBS_SAT2h;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
824 if(GF_low < 0.19)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
825 int_O_DBS_bitfield |= DBS_GFLOW2l;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
826 if(GF_low > 1.01)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
827 int_O_DBS_bitfield |= DBS_GFLOW2h;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
828 if(GF_high < 0.6)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
829 int_O_DBS_bitfield |= DBS_GFHGH2l;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
830 if(GF_high > 1.01)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
831 int_O_DBS_bitfield |= DBS_GFHGH2h;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
832 if((N2_ratio + He_ratio) > 0.95)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
833 int_O_DBS_bitfield |= DBS_GASO22l;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
834 if((N2_ratio + He_ratio) < 0.05)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
835 int_O_DBS_bitfield |= DBS_GASO22h;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
836 if(float_deco_distance > 0.25)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
837 int_O_DBS_bitfield |= DBS_DIST2h;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
838 if(char_I_depth_last_deco > 8)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
839 int_O_DBS_bitfield |= DBS_LAST2h;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
840 if(DBG_deco_gas_change && ((deco_N2_ratio + deco_He_ratio) > 0.95))
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
841 int_O_DBS_bitfield |= DBS_DECOO2l;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
842 if(DBG_deco_gas_change && ((deco_N2_ratio + deco_He_ratio) < 0.05))
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
843 int_O_DBS_bitfield |= DBS_DECOO2h;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
844 if(pres_respiration > 3.0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
845 int_O_DBS2_bitfield |= DBS2_PRES2h;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
846 if(pres_surface - pres_respiration > 0.2)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
847 int_O_DBS2_bitfield |= DBS2_PRES2l;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
848 if(pres_surface < 0.75)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
849 int_O_DBS2_bitfield |= DBS2_SURF2l;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
850 if(pres_surface > 1.11)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
851 int_O_DBS2_bitfield |= DBS2_SURF2h;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
852 if(float_desaturation_multiplier < 0.70)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
853 int_O_DBS2_bitfield |= DBS2_DESAT2l;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
854 if(float_desaturation_multiplier > 1.01)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
855 int_O_DBS2_bitfield |= DBS2_DESAT2h;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
856 if(GF_low > GF_high)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
857 int_O_DBS2_bitfield |= DBS2_GFDneg;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
858 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
859
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
860 // -------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
861 // DBG - set DBG to end_of_dive //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
862 // -------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
863 void set_dbg_end_of_dive(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
864 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
865 int_O_DBG_pre_bitfield &= (~DBG_RUN);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
866 int_O_DBG_post_bitfield &= (~DBG_RUN);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
867 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
868
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
869 // -------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
870 // DBG - NDL at first 20 m. hit //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
871 // -------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
872 void check_ndl(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
873 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
874 if((char_O_NDL_at_20mtr == -1) && (int_I_pres_respiration > 3000))
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
875 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
876 char_O_NDL_at_20mtr = char_O_nullzeit;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
877 if(char_O_NDL_at_20mtr == 255)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
878 char_O_NDL_at_20mtr == 254;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
879 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
880 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
881
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
882 // -------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
883 // DBG - multi main during dive //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
884 // -------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
885 void check_dbg(char is_post_check)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
886 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
887 temp_DBS = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
888 if( (DBG_N2_ratio != N2_ratio) || (DBG_He_ratio != He_ratio) )
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
889 temp_DBS |= DBG_c_gas;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
890 if(DBG_const_ppO2 != const_ppO2)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
891 temp_DBS |= DBG_c_ppO2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
892 if((DBG_float_saturation_multiplier != float_saturation_multiplier) || (DBG_float_desaturation_multiplier != float_desaturation_multiplier))
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
893 temp_DBS |= DBG_CdeSAT;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
894 if(DBG_char_I_deco_model != char_I_deco_model)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
895 temp_DBS |= DBG_C_MODE;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
896 if(DBG_pres_surface != pres_surface)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
897 temp_DBS |= DBG_C_SURF;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
898 if((!DBS_HE_sat) && (!He_ratio))
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
899 for(int_dbg_i = 16; int_dbg_i < 32; int_dbg_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
900 if(pres_tissue[int_dbg_i])
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
901 temp_DBS |= DBG_HEwoHE;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
902 if(DBG_deco_ppO2 != deco_ppO2)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
903 temp_DBS |= DBG_C_DPPO2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
904 if((DBG_deco_gas_change != deco_gas_change) || (DBG_deco_N2_ratio != deco_N2_ratio) || (DBG_deco_He_ratio != deco_He_ratio))
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
905 temp_DBS |= DBG_C_DGAS;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
906 if(DBG_float_deco_distance != float_deco_distance)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
907 temp_DBS |= DBG_C_DIST;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
908 if(DBG_char_I_depth_last_deco != char_I_depth_last_deco)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
909 temp_DBS |= DBG_C_LAST;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
910 if((DBG_GF_low != GF_low) || (DBG_GF_high != GF_high))
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
911 temp_DBS |= DBG_C_GF;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
912 if(pres_respiration > 13.0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
913 temp_DBS |= DBG_PHIGH;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
914 if(pres_surface - pres_respiration > 0.2)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
915 temp_DBS |= DBG_PLOW;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
916 /*
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
917 if()
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
918 temp_DBS |= ;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
919 if()
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
920 temp_DBS |= ;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
921 */
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
922 if(is_post_check)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
923 int_O_DBG_post_bitfield |= temp_DBS;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
924 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
925 int_O_DBG_pre_bitfield |= temp_DBS;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
926 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
927
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
928 // -------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
929 // DBG - prior to calc. of dive //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
930 // -------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
931 void check_pre_dbg(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
932 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
933 check_dbg(0);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
934 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
935
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
936 // -------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
937 // DBG - after decocalc of dive //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
938 // -------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
939 void check_post_dbg(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
940 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
941 check_dbg(1);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
942 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
943
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
944
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
945
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
946 // -------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
947 // calc_next_decodepth_GF //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
948 // -------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
949 // new in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
950 void calc_nextdecodepth_GF(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
951 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
952 // INPUT, changing during dive:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
953 // temp_pres_gtissue_limit_GF_low
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
954 // temp_pres_gtissue_limit_GF_low_below_surface
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
955 // temp_pres_gtissue
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
956 // temp_pres_gtissue_diff
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
957 // lock_GF_depth_list
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
958
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
959 // INPUT, fixed during dive:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
960 // pres_surface
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
961 // GF_delta
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
962 // GF_high
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
963 // GF_low
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
964 // temp_depth_last_deco
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
965 // float_deco_distance
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
966
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
967 // OUTPUT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
968 // GF_step
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
969 // temp_deco
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
970 // temp_depth_limt
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
971 // lock_GF_depth_list
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
972
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
973 // USES
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
974 // temp1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
975 // temp2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
976 // int_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
977
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
978 char_I_table_deco_done[0] = 0; // safety if changed somewhere else. Needed for exit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
979 if (char_I_deco_model == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
980 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
981 if (lock_GF_depth_list == 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
982 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
983 temp2 = temp_pres_gtissue_limit_GF_low_below_surface / 0.29985; // = ... / 99.95 / 0.003;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
984 int_temp = (int) (temp2 + 0.99);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
985 if (int_temp > 31)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
986 int_temp = 31; // deepest deco at 93 meter (31 deco stops)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
987 if (int_temp < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
988 int_temp = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
989 temp_depth_GF_low_number = int_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
990 temp_depth_GF_low_meter = 3 * temp_depth_GF_low_number;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
991 temp2 = (float)temp_depth_GF_low_meter * 0.09995;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
992 temp_pres_deco_GF_low = temp2 + float_deco_distance + pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
993 if (temp_depth_GF_low_number == 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
994 GF_step = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
995 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
996 GF_step = GF_delta / (float)temp_depth_GF_low_number;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
997 if (GF_step < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
998 GF_step = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
999 if (GF_step > GF_delta)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1000 GF_step = GF_delta;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1001 int_O_GF_step = (int)(GF_step * 10000);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1002 int_O_limit_GF_low = (int)(temp_pres_deco_GF_low * 1000);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1003 int_O_gtissue_press_at_GF_low = (int)(temp_pres_gtissue * 1000);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1004 char_O_GF_low_pointer = temp_depth_GF_low_number;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1005 lock_GF_depth_list = 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1006 internal_deco_pointer = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1007 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1008 if (internal_deco_pointer == 0) // new run
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1009 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1010 internal_deco_pointer = temp_depth_GF_low_number;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1011 GF_temp = GF_high - ((float)internal_deco_pointer * GF_step);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1012 int_temp = char_I_table_deco_done[internal_deco_pointer];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1013 output[8] = int_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1014 output[9] = 33;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1015 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1016 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1017 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1018 int_temp = 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1019 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1020 while (int_temp == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1021 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1022 int_temp = internal_deco_pointer - 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1023 if (int_temp == 1) // new in v104
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1024 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1025 temp2 = (float)(temp_depth_last_deco * int_temp) * 0.09995;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1026 GF_step2 = GF_step/3.0 * ((float)(6 - temp_depth_last_deco));
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1027 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1028 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1029 if (int_temp == 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1030 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1031 temp2 = 0.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1032 GF_step2 = GF_high - GF_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1033 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1034 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1035 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1036 temp2 = (float)(3 *int_temp) * 0.09995;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1037 GF_step2 = GF_step;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1038 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1039 temp2 = temp2 + pres_surface; // next deco stop to be tested
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1040 temp1 = ((GF_temp + GF_step2)* temp_pres_gtissue_diff) + temp_pres_gtissue; // upper limit (lowest pressure allowed) // changes GF_step2 in v104
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1041 if (temp1 > temp2) // check if ascent to next deco stop is ok
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1042 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1043 int_temp = 0; // no
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1044 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1045 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1046 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1047 internal_deco_pointer = int_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1048 GF_temp = GF_temp + GF_step2; // changed in v104
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1049 int_temp = char_I_table_deco_done[internal_deco_pointer]; // yes and check for ascent to even next stop if deco_done is set
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1050 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1051 } // while
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1052 if (internal_deco_pointer > 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1053 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1054 temp2 = (float)(0.29985 * internal_deco_pointer);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1055 temp_deco = temp2 + float_deco_distance + pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1056 if (internal_deco_pointer == 1) // new in v104
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1057 temp_depth_limit = temp_depth_last_deco;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1058 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1059 temp_depth_limit = 3 * internal_deco_pointer;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1060 if (output[9] == 33)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1061 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1062 output[9] = internal_deco_pointer;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1063 output[10] = char_I_table_deco_done[internal_deco_pointer];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1064 output[12] = output[12] + 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1065 if (output[12] == 100)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1066 output[12] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1067 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1068 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1069 else // if (char_I_deco_model == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1070 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1071 temp_deco = pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1072 temp_depth_limit = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1073 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1074 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1075 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1076 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1077 // calc_nextdecodepth - original
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1078 // optimized in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1079 // depth_last_deco included in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1080
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1081 temp1 = temp_pres_gtissue_limit - pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1082 if (temp1 >= 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1083 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1084 temp1 = temp1 / 0.29985; // = temp1 / 99.95 / 0.003;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1085 temp_depth_limit = (int) (temp1 + 0.99);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1086 temp_depth_limit = 3 * temp_depth_limit; // depth for deco [m]
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1087 if (temp_depth_limit == 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1088 temp_deco = pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1089 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1090 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1091 if (temp_depth_limit < temp_depth_last_deco)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1092 temp_depth_limit = temp_depth_last_deco;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1093 temp1 = (float)temp_depth_limit * 0.09995;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1094 temp_deco = temp1 + float_deco_distance + pres_surface; // depth for deco [bar]
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1095 } // if (temp_depth_limit == 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1096 } // if (temp1 >= 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1097 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1098 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1099 temp_deco = pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1100 temp_depth_limit = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1101 } // if (temp1 >= 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1102 } // calc_nextdecodepth original
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1103 } // calc_nextdecodepth_GF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1104
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1105
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1106 #if 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1107 void build_debug_output(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1108 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1109 output[0] = 0; // not used in asm PLED output
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1110 output[1] = (int) (GF_low * 100);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1111 output[2] = (int) (GF_high * 100);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1112 output[3] = (int) (GF_step * 100);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1113 output[4] = (int) temp_depth_GF_low_number;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1114 output[5] = (int) temp_depth_GF_low_meter;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1115 //output[6]
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1116 output[7] = (int) internal_deco_pointer;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1117 //output[8] = char_I_table_deco_done[temp_depth_GF_low_number]
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1118 //output[9] = internal_deco_pointer @ new run
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1119 //output[10] = char_I_table_deco_done[internal_deco_pointer] @ new run
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1120 output [11] = (int) (temp_pres_deco_GF_low * 10);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1121 } // build_debug_output
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1122 #endif
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1123
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1124 // ---------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1125 // copy_deco_table_GF //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1126 // ---------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1127 // new in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1128 void copy_deco_table_GF(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1129 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1130 if (char_I_deco_model == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1131 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1132 int_temp = 32;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1133 for (ci=0;ci<int_temp;ci++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1134 char_O_deco_table[ci] = internal_deco_table[ci];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1135 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1136 } // copy_deco_table_GF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1137
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1138
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1139 // ------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1140 // clear_internal_deco_table_GF//
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1141 // ------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1142 // new in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1143 void clear_internal_deco_table_GF(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1144 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1145 if (char_I_deco_model == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1146 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1147 for (ci=0;ci<32;ci++) // cycle through the 16 b"uhlmann tissues for Helium
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1148 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1149 internal_deco_table[ci] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1150 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1151 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1152 } // clear_internal_deco_table_GF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1153
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1154
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1155 // --------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1156 // update_internal_deco_table_GF //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1157 // --------------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1158 // new in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1159 void update_internal_deco_table_GF(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1160 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1161 if ((char_I_deco_model == 1) && (internal_deco_table[internal_deco_pointer] < 255))
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1162 internal_deco_table[internal_deco_pointer] = internal_deco_table[internal_deco_pointer] + 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1163 } // update_internal_deco_table_GF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1164
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1165
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1166 // ---------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1167 // temp_tissue_safety //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1168 // ---------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1169 // outsourced in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1170 void temp_tissue_safety(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1171 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1172 if (char_I_deco_model == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1173 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1174 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1175 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1176 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1177 if (temp_tissue < 0.0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1178 temp_tissue = temp_tissue * float_desaturation_multiplier;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1179 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1180 temp_tissue = temp_tissue * float_saturation_multiplier;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1181 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1182 } // temp_tissue_safety
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1183
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1184 // -----------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1185 // dd2 OLD //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1186 // -----------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1187 void DD2_write(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1188 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1189 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1190 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1191 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1192 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1193 void DD2_write_incon42(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1194 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1195 DD2_write();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1196 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1197
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1198 void DD2_write_incon24(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1199 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1200 DD2_write();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1201 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1202 void DD2_get_pointer_to_char(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1203 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1204 DD2_write();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1205 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1206 void DD2_set_column(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1207 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1208 DD2_write();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1209 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1210 void DD2_load_background(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1211 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1212 DD2_write();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1213 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1214 void DD2_build_one_line_of_char(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1215 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1216 DD2_write();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1217 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1218 void DD2_print_column(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1219 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1220 DD2_write();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1221 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1222 void DD2_CmdWrite(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1223 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1224 DD2_write();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1225 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1226 void DD2_DataWrite(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1227 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1228 DD2_write();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1229 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1230
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1231 // **********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1232 // **********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1233 // ** THE JUMP-IN CODE **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1234 // ** for the asm code **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1235 // **********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1236 // **********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1237 #pragma code main_calc_hauptroutine = 0x10000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1238 void main_calc_hauptroutine(void) // length 0x0A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1239 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1240 calc_hauptroutine();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1241 int_O_desaturation_time = 65535;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1242 } // divemode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1243
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1244 #pragma code main_without_deco = 0x1000C // length 0x06
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1245 void main_calc_without_deco(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1246 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1247 calc_without_deco();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1248 calc_desaturation_time();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1249 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1250
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1251
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1252 #pragma code main_clear_CNS_fraction = 0x10016
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1253 void main_clear_CNS_fraction(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1254 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1255 clear_CNS_fraction();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1256 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1257
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1258 #pragma code main_calc_CNS_decrease_15min = 0x1001C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1259 void main_calc_CNS_decrease_15min(void) // length 0x06
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1260 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1261 calc_CNS_decrease_15min();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1262 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1263
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1264 #pragma code main_calc_percentage = 0x10022
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1265 void main_calc_percentage(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1266 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1267 calc_percentage();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1268 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1269
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1270 #pragma code main_clear_tissue = 0x10028
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1271 void main_clear_tissue(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1272 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1273 clear_tissue();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1274 char_I_depth_last_deco = 0; // for compatibility with v.101pre_no_last_deco
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1275 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1276
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1277 #pragma code main_calc_CNS_fraction = 0x10032
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1278 void main_calc_CNS_fraction(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1279 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1280 calc_CNS_fraction();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1281 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1282
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1283 #pragma code main_calc_desaturation_time = 0x10038
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1284 void main_calc_desaturation_time(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1285 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1286 calc_desaturation_time();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1287 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1288
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1289 #pragma code main_calc_wo_deco_step_1_min = 0x1003E
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1290 void main_calc_wo_deco_step_1_min(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1291 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1292 calc_wo_deco_step_1_min();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1293 char_O_deco_status = 3; // surface new in v.102 overwrites value of calc_wo_deco_step_1_min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1294 calc_desaturation_time();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1295 } // surface mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1296
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1297 #pragma code main_wordprocessor = 0x1004E
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1298 void main_wordprocessor(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1299 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1300 wordprocessor();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1301 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1302
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1303 #pragma code main_gradient_array = 0x10054
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1304 void main_gradient_array(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1305 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1306 calc_gradient_array_only();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1307 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1308
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1309 #pragma code main_push_tissues = 0x1005A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1310 void main_push_tissues_to_vault(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1311 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1312 push_tissues_to_vault();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1313 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1314
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1315 #pragma code main_pull_tissues = 0x10060
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1316 void main_pull_tissues_from_vault(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1317 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1318 pull_tissues_from_vault();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1319 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1320
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1321 #pragma code main_hash = 0x10066
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1322 void main_hash(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1323 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1324 hash();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1325 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1326 /*
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1327 #pragma code main_debug = 0x1004E
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1328 void main_debug(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1329 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1330 // debug();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1331 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1332 */
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1333
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1334 // ***********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1335 // ***********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1336 // ** THE LOOKUP TABLES **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1337 // ***********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1338 // ***********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1339
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1340 #pragma romdata tables = 0x10200
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1341 #include <p2_tables.romdata> // new table for deco_main_v.101 (var_a modified)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1342
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1343 #pragma romdata tables2 = 0x10600
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1344 rom const rom unsigned int md_pi[] =
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1345 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1346 0x292E, 0x43C9, 0xA2D8, 0x7C01, 0x3D36, 0x54A1, 0xECF0, 0x0613
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1347 , 0x62A7, 0x05F3, 0xC0C7, 0x738C, 0x9893, 0x2BD9, 0xBC4C, 0x82CA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1348 , 0x1E9B, 0x573C, 0xFDD4, 0xE016, 0x6742, 0x6F18, 0x8A17, 0xE512
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1349 , 0xBE4E, 0xC4D6, 0xDA9E, 0xDE49, 0xA0FB, 0xF58E, 0xBB2F, 0xEE7A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1350 , 0xA968, 0x7991, 0x15B2, 0x073F, 0x94C2, 0x1089, 0x0B22, 0x5F21
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1351 , 0x807F, 0x5D9A, 0x5A90, 0x3227, 0x353E, 0xCCE7, 0xBFF7, 0x9703
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1352 , 0xFF19, 0x30B3, 0x48A5, 0xB5D1, 0xD75E, 0x922A, 0xAC56, 0xAAC6
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1353 , 0x4FB8, 0x38D2, 0x96A4, 0x7DB6, 0x76FC, 0x6BE2, 0x9C74, 0x04F1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1354 , 0x459D, 0x7059, 0x6471, 0x8720, 0x865B, 0xCF65, 0xE62D, 0xA802
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1355 , 0x1B60, 0x25AD, 0xAEB0, 0xB9F6, 0x1C46, 0x6169, 0x3440, 0x7E0F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1356 , 0x5547, 0xA323, 0xDD51, 0xAF3A, 0xC35C, 0xF9CE, 0xBAC5, 0xEA26
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1357 , 0x2C53, 0x0D6E, 0x8528, 0x8409, 0xD3DF, 0xCDF4, 0x4181, 0x4D52
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1358 , 0x6ADC, 0x37C8, 0x6CC1, 0xABFA, 0x24E1, 0x7B08, 0x0CBD, 0xB14A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1359 , 0x7888, 0x958B, 0xE363, 0xE86D, 0xE9CB, 0xD5FE, 0x3B00, 0x1D39
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1360 , 0xF2EF, 0xB70E, 0x6658, 0xD0E4, 0xA677, 0x72F8, 0xEB75, 0x4B0A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1361 , 0x3144, 0x50B4, 0x8FED, 0x1F1A, 0xDB99, 0x8D33, 0x9F11, 0x8314
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1362 };
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1363
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1364 // *********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1365 // *********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1366 // ** THE SUBROUTINES **
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1367 // *********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1368 // *********************
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1369
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1370 #pragma code subroutines = 0x10700 // can be adapted to fit the romdata tables ahead
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1371
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1372
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1373 // ---------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1374 // CLEAR tissue //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1375 // ---------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1376 // optimized in v.101 (var_a)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1377
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1378 void clear_tissue(void) // preload tissues with standard pressure for the given ambient pressure
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1379 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1380
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1381 flag_in_divemode = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1382 int_O_DBS_bitfield = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1383 int_O_DBS2_bitfield = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1384 int_O_DBG_pre_bitfield = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1385 int_O_DBG_post_bitfield = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1386 char_O_NDL_at_20mtr = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1387
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1388 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1389 lfsr 1, 0x300 // C math routines shall use this variable bank
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1390 movlw 0x01
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1391 movwf TBLPTRU,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1392 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1393
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1394 // N2_ratio = (float)char_I_N2_ratio; // the 0.0002 of 0.7902 are missing with standard air
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1395 N2_ratio = 0.7902; // N2_ratio / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1396 pres_respiration = (float)int_I_pres_respiration / 1000.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1397 for (ci=0;ci<16;ci++) // cycle through the 16 b"uhlmann tissues
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1398 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1399 pres_tissue[ci] = N2_ratio * (pres_respiration - 0.0627) ;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1400 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1401 movlw 0x02
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1402 movwf TBLPTRH,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1403 movlb 4 // fuer ci
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1404 movf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1405 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1406 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1407 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1408 addlw 0x80
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1409 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1410 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1411 movff TABLAT,var_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1412 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1413 movff TABLAT,var_a
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1414 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1415 movff TABLAT,var_a+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1416 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1417 movff TABLAT,var_a+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1418 addlw 0x80
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1419 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1420 incf TBLPTRH,1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1421 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1422 movff TABLAT,var_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1423 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1424 movff TABLAT,var_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1425 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1426 movff TABLAT,var_b+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1427 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1428 movff TABLAT,var_b+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1429 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1430
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1431 pres_tissue_limit[ci] = (pres_tissue[ci] - var_a) * var_b ;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1432 // now update the guiding tissue
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1433 if (pres_tissue_limit[ci] < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1434 pres_tissue_limit[ci] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1435 } // for 0 to 16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1436
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1437 for (ci=16;ci<32;ci++) // cycle through the 16 b"uhlmann tissues for Helium
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1438 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1439 pres_tissue[ci] = 0.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1440 } // for
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1441
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1442 clear_decoarray();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1443 char_O_deco_status = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1444 char_O_nullzeit = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1445 char_O_ascenttime = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1446 char_O_gradient_factor = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1447 char_O_relative_gradient_GF = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1448 } // clear_tissue(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1449
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1450
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1451 // --------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1452 // calc_without_deco //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1453 // fixed N2_ratio ! //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1454 // --------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1455 // optimized in v.101 (float_..saturation_multiplier)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1456
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1457 void calc_without_deco(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1458 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1459 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1460 lfsr 1, 0x300
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1461 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1462 N2_ratio = 0.7902; // FIXED RATIO !! sum as stated in b"uhlmann
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1463 pres_respiration = (float)int_I_pres_respiration / 1000.0; // assembler code uses different digit system
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1464 pres_surface = (float)int_I_pres_surface / 1000.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1465 temp_atem = N2_ratio * (pres_respiration - 0.0627); // 0.0627 is the extra pressure in the body
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1466 temp2_atem = 0.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1467 temp_surface = pres_surface; // the b"uhlmann formula using temp_surface does apply to the pressure without any inert ratio
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1468 float_desaturation_multiplier = char_I_desaturation_multiplier / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1469 float_saturation_multiplier = char_I_saturation_multiplier / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1470
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1471 calc_tissue(); // update the pressure in the 16 tissues in accordance with the new ambient pressure
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1472
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1473 clear_decoarray();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1474 char_O_deco_status = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1475 char_O_nullzeit = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1476 char_O_ascenttime = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1477 calc_gradient_factor();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1478
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1479 } // calc_without_deco
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1480
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1481
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1482 // --------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1483 // calc_hauptroutine //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1484 // --------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1485 // this is the major code in dive mode
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1486 // calculates:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1487 // the tissues,
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1488 // the bottom time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1489 // and simulates the ascend with all deco stops
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1490
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1491 void calc_hauptroutine(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1492 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1493 calc_hauptroutine_data_input();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1494
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1495 if(!flag_in_divemode)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1496 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1497 flag_in_divemode = 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1498 create_dbs_set_dbg_and_ndl20mtr();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1499 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1500 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1501 check_pre_dbg();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1502
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1503 calc_hauptroutine_update_tissues();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1504 calc_gradient_factor();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1505
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1506
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1507 switch (char_O_deco_status) // toggle between calculation for nullzeit (bottom time), deco stops and more deco stops (continue)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1508 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1509 case 0:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1510 update_startvalues();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1511 calc_nullzeit();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1512 check_ndl();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1513 char_O_deco_status = 255; // calc deco next time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1514 break;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1515 case 1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1516 if (char_O_deco_status == 3)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1517 break;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1518 char_O_deco_status = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1519 // char_O_lock_depth_list = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1520 calc_hauptroutine_calc_deco();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1521 // build_debug_output();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1522 break;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1523 case 3: // new dive
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1524 clear_decoarray();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1525 clear_internal_deco_table_GF();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1526 copy_deco_table_GF();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1527 internal_deco_pointer = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1528 lock_GF_depth_list = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1529 update_startvalues();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1530 calc_nextdecodepth_GF();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1531 char_O_deco_status = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1532 break;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1533 default:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1534 update_startvalues();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1535 clear_decoarray();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1536 clear_internal_deco_table_GF();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1537 output[6] = 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1538 calc_hauptroutine_calc_ascend_to_deco();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1539 if (char_O_deco_status > 15) // can't go up to first deco, too deep to calculate in the given time slot
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1540 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1541 char_O_deco_status = 2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1542 // char_O_lock_depth_list = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1543 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1544 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1545 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1546 // char_O_lock_depth_list = lock_GF_depth_list;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1547 calc_hauptroutine_calc_deco();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1548 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1549 // build_debug_output();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1550 break;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1551 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1552 calc_ascenttime();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1553 check_post_dbg();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1554 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1555
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1556 void calc_hauptroutine_data_input(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1557 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1558 pres_respiration = (float)int_I_pres_respiration / 1000.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1559 pres_surface = (float)int_I_pres_surface / 1000.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1560
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1561 N2_ratio = (float)char_I_N2_ratio / 100.0;; // the 0.0002 of 0.7902 are missing with standard air
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1562 He_ratio = (float)char_I_He_ratio / 100.0;;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1563 deco_N2_ratio = (float)char_I_deco_N2_ratio / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1564 deco_He_ratio = (float)char_I_deco_He_ratio / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1565 float_deco_distance = (float)char_I_deco_distance / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1566 if(char_I_deco_gas_change)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1567 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1568 deco_gas_change = (float)char_I_deco_gas_change / 9.995 + pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1569 deco_gas_change = deco_gas_change + float_deco_distance;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1570 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1571 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1572 deco_gas_change = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1573 const_ppO2 = (float)char_I_const_ppO2 / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1574 deco_ppO2_change = (float)char_I_deco_ppO2_change / 99.95 + pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1575 deco_ppO2_change = deco_ppO2_change + float_deco_distance;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1576 deco_ppO2 = (float)char_I_deco_ppO2 / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1577 float_desaturation_multiplier = char_I_desaturation_multiplier / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1578 float_saturation_multiplier = char_I_saturation_multiplier / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1579 GF_low = (float)char_I_GF_Low_percentage / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1580 GF_high = (float)char_I_GF_High_percentage / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1581 GF_delta = GF_high - GF_low;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1582
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1583 temp2 = (pres_respiration - pres_surface) / 0.29985;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1584 int_temp = (int)(temp2);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1585 if (int_temp < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1586 int_temp = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1587 if (int_temp > 255)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1588 int_temp = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1589 char_O_actual_pointer = int_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1590
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1591 temp_depth_last_deco = (int)char_I_depth_last_deco;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1592 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1593
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1594 void calc_hauptroutine_update_tissues(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1595 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1596 int_O_calc_tissue_call_counter = int_O_calc_tissue_call_counter + 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1597 if (char_I_const_ppO2 == 0) // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1598 pres_diluent = pres_respiration; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1599 else // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1600 pres_diluent = ((pres_respiration - const_ppO2)/(N2_ratio + He_ratio)); // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1601 if (pres_diluent > pres_respiration) // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1602 pres_diluent = pres_respiration; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1603 if (pres_diluent > 0.0627) // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1604 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1605 temp_atem = N2_ratio * (pres_diluent - 0.0627); // changed in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1606 temp2_atem = He_ratio * (pres_diluent - 0.0627); // changed in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1607 char_O_diluent = (char)(pres_diluent/pres_respiration*100.0);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1608 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1609 else // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1610 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1611 temp_atem = 0.0; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1612 temp2_atem = 0.0; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1613 char_O_diluent = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1614 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1615 temp_surface = pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1616 calc_tissue();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1617 int_O_gtissue_limit = (int)(pres_tissue_limit[char_O_gtissue_no] * 1000);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1618 int_O_gtissue_press = (int)((pres_tissue[char_O_gtissue_no] + pres_tissue[char_O_gtissue_no+16]) * 1000);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1619 if (char_I_deco_model == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1620 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1621 temp1 = temp1 * GF_high;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1622 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1623 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1624 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1625 temp1 = temp_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1626 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1627 if (pres_gtissue_limit > temp1 && char_O_deco_status == 0) // if guiding tissue can not be exposed to surface pressure immediately
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1628 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1629 char_O_nullzeit = 0; // deco necessary
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1630 char_O_deco_status = 255; // calculate deco skip nullzeit calculation
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1631 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1632 } // calc_hauptroutine_update_tissues
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1633 void calc_hauptroutine_calc_deco(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1634 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1635 do
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1636 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1637 int_temp_decostatus = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1638 calc_nextdecodepth_GF();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1639 if (temp_depth_limit > 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1640 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1641 if (char_I_const_ppO2 == 0) // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1642 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1643 deco_diluent = temp_deco; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1644 if (temp_deco > deco_gas_change)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1645 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1646 calc_N2_ratio = N2_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1647 calc_He_ratio = He_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1648 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1649 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1650 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1651 calc_N2_ratio = deco_N2_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1652 calc_He_ratio = deco_He_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1653 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1654 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1655 else // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1656 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1657 calc_N2_ratio = N2_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1658 calc_He_ratio = He_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1659 if (temp_deco > deco_ppO2_change)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1660 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1661 deco_diluent = ((temp_deco - const_ppO2)/(N2_ratio + He_ratio)); // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1662 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1663 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1664 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1665 deco_diluent = ((temp_deco - deco_ppO2)/(N2_ratio + He_ratio)); // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1666 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1667 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1668 if (deco_diluent > temp_deco) // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1669 deco_diluent = temp_deco; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1670 if (deco_diluent > 0.0627) // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1671 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1672 temp_atem = calc_N2_ratio * (deco_diluent - 0.0627); // changed in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1673 temp2_atem = calc_He_ratio * (deco_diluent - 0.0627); // changed in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1674 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1675 else // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1676 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1677 temp_atem = 0.0; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1678 temp2_atem = 0.0; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1679 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1680 sim_tissue_1min();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1681 update_internal_deco_table_GF();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1682 temp_decotime = 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1683 update_decoarray();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1684 char_O_deco_status = char_O_deco_status + 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1685 if (char_O_deco_status < 16)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1686 int_temp_decostatus = 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1687 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1688 else // if (temp_depth_limit > 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1689 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1690 char_O_deco_status = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1691 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1692 } while (int_temp_decostatus == 1);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1693 if (char_O_deco_status > 15)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1694 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1695 char_O_deco_status = 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1696 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1697 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1698 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1699 copy_deco_table_GF();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1700 char_O_deco_status = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1701 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1702 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1703
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1704 void calc_hauptroutine_calc_ascend_to_deco(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1705 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1706 update_startvalues();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1707 char_O_deco_status = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1708 temp_deco = pres_respiration;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1709 lock_GF_depth_list = 1; // new in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1710 do // go up to first deco
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1711 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1712 int_temp_decostatus = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1713 temp_deco = temp_deco - 1.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1714 if ( char_I_deco_model == 1) // new in v.102 , 4 = deep stops
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1715 temp_limit = temp_pres_gtissue_limit_GF_low;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1716 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1717 temp_limit = temp_pres_gtissue_limit;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1718 if ((temp_deco > temp_limit) && (temp_deco > pres_surface)) // changes in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1719 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1720 lock_GF_depth_list = 0; // new in v.102, distance to first stop > 10 mtr.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1721 output[6] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1722 if (char_I_const_ppO2 == 0) // new in v.101 // calculate at half of the ascent
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1723 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1724 deco_diluent = temp_deco + 0.5; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1725 if (temp_deco + 0.5 > deco_gas_change)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1726 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1727 calc_N2_ratio = N2_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1728 calc_He_ratio = He_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1729 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1730 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1731 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1732 calc_N2_ratio = deco_N2_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1733 calc_He_ratio = deco_He_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1734 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1735 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1736 else // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1737 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1738 calc_N2_ratio = N2_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1739 calc_He_ratio = He_ratio;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1740 if (temp_deco + 0.5 > deco_ppO2_change)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1741 deco_diluent = ((temp_deco + 0.5 - const_ppO2)/(N2_ratio + He_ratio)); // new in v.101 // calculate at half of the ascent
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1742 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1743 deco_diluent = ((temp_deco + 0.5 - deco_ppO2)/(N2_ratio + He_ratio)); // new in v.101 // calculate at half of the ascent
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1744 if (deco_diluent > (temp_deco +0.5)) // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1745 deco_diluent = temp_deco + 0.5; // new in v.101 // calculate at half of the ascent
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1746 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1747 if (deco_diluent > 0.0627) // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1748 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1749 temp_atem = calc_N2_ratio * (deco_diluent - 0.0627); // changed in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1750 temp2_atem = calc_He_ratio * (deco_diluent - 0.0627); // changed in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1751 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1752 else // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1753 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1754 temp_atem = 0.0; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1755 temp2_atem = 0.0; // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1756 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1757 sim_tissue_1min();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1758 char_O_deco_status = char_O_deco_status + 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1759 if (char_O_deco_status < 16) // 16 is the limit of calculations for one time slot
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1760 int_temp_decostatus = 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1761 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1762 } while (int_temp_decostatus == 1);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1763 } // calc_hauptroutine_calc_ascend_to_deco
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1764
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1765 // --------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1766 // calc_tissue //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1767 // --------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1768 // optimized in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1769
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1770 void calc_tissue(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1771 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1772 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1773 lfsr 1, 0x300
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1774 movlw 0x01
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1775 movwf TBLPTRU,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1776 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1777
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1778 char_O_gtissue_no = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1779 pres_gtissue_limit = 0.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1780
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1781 for (ci=0;ci<16;ci++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1782 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1783 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1784 movlw 0x02
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1785 movwf TBLPTRH,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1786 movlb 4 // fuer ci
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1787 movf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1788 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1789 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1790 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1791 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1792 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1793 movff TABLAT,var_e2secs+1 // the order is confussing
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1794 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1795 movff TABLAT,var_e2secs // low byte first, high afterwards
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1796 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1797 movff TABLAT,var_e2secs+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1798 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1799 movff TABLAT,var_e2secs+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1800 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1801 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1802 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1803 movff TABLAT,var2_e2secs+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1804 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1805 movff TABLAT,var2_e2secs
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1806 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1807 movff TABLAT,var2_e2secs+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1808 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1809 movff TABLAT,var2_e2secs+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1810 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1811 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1812 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1813 movff TABLAT,var_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1814 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1815 movff TABLAT,var_a
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1816 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1817 movff TABLAT,var_a+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1818 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1819 movff TABLAT,var_a+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1820 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1821 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1822 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1823 movff TABLAT,var2_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1824 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1825 movff TABLAT,var2_a
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1826 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1827 movff TABLAT,var2_a+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1828 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1829 movff TABLAT,var2_a+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1830 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1831 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1832 incf TBLPTRH,1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1833 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1834 movff TABLAT,var_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1835 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1836 movff TABLAT,var_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1837 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1838 movff TABLAT,var_b+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1839 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1840 movff TABLAT,var_b+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1841 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1842 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1843 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1844 movff TABLAT,var2_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1845 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1846 movff TABLAT,var2_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1847 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1848 movff TABLAT,var2_b+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1849 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1850 movff TABLAT,var2_b+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1851 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1852 // the start values are the previous end values // write new values in temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1853
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1854 if( (var_e2secs < 0.0000363)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1855 || (var_e2secs > 0.00577)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1856 || (var2_e2secs < 0.0000961)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1857 || (var2_e2secs > 0.150)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1858 || (var_a < 0.231)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1859 || (var_a > 1.27)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1860 || (var_b < 0.504)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1861 || (var_b > 0.966)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1862 || (var2_a < 0.510)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1863 || (var2_a > 1.75)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1864 || (var2_b < 0.423)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1865 || (var2_b > 0.927)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1866 )
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1867 int_O_DBG_pre_bitfield |= DBG_ZH16ERR;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1868
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1869 // N2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1870 temp_tissue = (temp_atem - pres_tissue[ci]) * var_e2secs;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1871 temp_tissue_safety();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1872 pres_tissue[ci] = pres_tissue[ci] + temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1873
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1874 // He
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1875 temp_tissue = (temp2_atem - pres_tissue[ci+16]) * var2_e2secs;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1876 temp_tissue_safety();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1877 pres_tissue[ci+16] = pres_tissue[ci+16] + temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1878
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1879 temp_tissue = pres_tissue[ci] + pres_tissue[ci+16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1880
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1881 var_a = (var_a * pres_tissue[ci] + var2_a * pres_tissue[ci+16]) / temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1882 var_b = (var_b * pres_tissue[ci] + var2_b * pres_tissue[ci+16]) / temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1883 pres_tissue_limit[ci] = (temp_tissue - var_a) * var_b;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1884 if (pres_tissue_limit[ci] < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1885 pres_tissue_limit[ci] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1886 if (pres_tissue_limit[ci] > pres_gtissue_limit)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1887 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1888 pres_gtissue_limit = pres_tissue_limit[ci];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1889 char_O_gtissue_no = ci;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1890 }//if
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1891 } // for
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1892 }//calc_tissue(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1893
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1894 // ----------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1895 // calc_nullzeit //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1896 // ----------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1897 // calculates the remaining bottom time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1898
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1899 // unchanged in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1900
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1901 void calc_nullzeit(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1902 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1903 char_O_nullzeit = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1904 int_temp = 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1905 do
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1906 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1907 backup_sim_pres_tissue();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1908 sim_tissue_10min();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1909 char_O_nullzeit = char_O_nullzeit + 10;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1910 int_temp = int_temp + 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1911 if (char_I_deco_model == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1912 temp1 = GF_high * temp_pres_gtissue_diff + temp_pres_gtissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1913 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1914 temp1 = temp_pres_gtissue_limit;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1915 if (temp1 > temp_surface) // changed in v.102 , if guiding tissue can not be exposed to surface pressure immediately
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1916 int_temp = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1917 } while (int_temp < 17);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1918 if (int_temp == 255)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1919 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1920 restore_sim_pres_tissue();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1921 char_O_nullzeit = char_O_nullzeit - 10;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1922 } //if int_temp == 255]
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1923 int_temp = 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1924 if (char_O_nullzeit < 60)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1925 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1926 do
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1927 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1928 sim_tissue_1min();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1929 char_O_nullzeit = char_O_nullzeit + 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1930 int_temp = int_temp + 1; // new in v.102a
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1931 if (char_I_deco_model == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1932 temp1 = GF_high * temp_pres_gtissue_diff + temp_pres_gtissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1933 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1934 temp1 = temp_pres_gtissue_limit;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1935 if (temp1 > temp_surface) // changed in v.102 , if guiding tissue can not be exposed to surface pressure immediately
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1936 int_temp = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1937 } while (int_temp < 10);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1938 if (int_temp == 255)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1939 char_O_nullzeit = char_O_nullzeit - 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1940 } // if char_O_nullzeit < 60
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1941 } //calc_nullzeit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1942
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1943 // -------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1944 // backup_sim_pres_tissue //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1945 // -------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1946 void backup_sim_pres_tissue(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1947 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1948 for (x = 0;x<16;x++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1949 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1950 sim_pres_tissue_backup[x] = sim_pres_tissue[x];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1951 sim_pres_tissue_backup[x+16] = sim_pres_tissue[x+16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1952 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1953 } // backup_sim
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1954
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1955 // --------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1956 // restore_sim_pres_tissue //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1957 // --------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1958 void restore_sim_pres_tissue(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1959 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1960 for (x = 0;x<16;x++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1961 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1962 sim_pres_tissue[x] = sim_pres_tissue_backup[x];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1963 sim_pres_tissue[x+16] = sim_pres_tissue_backup[x+16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1964 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1965 } // restore_sim
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1966
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1967 // ------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1968 // calc_ascenttime //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1969 // ------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1970
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1971 void calc_ascenttime(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1972 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1973 if (pres_respiration > pres_surface)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1974 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1975 switch (char_O_deco_status)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1976 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1977 case 2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1978 char_O_ascenttime = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1979 break;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1980 case 1:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1981 break;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1982 default:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1983 temp1 = pres_respiration - pres_surface + 0.6; // + 0.6 hence 1 minute ascent time from a depth of 4 meter on
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1984 if (temp1 < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1985 temp1 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1986 if (temp1 > 255)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1987 temp1 = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1988 char_O_ascenttime = (char)temp1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1989
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1990 for(ci=0;ci<7;ci++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1991 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1992 x = char_O_ascenttime + char_O_array_decotime[ci];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1993 if (x < char_O_ascenttime)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1994 char_O_ascenttime = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1995 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1996 char_O_ascenttime = x;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1997 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1998 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
1999 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2000 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2001 char_O_ascenttime = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2002 } // calc_ascenttime()
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2003
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2004
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2005 // ---------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2006 // update_startvalues //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2007 // ---------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2008 // updated in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2009
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2010 void update_startvalues(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2011 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2012 temp_pres_gtissue_limit = pres_gtissue_limit;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2013 temp_pres_gtissue = pres_tissue[char_O_gtissue_no] + pres_tissue[char_O_gtissue_no+16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2014 temp_pres_gtissue_diff = temp_pres_gtissue_limit - temp_pres_gtissue; // negative number
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2015 temp_pres_gtissue_limit_GF_low = GF_low * temp_pres_gtissue_diff + temp_pres_gtissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2016 temp_pres_gtissue_limit_GF_low_below_surface = temp_pres_gtissue_limit_GF_low - pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2017 if (temp_pres_gtissue_limit_GF_low_below_surface < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2018 temp_pres_gtissue_limit_GF_low_below_surface = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2019
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2020 temp_gtissue_no = char_O_gtissue_no;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2021 for (x = 0;x<16;x++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2022 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2023 sim_pres_tissue[x] = pres_tissue[x];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2024 sim_pres_tissue[x+16] = pres_tissue[x+16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2025 sim_pres_tissue_limit[x] = pres_tissue_limit[x];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2026 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2027 } // update_startvalues
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2028
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2029
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2030 // ------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2031 // sim_tissue_1min //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2032 // ------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2033 // optimized in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2034
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2035 void sim_tissue_1min(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2036 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2037 temp_pres_gtissue_limit = 0.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2038 temp_gtissue_no = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2039
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2040 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2041 lfsr 1, 0x300
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2042 movlw 0x01
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2043 movwf TBLPTRU,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2044 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2045
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2046
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2047 for (ci=0;ci<16;ci++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2048 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2049 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2050 movlw 0x02
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2051 movwf TBLPTRH,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2052 movlb 4 // fuer ci
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2053 movf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2054 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2055 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2056 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2057 addlw 0x80
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2058 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2059 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2060 movff TABLAT,var_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2061 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2062 movff TABLAT,var_a
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2063 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2064 movff TABLAT,var_a+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2065 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2066 movff TABLAT,var_a+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2067 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2068 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2069 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2070 movff TABLAT,var2_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2071 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2072 movff TABLAT,var2_a
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2073 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2074 movff TABLAT,var2_a+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2075 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2076 movff TABLAT,var2_a+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2077 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2078 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2079 incf TBLPTRH,1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2080 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2081 movff TABLAT,var_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2082 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2083 movff TABLAT,var_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2084 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2085 movff TABLAT,var_b+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2086 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2087 movff TABLAT,var_b+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2088 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2089 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2090 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2091 movff TABLAT,var2_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2092 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2093 movff TABLAT,var2_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2094 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2095 movff TABLAT,var2_b+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2096 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2097 movff TABLAT,var2_b+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2098 addlw 0xC0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2099 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2100 incf TBLPTRH,1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2101 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2102 movff TABLAT,var_e1min+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2103 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2104 movff TABLAT,var_e1min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2105 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2106 movff TABLAT,var_e1min+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2107 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2108 movff TABLAT,var_e1min+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2109 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2110 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2111 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2112 movff TABLAT,var2_e1min+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2113 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2114 movff TABLAT,var2_e1min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2115 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2116 movff TABLAT,var2_e1min+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2117 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2118 movff TABLAT,var2_e1min+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2119 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2120 // N2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2121 temp_tissue = (temp_atem - sim_pres_tissue[ci]) * var_e1min;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2122 temp_tissue_safety();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2123 sim_pres_tissue[ci] = sim_pres_tissue[ci] + temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2124 // He
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2125 temp_tissue = (temp2_atem - sim_pres_tissue[ci+16]) * var2_e1min;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2126 temp_tissue_safety();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2127 sim_pres_tissue[ci+16] = sim_pres_tissue[ci+16] + temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2128 // pressure limit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2129 temp_tissue = sim_pres_tissue[ci] + sim_pres_tissue[ci+16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2130 var_a = (var_a * sim_pres_tissue[ci] + var2_a * sim_pres_tissue[ci+16]) / temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2131 var_b = (var_b * sim_pres_tissue[ci] + var2_b * sim_pres_tissue[ci+16]) / temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2132 sim_pres_tissue_limit[ci] = (temp_tissue - var_a) * var_b;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2133
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2134 if (sim_pres_tissue_limit[ci] < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2135 sim_pres_tissue_limit[ci] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2136 if (sim_pres_tissue_limit[ci] > temp_pres_gtissue_limit)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2137 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2138 temp_pres_gtissue = temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2139 temp_pres_gtissue_limit = sim_pres_tissue_limit[ci];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2140 temp_gtissue_no = ci;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2141 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2142 } // for
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2143 temp_pres_gtissue_diff = temp_pres_gtissue_limit - temp_pres_gtissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2144 temp_pres_gtissue_limit_GF_low = GF_low * temp_pres_gtissue_diff + temp_pres_gtissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2145 temp_pres_gtissue_limit_GF_low_below_surface = temp_pres_gtissue_limit_GF_low - pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2146 if (temp_pres_gtissue_limit_GF_low_below_surface < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2147 temp_pres_gtissue_limit_GF_low_below_surface = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2148 } //sim_tissue_1min()
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2149
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2150 //--------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2151 // sim_tissue_10min //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2152 //--------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2153
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2154 // Attention!! uses var_e1min und var2_e1min to load 10min data !!!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2155 // is identical to sim_tissue_1min routine except for the different load of those variables
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2156
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2157 // optimized in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2158
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2159 void sim_tissue_10min(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2160 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2161 temp_pres_gtissue_limit = 0.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2162 temp_gtissue_no = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2163
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2164 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2165 lfsr 1, 0x300
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2166 movlw 0x01
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2167 movwf TBLPTRU,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2168 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2169
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2170 for (ci=0;ci<16;ci++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2171 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2172 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2173 movlw 0x02
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2174 movwf TBLPTRH,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2175 movlb 4 // fuer ci
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2176 movf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2177 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2178 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2179 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2180 addlw 0x80
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2181 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2182 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2183 movff TABLAT,var_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2184 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2185 movff TABLAT,var_a
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2186 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2187 movff TABLAT,var_a+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2188 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2189 movff TABLAT,var_a+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2190 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2191 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2192 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2193 movff TABLAT,var2_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2194 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2195 movff TABLAT,var2_a
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2196 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2197 movff TABLAT,var2_a+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2198 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2199 movff TABLAT,var2_a+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2200 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2201 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2202 incf TBLPTRH,1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2203 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2204 movff TABLAT,var_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2205 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2206 movff TABLAT,var_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2207 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2208 movff TABLAT,var_b+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2209 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2210 movff TABLAT,var_b+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2211 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2212 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2213 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2214 movff TABLAT,var2_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2215 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2216 movff TABLAT,var2_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2217 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2218 movff TABLAT,var2_b+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2219 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2220 movff TABLAT,var2_b+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2221 addlw 0xC0 // different to 1 min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2222 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2223 incf TBLPTRH,1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2224 incf TBLPTRH,1,0 // different to 1 min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2225 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2226 movff TABLAT,var_e1min+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2227 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2228 movff TABLAT,var_e1min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2229 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2230 movff TABLAT,var_e1min+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2231 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2232 movff TABLAT,var_e1min+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2233 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2234 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2235 //incf TBLPTRH,1,0 // different to 1 min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2236 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2237 movff TABLAT,var2_e1min+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2238 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2239 movff TABLAT,var2_e1min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2240 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2241 movff TABLAT,var2_e1min+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2242 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2243 movff TABLAT,var2_e1min+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2244 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2245 // N2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2246 temp_tissue = (temp_atem - sim_pres_tissue[ci]) * var_e1min;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2247 temp_tissue_safety();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2248 sim_pres_tissue[ci] = sim_pres_tissue[ci] + temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2249 // He
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2250 temp_tissue = (temp2_atem - sim_pres_tissue[ci+16]) * var2_e1min;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2251 temp_tissue_safety();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2252 sim_pres_tissue[ci+16] = sim_pres_tissue[ci+16] + temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2253 // pressure limit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2254 temp_tissue = sim_pres_tissue[ci] + sim_pres_tissue[ci+16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2255 var_a = (var_a * sim_pres_tissue[ci] + var2_a * sim_pres_tissue[ci+16]) / temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2256 var_b = (var_b * sim_pres_tissue[ci] + var2_b * sim_pres_tissue[ci+16]) / temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2257
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2258 sim_pres_tissue_limit[ci] = (temp_tissue - var_a) * var_b;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2259 if (sim_pres_tissue_limit[ci] < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2260 sim_pres_tissue_limit[ci] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2261 if (sim_pres_tissue_limit[ci] > temp_pres_gtissue_limit)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2262 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2263 temp_pres_gtissue = temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2264 temp_pres_gtissue_limit = sim_pres_tissue_limit[ci];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2265 temp_gtissue_no = ci;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2266 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2267 } // for
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2268 temp_pres_gtissue_diff = temp_pres_gtissue_limit - temp_pres_gtissue; // negative number
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2269 temp_pres_gtissue_limit_GF_low = GF_low * temp_pres_gtissue_diff + temp_pres_gtissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2270 temp_pres_gtissue_limit_GF_low_below_surface = temp_pres_gtissue_limit_GF_low - pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2271 if (temp_pres_gtissue_limit_GF_low_below_surface < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2272 temp_pres_gtissue_limit_GF_low_below_surface = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2273 } //sim_tissue_10min()
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2274
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2275
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2276 // ------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2277 // clear_decoarray //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2278 // ------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2279 // unchanged in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2280
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2281 void clear_decoarray(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2282 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2283 char_O_array_decodepth[0] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2284 char_O_array_decodepth[1] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2285 char_O_array_decodepth[2] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2286 char_O_array_decodepth[3] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2287 char_O_array_decodepth[4] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2288 char_O_array_decodepth[5] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2289 char_O_array_decotime[0] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2290 char_O_array_decotime[1] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2291 char_O_array_decotime[2] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2292 char_O_array_decotime[3] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2293 char_O_array_decotime[4] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2294 char_O_array_decotime[5] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2295 char_O_array_decotime[6] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2296 } // clear_decoarray
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2297
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2298
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2299 // -------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2300 // update_decoarray //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2301 // -------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2302 // unchanged in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2303
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2304 void update_decoarray()
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2305 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2306 x = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2307 do
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2308 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2309 if (char_O_array_decodepth[x] == temp_depth_limit)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2310 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2311 int_temp = char_O_array_decotime[x] + temp_decotime;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2312 if (int_temp < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2313 int_temp = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2314 if (int_temp > 240)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2315 int_temp = 240;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2316 char_O_array_decotime[x] = int_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2317 x = 10; // exit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2318 } // if
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2319 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2320 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2321 if (char_O_array_decodepth[x] == 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2322 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2323 if (temp_depth_limit > 255)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2324 char_O_array_decodepth[x] = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2325 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2326 char_O_array_decodepth[x] = (char)temp_depth_limit;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2327 int_temp = char_O_array_decotime[x] + temp_decotime;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2328 if (int_temp > 240)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2329 char_O_array_decotime[x] = 240;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2330 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2331 char_O_array_decotime[x] = (char)int_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2332 x = 10; // exit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2333 } // if
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2334 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2335 x++;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2336 } // else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2337 } while (x<6);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2338 if (x == 6)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2339 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2340 int_temp = char_O_array_decotime[6] + temp_decotime;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2341 if (int_temp > 220)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2342 char_O_array_decotime[6] = 220;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2343 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2344 char_O_array_decotime[6] = (char)int_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2345 } // if x == 6
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2346 } // update_decoarray
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2347
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2348
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2349 // -----------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2350 // calc_gradient_factor //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2351 // -----------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2352 // optimized in v.101 (var_a)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2353 // new code in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2354
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2355 void calc_gradient_factor(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2356 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2357 // tissue > respiration (entsaettigungsvorgang)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2358 // gradient ist wieviel prozent an limit mit basis tissue
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2359 // dh. 0% = respiration == tissue
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2360 // dh. 100% = respiration == limit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2361 temp_tissue = pres_tissue[char_O_gtissue_no] + pres_tissue[char_O_gtissue_no+16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2362 temp1 = temp_tissue - pres_respiration;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2363 temp2 = temp_tissue - pres_tissue_limit[char_O_gtissue_no]; // changed in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2364 temp2 = temp1/temp2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2365 temp2 = temp2 * 100; // displayed in percent
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2366 if (temp2 < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2367 temp2 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2368 if (temp2 > 255)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2369 temp2 = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2370 if (temp1 < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2371 char_O_gradient_factor = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2372 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2373 char_O_gradient_factor = (char)temp2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2374
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2375 temp3 = temp2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2376
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2377 if (char_I_deco_model == 1) // calculate relative gradient factor
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2378 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2379 temp1 = (float)temp_depth_GF_low_meter * 0.09995;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2380 temp2 = pres_respiration - pres_surface;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2381 if (temp2 <= 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2382 temp1 = GF_high;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2383 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2384 if (temp2 >= temp1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2385 temp1 = GF_low;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2386 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2387 temp1 = GF_low + (temp1 - temp2)/temp1*GF_delta;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2388 if (temp_depth_GF_low_meter == 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2389 temp1 = GF_high;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2390 temp2 = temp3 / temp1; // temp3 is already in percent
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2391 if (temp2 < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2392 temp2 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2393 if (temp2 > 255)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2394 temp2 = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2395 char_O_relative_gradient_GF = (char)temp2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2396 } // calc relative gradient factor
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2397 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2398 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2399 char_O_relative_gradient_GF = char_O_gradient_factor;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2400 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2401 } // calc_gradient
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2402
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2403 // ---------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2404 // calc_gradient_array_only //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2405 // ---------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2406 // optimized in v.101 (var_a)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2407 // new code in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2408
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2409 void calc_gradient_array_only()
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2410 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2411 pres_respiration = (float)int_I_pres_respiration / 1000.0; // assembler code uses different digit system
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2412 for (ci=0;ci<16;ci++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2413 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2414 temp_tissue = pres_tissue[ci] + pres_tissue[ci+16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2415 temp1 = temp_tissue - pres_respiration;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2416 temp2 = temp_tissue - pres_tissue_limit[ci];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2417 temp2 = temp1/temp2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2418 temp2 = temp2 * 200; // because of output in (Double-)percentage
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2419 if (temp2 < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2420 temp2 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2421 if (temp2 > 255)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2422 temp2 = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2423 if (temp1 < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2424 char_O_array_gradient_weighted[ci] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2425 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2426 char_O_array_gradient_weighted[ci] = (char)temp2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2427 } // for
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2428 } // calc_gradient_array_only
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2429
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2430
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2431 // -------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2432 // calc_desaturation_time //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2433 // -------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2434 // FIXED N2_ratio
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2435 // unchanged in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2436
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2437 void calc_desaturation_time(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2438 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2439 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2440 lfsr 1, 0x300
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2441 movlw 0x01
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2442 movwf TBLPTRU,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2443 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2444 N2_ratio = 0.7902; // FIXED sum as stated in b"uhlmann
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2445 pres_surface = (float)int_I_pres_surface / 1000.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2446 temp_atem = N2_ratio * (pres_surface - 0.0627);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2447 int_O_desaturation_time = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2448 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2449
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2450 for (ci=0;ci<16;ci++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2451 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2452 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2453 movlw 0x04
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2454 movwf TBLPTRH,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2455 movlb 4 // fuer ci
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2456 movf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2457 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2458 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2459 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2460 addlw 0x80
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2461 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2462 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2463 movff TABLAT,var_halftimes+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2464 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2465 movff TABLAT,var_halftimes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2466 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2467 movff TABLAT,var_halftimes+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2468 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2469 movff TABLAT,var_halftimes+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2470 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2471 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2472 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2473 movff TABLAT,var2_halftimes+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2474 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2475 movff TABLAT,var2_halftimes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2476 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2477 movff TABLAT,var2_halftimes+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2478 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2479 movff TABLAT,var2_halftimes+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2480 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2481
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2482 // saturation_time (for flight) and N2_saturation in multiples of halftime
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2483 // version v.100: 1.1 = 10 percent distance to totally clean (totally clean is not possible, would take infinite time )
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2484 // new in version v.101: 1.07 = 7 percent distance to totally clean (totally clean is not possible, would take infinite time )
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2485 // changes in v.101: 1.05 = 5 percent dist to totally clean is new desaturation point for display and noFly calculations
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2486 // N2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2487 temp1 = 1.05 * temp_atem;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2488 temp1 = temp1 - pres_tissue[ci];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2489 temp2 = temp_atem - pres_tissue[ci];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2490 if (temp2 >= 0.0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2491 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2492 temp1 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2493 temp2 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2494 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2495 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2496 temp1 = temp1 / temp2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2497 if (temp1 > 0.0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2498 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2499 temp1 = log(1.0 - temp1);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2500 temp1 = temp1 / -0.6931; // temp1 is the multiples of half times necessary.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2501 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2502 // minus because log is negative
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2503 temp2 = var_halftimes * temp1 / float_desaturation_multiplier; // time necessary (in minutes ) for complete desaturation (see comment about 10 percent) , new in v.101: float_desaturation_multiplier
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2504 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2505 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2506 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2507 temp1 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2508 temp2 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2509 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2510
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2511 // He
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2512 temp3 = 0.1 - pres_tissue[ci+16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2513 if (temp3 >= 0.0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2514 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2515 temp3 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2516 temp4 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2517 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2518 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2519 temp3 = -1.0 * temp3 / pres_tissue[ci+16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2520 if (temp3 > 0.0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2521 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2522 temp3 = log(1.0 - temp3);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2523 temp3 = temp3 / -0.6931; // temp1 is the multiples of half times necessary.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2524 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested.
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2525 // minus because log is negative
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2526 temp4 = var2_halftimes * temp3 / float_desaturation_multiplier; // time necessary (in minutes ) for "complete" desaturation, new in v.101 float_desaturation_multiplier
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2527 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2528 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2529 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2530 temp3 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2531 temp4 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2532 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2533
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2534 // saturation_time (for flight)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2535 if (temp4 > temp2)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2536 int_temp = (int)temp4;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2537 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2538 int_temp = (int)temp2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2539 if(int_temp > int_O_desaturation_time)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2540 int_O_desaturation_time = int_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2541
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2542 // N2 saturation in multiples of halftime for display purposes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2543 temp2 = temp1 * 20.0; // 0 = 1/8, 120 = 0, 249 = 8
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2544 temp2 = temp2 + 80.0; // set center
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2545 if (temp2 < 0.0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2546 temp2 = 0.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2547 if (temp2 > 255.0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2548 temp2 = 255.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2549 char_O_tissue_saturation[ci] = (char)temp2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2550 // He saturation in multiples of halftime for display purposes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2551 temp4 = temp3 * 20.0; // 0 = 1/8, 120 = 0, 249 = 8
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2552 temp4 = temp4 + 80.0; // set center
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2553 if (temp4 < 0.0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2554 temp4 = 0.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2555 if (temp4 > 255.0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2556 temp4 = 255.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2557 char_O_tissue_saturation[ci+16] = (char)temp4;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2558 } // for
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2559 } // calc_desaturation_time
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2560
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2561
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2562 // --------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2563 // calc_wo_deco_step_1_min //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2564 // --------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2565 // FIXED N2 Ratio
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2566 // optimized in v.101 (...saturation_multiplier)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2567 // desaturation slowed down to 70,42%
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2568
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2569 void calc_wo_deco_step_1_min(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2570 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2571 if(flag_in_divemode)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2572 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2573 flag_in_divemode = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2574 set_dbg_end_of_dive();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2575 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2576 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2577 lfsr 1, 0x300
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2578 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2579 N2_ratio = 0.7902; // FIXED, sum lt. buehlmann
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2580 pres_respiration = (float)int_I_pres_respiration / 1000.0; // assembler code uses different digit system
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2581 pres_surface = (float)int_I_pres_surface / 1000.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2582 temp_atem = N2_ratio * (pres_respiration - 0.0627); // 0.0627 is the extra pressure in the body
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2583 temp2_atem = 0.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2584 temp_surface = pres_surface; // the b"uhlmann formula using temp_surface does not use the N2_ratio
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2585 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2586 float_saturation_multiplier = char_I_saturation_multiplier / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2587
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2588 calc_tissue_step_1_min(); // update the pressure in the 16 tissues in accordance with the new ambient pressure
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2589 clear_decoarray();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2590 char_O_deco_status = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2591 char_O_nullzeit = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2592 char_O_ascenttime = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2593 calc_gradient_factor();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2594
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2595 } // calc_wo_deco_step_1_min(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2596
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2597
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2598 // -------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2599 // calc_tissue_step_1_min //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2600 // -------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2601 // optimized in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2602
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2603 void calc_tissue_step_1_min(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2604 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2605 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2606 lfsr 1, 0x300
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2607 movlw 0x01
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2608 movwf TBLPTRU,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2609 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2610
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2611 char_O_gtissue_no = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2612 pres_gtissue_limit = 0.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2613
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2614 for (ci=0;ci<16;ci++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2615 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2616 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2617 movlw 0x02
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2618 movwf TBLPTRH,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2619 movlb 4 // fuer ci
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2620 movf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2621 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2622 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2623 addwf ci,0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2624 addlw 0x80
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2625 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2626 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2627 movff TABLAT,var_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2628 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2629 movff TABLAT,var_a
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2630 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2631 movff TABLAT,var_a+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2632 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2633 movff TABLAT,var_a+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2634 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2635 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2636 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2637 movff TABLAT,var2_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2638 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2639 movff TABLAT,var2_a
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2640 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2641 movff TABLAT,var2_a+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2642 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2643 movff TABLAT,var2_a+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2644 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2645 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2646 incf TBLPTRH,1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2647 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2648 movff TABLAT,var_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2649 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2650 movff TABLAT,var_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2651 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2652 movff TABLAT,var_b+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2653 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2654 movff TABLAT,var_b+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2655 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2656 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2657 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2658 movff TABLAT,var2_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2659 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2660 movff TABLAT,var2_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2661 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2662 movff TABLAT,var2_b+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2663 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2664 movff TABLAT,var2_b+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2665 addlw 0xC0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2666 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2667 incf TBLPTRH,1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2668 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2669 movff TABLAT,var_e1min+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2670 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2671 movff TABLAT,var_e1min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2672 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2673 movff TABLAT,var_e1min+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2674 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2675 movff TABLAT,var_e1min+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2676 addlw 0x40
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2677 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2678 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2679 movff TABLAT,var2_e1min+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2680 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2681 movff TABLAT,var2_e1min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2682 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2683 movff TABLAT,var2_e1min+3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2684 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2685 movff TABLAT,var2_e1min+2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2686 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2687
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2688 // N2 1 min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2689 temp_tissue = (temp_atem - pres_tissue[ci]) * var_e1min;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2690 temp_tissue_safety();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2691 pres_tissue[ci] = pres_tissue[ci] + temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2692
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2693 // He 1 min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2694 temp_tissue = (temp2_atem - pres_tissue[ci+16]) * var2_e1min;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2695 temp_tissue_safety();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2696 pres_tissue[ci+16] = pres_tissue[ci+16] + temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2697
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2698 temp_tissue = pres_tissue[ci] + pres_tissue[ci+16];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2699 var_a = (var_a * pres_tissue[ci] + var2_a * pres_tissue[ci+16]) / temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2700 var_b = (var_b * pres_tissue[ci] + var2_b * pres_tissue[ci+16]) / temp_tissue;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2701 pres_tissue_limit[ci] = (temp_tissue - var_a) * var_b;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2702 if (pres_tissue_limit[ci] < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2703 pres_tissue_limit[ci] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2704 if (pres_tissue_limit[ci] > pres_gtissue_limit)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2705 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2706 pres_gtissue_limit = pres_tissue_limit[ci];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2707 char_O_gtissue_no = ci;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2708 }//if
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2709
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2710 // gradient factor array for graphical display
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2711 // display range is 0 to 250! in steps of 5 for 1 pixel
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2712 // the display is divided in 6 blocks
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2713 // -> double the gradient 100% = 200
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2714 // tissue > respiration (entsaettigungsvorgang)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2715 // gradient ist wieviel prozent an limit von tissue aus
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2716 // dh. 0% = respiration == tissue
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2717 // dh. 100% = respiration == limit
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2718 temp1 = temp_tissue - pres_respiration;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2719 temp2 = temp_tissue - pres_tissue_limit[ci]; // changed in v.102
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2720 temp2 = temp1/temp2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2721 temp2 = temp2 * 200; // because of output in (Double-)percentage
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2722 if (temp2 < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2723 temp2 = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2724 if (temp2 > 255)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2725 temp2 = 255;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2726 if (temp1 < 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2727 char_O_array_gradient_weighted[ci] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2728 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2729 char_O_array_gradient_weighted[ci] = (char)temp2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2730
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2731 } // for
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2732 } // calc wo deco 1min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2733
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2734 #if 0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2735 // --------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2736 // debug //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2737 // --------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2738 void debug(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2739 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2740 for (ci=0;ci<32;ci++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2741 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2742 int_O_tissue_for_debug[ci] = (unsigned int)(pres_tissue[ci] *1000);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2743 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2744 } // void debug(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2745 #endif
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2746
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2747 // ----------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2748 // md hash //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2749 // ----------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2750 void hash(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2751 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2752 // init
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2753 for (md_i=0;md_i<16;md_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2754 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2755 md_state[md_i] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2756 md_cksum[md_i] = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2757 } // for md_i 16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2758
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2759 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2760 movlw 0x01
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2761 movwf TBLPTRU,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2762 movlw 0x06
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2763 movwf TBLPTRH,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2764 movlw 0x00
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2765 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2766 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2767 for (md_i=0;md_i<127;md_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2768 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2769 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2770 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2771 movff TABLAT,md_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2772 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2773 md_pi_subst[md_i] = md_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2774 } // for md_i 256
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2775 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2776 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2777 movff TABLAT,md_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2778 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2779 md_pi_subst[127] = md_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2780 for (md_i=0;md_i<127;md_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2781 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2782 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2783 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2784 movff TABLAT,md_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2785 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2786 md_pi_subst[md_i+128] = md_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2787 } // for md_i 256
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2788 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2789 TBLRD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2790 movff TABLAT,md_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2791 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2792 md_pi_subst[255] = md_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2793
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2794 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2795 movlw 0x00
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2796 movwf TBLPTRU,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2797 movlw 0x00
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2798 movwf TBLPTRH,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2799 movlw 0x00
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2800 movwf TBLPTRL,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2801 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2802 // cycle buffers
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2803 for (md_pointer=0x0000;md_pointer<0x17f3;md_pointer++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2804 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2805 md_t = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2806 for (md_i=0;md_i<16;md_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2807 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2808 if(md_pointer == 9)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2809 md_temp = md_cksum[md_i];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2810 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2811 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2812 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2813 TBLRDPOSTINC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2814 movff TABLAT,md_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2815 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2816 } // else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2817 md_buffer[md_i] = md_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2818 md_state[md_i+16] = md_buffer[md_i];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2819 md_state[md_i+32] = (unsigned char)(md_buffer[md_i] ^ md_state[md_i]);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2820 } // for md_i 16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2821
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2822 for (md_i=0;md_i<18;md_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2823 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2824 for (md_j=0;md_j<48;md_j++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2825 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2826 md_state[md_j] = (unsigned char)(md_state[md_j] ^ md_pi_subst[md_t]);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2827 md_t = md_state[md_j];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2828 } // for md_j 48
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2829 md_t = (unsigned char)(md_t+1);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2830 } // for md_i 18
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2831 md_t = md_cksum[15];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2832
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2833 for (md_i=0;md_i<16;md_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2834 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2835 md_cksum[md_i] = (unsigned char)(md_cksum[md_i] ^ md_pi_subst[(md_buffer[md_i] ^ md_t)]);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2836 md_t = md_cksum[md_i];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2837 } // for md_i 16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2838 } // for md_pointer
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2839 } // void hash(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2840
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2841 // ---------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2842 // clear_CNS_fraction //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2843 // ---------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2844 // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2845
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2846 void clear_CNS_fraction(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2847 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2848 CNS_fraction = 0.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2849 char_O_CNS_fraction = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2850 } // void clear_CNS_fraction(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2851
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2852
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2853 // --------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2854 // calc_CNS_fraction //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2855 // --------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2856 // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2857 // optimized in v.102 : with new variables char_I_actual_ppO2 and actual_ppO2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2858
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2859 // Input: char_I_actual_ppO2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2860 // Output: char_O_CNS_fraction
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2861 // Uses and Updates: CNS_fraction
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2862 // Uses: acutal_ppO2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2863
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2864 void calc_CNS_fraction(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2865 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2866 actual_ppO2 = (float)char_I_actual_ppO2 / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2867
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2868 if (char_I_actual_ppO2 < 50)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2869 CNS_fraction = CNS_fraction;// no changes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2870 else if (char_I_actual_ppO2 < 60)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2871 CNS_fraction = 1/(-54000.0 * actual_ppO2 + 54000.0) + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2872 else if (char_I_actual_ppO2 < 70)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2873 CNS_fraction = 1/(-45000.0 * actual_ppO2 + 48600.0) + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2874 else if (char_I_actual_ppO2 < 80)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2875 CNS_fraction = 1/(-36000.0 * actual_ppO2 + 42300.0) + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2876 else if (char_I_actual_ppO2 < 90)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2877 CNS_fraction = 1/(-27000.0 * actual_ppO2 + 35100.0) + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2878 else if (char_I_actual_ppO2 < 110)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2879 CNS_fraction = 1/(-18000.0 * actual_ppO2 + 27000.0) + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2880 else if (char_I_actual_ppO2 < 150)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2881 CNS_fraction = 1/(-9000.0 * actual_ppO2 + 17100.0) + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2882 else if (char_I_actual_ppO2 < 160)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2883 CNS_fraction = 1/(-22500.0 * actual_ppO2 + 37350.0) + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2884 else if (char_I_actual_ppO2 < 165)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2885 CNS_fraction = 0.000755 + CNS_fraction; // Arieli et all.(2002): Modeling pulmonary and CNS O2 toxicity... Formula (A1) based on value for 1.55 and c=20
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2886 else if (char_I_actual_ppO2 < 170)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2887 CNS_fraction = 0.00102 + CNS_fraction; // example calculation: Sqrt((1.7/1.55)^20)*0.000404
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2888 else if (char_I_actual_ppO2 < 175)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2889 CNS_fraction = 0.00136 + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2890 else if (char_I_actual_ppO2 < 180)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2891 CNS_fraction = 0.00180 + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2892 else if (char_I_actual_ppO2 < 185)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2893 CNS_fraction = 0.00237 + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2894 else if (char_I_actual_ppO2 < 190)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2895 CNS_fraction = 0.00310 + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2896 else if (char_I_actual_ppO2 < 195)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2897 CNS_fraction = 0.00401 + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2898 else if (char_I_actual_ppO2 < 200)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2899 CNS_fraction = 0.00517 + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2900 else if (char_I_actual_ppO2 < 230)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2901 CNS_fraction = 0.0209 + CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2902 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2903 CNS_fraction = 0.0482 + CNS_fraction; // value for 2.5
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2904
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2905 if (CNS_fraction > 2.5)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2906 CNS_fraction = 2.5;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2907 if (CNS_fraction < 0.0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2908 CNS_fraction = 0.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2909 char_O_CNS_fraction = (char)((CNS_fraction + 0.005)* 100.0);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2910 } // void calc_CNS_fraction(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2911
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2912 // --------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2913 // calc_CNS_decrease_15min //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2914 // --------------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2915 // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2916
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2917 // calculates the half time of 90 minutes in 6 steps of 15 min
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2918
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2919 // Output: char_O_CNS_fraction
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2920 // Uses and Updates: CNS_fraction
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2921
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2922 void calc_CNS_decrease_15min(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2923 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2924 CNS_fraction = 0.890899 * CNS_fraction;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2925 char_O_CNS_fraction = (char)((CNS_fraction + 0.005)* 100.0);
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2926 }// calc_CNS_decrease_15min(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2927
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2928
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2929 // ------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2930 // calc_percentage //
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2931 // ------------------
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2932 // new in v.101
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2933
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2934 // calculates int_I_temp * char_I_temp / 100
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2935 // output is int_I_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2936
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2937 void calc_percentage(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2938 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2939 temp1 = (float)int_I_temp;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2940 temp2 = (float)char_I_temp / 100.0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2941 temp3 = temp1 * temp2;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2942 int_I_temp = (int)temp3;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2943 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2944 void push_tissues_to_vault(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2945 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2946 for (ci=0;ci<32;ci++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2947 pres_tissue_vault[ci] = pres_tissue[ci];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2948 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2949 void pull_tissues_from_vault(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2950 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2951 for (ci=0;ci<32;ci++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2952 pres_tissue[ci] = pres_tissue_vault[ci];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2953 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2954
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2955 void wp_write_command(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2956 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2957 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2958 bcf oled_rs
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2959 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2960 movff wp_command,PORTD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2961 bcf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2962 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2963 bsf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2964 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2965 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2966
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2967 void wp_write_data(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2968 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2969 wp_data_8bit_one = wp_data_16bit >> 8;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2970 wp_data_8bit_two = wp_data_16bit;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2971 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2972 bsf oled_rs
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2973 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2974 movff wp_data_8bit_one,PORTD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2975 bcf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2976 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2977 bsf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2978 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2979 movff wp_data_8bit_two,PORTD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2980 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2981 bcf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2982 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2983 bsf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2984 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2985 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2986
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2987 void wp_write_black(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2988 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2989 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2990 movff wp_black,PORTD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2991 bcf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2992 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2993 bsf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2994 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2995 bcf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2996 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2997 bsf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2998 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
2999 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3001 void wp_write_color(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3002 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3003 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3004 movff wp_color1,PORTD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3005 bcf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3006 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3007 bsf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3008 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3009 movff wp_color2,PORTD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3010 bcf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3011 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3012 bsf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3013 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3014 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3015
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3016 void wp_set_window(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3017 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3018 // x axis start ( 0 - 319)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3019 wp_command = 0x35;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3020 wp_write_command();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3021 wp_data_16bit = ((U16)wp_leftx2) << 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3022 wp_write_data();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3023 // x axis end ( 0 - 319)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3024 wp_command = 0x36;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3025 wp_write_command();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3026 wp_data_16bit = 319;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3027 wp_write_data();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3028 // y axis start + end ( 0 - 239 )
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3029 wp_command = 0x37;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3030 wp_write_command();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3031 // the bottom part
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3032 wp_data_16bit = wp_top;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3033 if(wp_font == 2)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3034 wp_data_16bit += WP_FONT_LARGE_HEIGHT;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3035 else if(wp_font == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3036 wp_data_16bit += WP_FONT_MEDIUM_HEIGHT;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3037 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3038 wp_data_16bit += WP_FONT_SMALL_HEIGHT;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3039 wp_data_16bit--;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3040 if(wp_data_16bit > 239)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3041 wp_data_16bit = 239;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3042 // the top part
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3043 wp_data_16bit |= ((U16)wp_top) << 8;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3044 // all together in one 16bit transfer
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3045 wp_write_data();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3046
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3047 // start
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3048 wp_command = 0x20;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3049 wp_write_command();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3050 wp_data_16bit = wp_top;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3051 wp_write_data();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3052
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3053 wp_command = 0x21;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3054 wp_write_command();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3055 wp_data_16bit = ((U16)wp_leftx2) << 1;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3056 wp_write_data();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3057 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3058
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3059 void wp_set_char_font_small(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3060 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3061 if(wp_char == ' ')
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3062 wp_char = '¶';
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3063
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3064 if (wp_char > 0x7E) // skip space between ~ and ¡
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3065 wp_char -= 34;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3066
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3067 if((wp_char < '!') || (wp_char > 0xA1)) // font has 34 chars after ~ // ¾ + 4 chars limit to end of battery at the moment
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3068 wp_char = 0x82; // ¤
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3069
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3070 wp_start = wp_small_table[wp_char - '!'];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3071 wp_end = wp_small_table[1 + wp_char - '!'];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3072 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3073
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3074 void wp_set_char_font_medium(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3075 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3076 // space is 3E
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3077 if (wp_char == 0x27) // 0x27 == '
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3078 wp_char = 0x3B;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3079 if (wp_char == '"')
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3080 wp_char = 0x3C;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3081 if (wp_char == 'm')
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3082 wp_char = 0x3D;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3083 if (wp_char == ' ')
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3084 wp_char = 0x3E;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3085
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3086 if((wp_char < '.') || (wp_char > 0x3E))
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3087 wp_char = 0x3E;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3088 wp_start = wp_medium_table[wp_char - '.'];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3089 wp_end = wp_medium_table[1 + wp_char - '.'];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3090 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3091
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3092 void wp_set_char_font_large(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3093 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3094 // space is / = 0x2F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3095 if (wp_char == ' ')
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3096 wp_char = 0x2F;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3097
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3098 if((wp_char < '.') || (wp_char > '9'))
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3099 wp_char = 0x2F;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3100 wp_start = wp_large_table[wp_char - '.'];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3101 wp_end = wp_large_table[1 + wp_char - '.'];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3102 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3103
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3104 void wordprocessor(void)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3105 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3106 wp_set_window();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3107
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3108 // access to GRAM
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3109 wp_command = 0x22;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3110 wp_write_command();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3111 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3112 bsf oled_rs
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3113 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3114 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3115
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3116 wp_txtptr = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3117 wp_char = wp_stringstore[wp_txtptr];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3118
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3119 while(wp_char)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3120 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3121 if(wp_font == 2)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3122 wp_set_char_font_large();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3123 else if(wp_font == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3124 wp_set_char_font_medium();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3125 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3126 wp_set_char_font_small();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3127
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3128 wp_black = 0;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3129
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3130 for(wp_i = wp_start; wp_i<wp_end;wp_i++)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3131 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3132 if(wp_font == 2)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3133 wp_data_16bit = wp_large_data[wp_i / 2];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3134 else if(wp_font == 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3135 wp_data_16bit = wp_medium_data[wp_i / 2];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3136 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3137 wp_data_16bit = wp_small_data[wp_i / 2];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3138 if(wp_i & 1)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3139 wp_temp_U8 = wp_data_16bit & 0xFF;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3140 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3141 wp_temp_U8 = wp_data_16bit >> 8;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3142 if((wp_temp_U8 & 128))
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3143 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3144 wp_temp_U8 -= 127;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3145 if(wp_invert)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3146 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3147 while(wp_temp_U8 > 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3148 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3149 wp_temp_U8--;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3150 wp_write_color();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3151 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3152 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3153 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3154 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3155 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3156 movff wp_black,PORTD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3157 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3158 while(wp_temp_U8 > 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3159 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3160 wp_temp_U8--;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3161 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3162 bcf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3163 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3164 bsf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3165 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3166 bcf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3167 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3168 bsf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3169 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3170 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3171 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3172 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3173 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3174 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3175 wp_temp_U8++;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3176 if(wp_invert)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3177 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3178 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3179 movff wp_black,PORTD
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3180 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3181 while(wp_temp_U8 > 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3182 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3183 wp_temp_U8--;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3184 _asm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3185 bcf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3186 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3187 bsf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3188 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3189 bcf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3190 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3191 bsf oled_rw
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3192 _endasm
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3193 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3194 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3195 else
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3196 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3197 while(wp_temp_U8 > 0)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3198 {
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3199 wp_temp_U8--;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3200 wp_write_color();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3201 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3202 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3203 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3204 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3205 wp_txtptr++;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3206 wp_char = wp_stringstore[wp_txtptr];
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3207 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3208 wp_command = 0x00;
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3209 wp_write_command();
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3210 }
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
3211