annotate code_part1/OSTC_code_c_part2/p2_deco_main - 090915b.c @ 13:3b30cd739782

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