annotate code_part1/OSTC_code_c_part2/p2_deco_main - 090915a.c @ 60:3691ea95a34d

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