comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 163:144822282fa3

Fusion declaration of shared C/ASM variables. + remove unused variables. + sort all in variables in BANK3, and out variables in BANK2.
author JeanDo
date Fri, 21 Jan 2011 01:44:37 +0100
parents ed275788a291
children 999abb01c78f
comparison
equal deleted inserted replaced
162:fdebc43c8372 163:144822282fa3
61 // 10/14/08 v104: integration of temp_depth_last_deco for Gradient Model 61 // 10/14/08 v104: integration of temp_depth_last_deco for Gradient Model
62 // 03/31/09 v107: integration of FONT Incon24 62 // 03/31/09 v107: integration of FONT Incon24
63 // 05/23/10 v109: 5 gas changes & 1 min timer 63 // 05/23/10 v109: 5 gas changes & 1 min timer
64 // 07/13/10 v110: cns vault added 64 // 07/13/10 v110: cns vault added
65 // 12/25/10 v110: split in three files (deco.c, main.c, definitions.h) 65 // 12/25/10 v110: split in three files (deco.c, main.c, definitions.h)
66 // 2011/01/20: [jDG] Create a common file included in ASM and C code.
66 // 67 //
67 // 68 //
68 // literature: 69 // literature:
69 // B"uhlmann, Albert: Tauchmedizin; 4. Auflage; 70 // B"uhlmann, Albert: Tauchmedizin; 4. Auflage;
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 71 // 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
83 84
84 // *********************************************** 85 // ***********************************************
85 // ** V A R I A B L E S D E F I N I T I O N S ** 86 // ** V A R I A B L E S D E F I N I T I O N S **
86 // *********************************************** 87 // ***********************************************
87 88
88 89 #include "../OSTC_code_c_part2/shared_definitions.h"
89 #pragma udata bank2a=0x200 90
90 // output: 91 //---- Bank 3 parameters -----------------------------------------------------
91 unsigned int int_O_tissue_for_debug[32]; 92 #pragma udata bank4=0x400
92 unsigned int int_O_GF_spare____; // 0x240 93
93 unsigned int int_O_GF_step; // 0x242
94 unsigned int int_O_gtissue_limit; // 0x244
95 unsigned int int_O_gtissue_press; // 0x246
96 unsigned int int_O_limit_GF_low; // 0x248
97 unsigned int int_O_gtissue_press_at_GF_low; // 0x24A
98 unsigned char char_I_step_is_1min; // 0x24C
99
100 // ...
101 #pragma udata bank2b=0x24E
102 unsigned char char_O_GF_low_pointer; // 0x24E
103 unsigned char char_O_actual_pointer; // 0x24F
104
105 #pragma udata bank2c=0x250
106 unsigned char char_O_deco_table[32]; // 0x250
107
108 #pragma udata bank2d=0x270
109 unsigned char char_I_table_deco_done[32];
110
111 #pragma udata bank2e=0x290
112 unsigned int int_O_calc_tissue_call_counter; // 0x290
113
114 // internal:
115 static unsigned char lock_GF_depth_list; 94 static unsigned char lock_GF_depth_list;
116 static float temp_limit; 95 static float temp_limit;
117 static float GF_low; 96 static float GF_low;
118 static float GF_high; 97 static float GF_high;
119 static float GF_delta; 98 static float GF_delta;
131 110
132 static unsigned char temp_depth_GF_low_meter; 111 static unsigned char temp_depth_GF_low_meter;
133 static unsigned char temp_depth_GF_low_number; 112 static unsigned char temp_depth_GF_low_number;
134 static unsigned char internal_deco_pointer; 113 static unsigned char internal_deco_pointer;
135 114
136 #pragma udata bank2f=0x2C8
137 static unsigned char internal_deco_table[32]; // 0x2C8 115 static unsigned char internal_deco_table[32]; // 0x2C8
138 static float temp_pres_deco_GF_low; 116 static float temp_pres_deco_GF_low;
139 117
140 #pragma udata bank3a=0x300
141 static char output[32]; // used by the math routines 118 static char output[32]; // used by the math routines
142 119
143 #pragma udata bank3b=0x37C
144 static float cns_vault; 120 static float cns_vault;
145 121
146 #pragma udata bank3c=0x380
147 static float pres_tissue_vault[32]; 122 static float pres_tissue_vault[32];
148 123
149 #pragma udata bank4a=0x400 124 //---- Bank 5 parameters -----------------------------------------------------
150 // internal: 125 #pragma udata bank5=0x500
126
151 static unsigned char ci ; // don't move - used in _asm routines - if moved then modify movlb commands 127 static unsigned char ci ; // don't move - used in _asm routines - if moved then modify movlb commands
152 static unsigned char x; 128 static unsigned char x;
153 static unsigned int main_i_dummy; 129 static unsigned int main_i_dummy;
154 static unsigned int int_temp; 130 static unsigned int int_temp;
155 static unsigned int int_temp2; 131 static unsigned int int_temp2;
182 static float var2_halftimes; 158 static float var2_halftimes;
183 static float pres_gtissue_limit; 159 static float pres_gtissue_limit;
184 static float temp_pres_gtissue_limit; 160 static float temp_pres_gtissue_limit;
185 static float actual_ppO2; // new in v.102 161 static float actual_ppO2; // new in v.102
186 162
187 #pragma udata bank4b=0x480
188 static float pres_tissue[32]; 163 static float pres_tissue[32];
189 164
190 #pragma udata bank5=0x500 165 //---- Bank 6 parameters -----------------------------------------------------
191 // don't move positions in this bank, the registers are addressed directly from assembler code 166 #pragma udata bank6=0x600
192 // input: 167
193 unsigned int int_I_pres_respiration; // 0x500
194 unsigned int int_I_pres_surface; // 0x502
195 unsigned int int_I_temp; // 0x504 new in v101
196 unsigned char char_I_temp; // 0x506 new in v101
197 unsigned char char_I_actual_ppO2; // 0x507
198 unsigned char char_I_deco_N2_ratio2; // 0x508 new in v.109
199 unsigned char char_I_deco_He_ratio2; // 0x509 new in v.109
200 unsigned char char_I_deco_N2_ratio3; // 0x50A new in v.109
201 unsigned char char_I_deco_He_ratio3; // 0x50B new in v.109
202 unsigned char char_I_deco_N2_ratio4; // 0x50C new in v.109
203 unsigned char char_I_deco_He_ratio4; // 0x50D new in v.109
204 unsigned char char_I_deco_N2_ratio5; // 0x50E new in v.109
205 unsigned char char_I_deco_He_ratio5; // 0x50F new in v.109
206 unsigned char char_I_N2_ratio; // 0x510
207 unsigned char char_I_He_ratio; // 0x511
208 unsigned char char_I_saturation_multiplier; // for conservatism/safety values 1.0 (no conservatism) to 1.5 (50% faster saturation
209 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()
210 unsigned char char_I_GF_High_percentage; // 0x514 new in v.102
211 unsigned char char_I_GF_Low_percentage; // 0x515 new in v.102
212 unsigned char char_I_spare; // 0x516
213 unsigned char char_I_deco_distance; // 0x517
214 unsigned char char_I_const_ppO2; // 0x518 new in v.101
215 unsigned char char_I_deco_ppO2_change; // 0x519 new in v.101
216 unsigned char char_I_deco_ppO2; // 0x51A new in v.101
217 unsigned char char_I_deco_gas_change; // 0x51B new in v.101
218 unsigned char char_I_deco_N2_ratio; // 0x51C new in v.101
219 unsigned char char_I_deco_He_ratio; // 0x51D new in v.101
220 unsigned char char_I_depth_last_deco; // 0x51E new in v.101 unit: [m]
221 unsigned char char_I_deco_model; // 0x51F new in v.102 ( 1 = MultiGraF, sonst Std. mit (de-)saturation_multiplier)
222
223 // output:
224 unsigned int int_O_desaturation_time; // 0x520
225 unsigned char char_O_nullzeit; // 0x522
226 unsigned char char_O_deco_status; // 0x523
227 unsigned char char_O_array_decotime[7]; // 0x524
228 unsigned char char_O_array_decodepth[6]; // 0x52B
229 unsigned char char_O_ascenttime; // 0x531
230 unsigned char char_O_gradient_factor; // 0x532
231 unsigned char char_O_tissue_saturation[32]; // 0x533
232 unsigned char char_O_array_gradient_weighted[16]; // 0x553
233 unsigned char char_O_gtissue_no; // 0x563
234 unsigned char char_O_diluent; // 0x564 new in v.101
235 unsigned char char_O_CNS_fraction; // 0x565 new in v.101
236 unsigned char char_O_relative_gradient_GF; // 0x566 new in v.102
237 unsigned char char_I_deco_gas_change2; // 0x567 new in v.109
238 unsigned char char_I_deco_gas_change3; // 0x568 new in v.109
239 unsigned char char_I_deco_gas_change4; // 0x569 new in v.109
240 unsigned char char_I_deco_gas_change5; // 0x56A new in v.109
241
242 // internal:
243 static float pres_tissue_limit[16]; 168 static float pres_tissue_limit[16];
244 static float sim_pres_tissue_limit[16]; 169 static float sim_pres_tissue_limit[16];
245 static float pres_diluent; // new in v.101 170 static float pres_diluent; // new in v.101
246 static float deco_diluent; // new in v.101 171 static float deco_diluent; // new in v.101
247 static float const_ppO2; // new in v.101 172 static float const_ppO2; // new in v.101
248 static float deco_ppO2_change; // new in v.101 173 static float deco_ppO2_change; // new in v.101
249 static float deco_ppO2; // new in v.101 174 static float deco_ppO2; // new in v.101
250 175
251 #pragma udata bank6=0x600 176 //---- Bank 7 parameters -----------------------------------------------------
252 // internal: 177 #pragma udata bank7=0x700
253 static float sim_pres_tissue[32]; 178
179 static float sim_pres_tissue[32]; // 32 floats = 128 bytes.
254 static float sim_pres_tissue_backup[32]; 180 static float sim_pres_tissue_backup[32];
255 181
182 //---- Bank 8 parameters -----------------------------------------------------
256 #pragma udata bank8=0x800 183 #pragma udata bank8=0x800
184
257 static char md_pi_subst[256]; 185 static char md_pi_subst[256];
258 #define C_STACK md_pi_subst // Overlay C-code data stack here, too. 186 #define C_STACK md_pi_subst // Overlay C-code data stack here, too.
259 187
188 //---- Bank 9 parameters -----------------------------------------------------
260 #pragma udata bank9a=0x900 189 #pragma udata bank9a=0x900
261 // output: 190
262 static char md_state[48]; // DONT MOVE !! // has to be at the beginning of bank 9 for the asm code!!! 191 static char md_state[48]; // DONT MOVE !! // has to be at the beginning of bank 9 for the asm code!!!
263
264 #pragma udata bank9b=0x930
265 // output:
266 unsigned int int_O_DBS_bitfield; // 0x930 new in v.108
267 unsigned int int_O_DBS2_bitfield; // 0x932 new in v.108
268 unsigned int int_O_DBG_pre_bitfield; // 0x934 new in v.108
269 unsigned int int_O_DBG_post_bitfield; // 0x936 new in v.108
270 unsigned char char_O_NDL_at_20mtr; // 0x938 new in v.108 // 0xFF == undefined, max. 254
271 192
272 // internal: 193 // internal:
273 static char md_t; 194 static char md_t;
274 static char md_buffer[16]; 195 static char md_buffer[16];
275 static char md_cksum[16]; 196 static char md_cksum[16];
1919 { 1840 {
1920 char_O_relative_gradient_GF = char_O_gradient_factor; 1841 char_O_relative_gradient_GF = char_O_gradient_factor;
1921 } 1842 }
1922 } // calc_gradient 1843 } // calc_gradient
1923 1844
1924 // ---------------------------
1925 // deco_gradient_array //
1926 // ---------------------------
1927 // optimized in v.101 (var_a)
1928 // new code in v.102
1929
1930 void deco_gradient_array()
1931 {
1932 RESET_C_STACK
1933 pres_respiration = (float)int_I_pres_respiration / 1000.0; // assembler code uses different digit system
1934 for (ci=0;ci<16;ci++)
1935 {
1936 temp_tissue = pres_tissue[ci] + pres_tissue[ci+16];
1937 temp1 = temp_tissue - pres_respiration;
1938 temp2 = temp_tissue - pres_tissue_limit[ci];
1939 temp2 = temp1/temp2;
1940 temp2 = temp2 * 200; // because of output in (Double-)percentage
1941 if (temp2 < 0)
1942 temp2 = 0;
1943 if (temp2 > 255)
1944 temp2 = 255;
1945 if (temp1 < 0)
1946 char_O_array_gradient_weighted[ci] = 0;
1947 else
1948 char_O_array_gradient_weighted[ci] = (char)temp2;
1949 } // for
1950 } // deco_gradient_array
1951
1952
1953 // ------------------------------ 1845 // ------------------------------
1954 // deco_calc_desaturation_time // 1846 // deco_calc_desaturation_time //
1955 // ------------------------------ 1847 // ------------------------------
1956 // FIXED N2_ratio 1848 // FIXED N2_ratio
1957 // unchanged in v.101 1849 // unchanged in v.101
2215 if (pres_tissue_limit[ci] > pres_gtissue_limit) 2107 if (pres_tissue_limit[ci] > pres_gtissue_limit)
2216 { 2108 {
2217 pres_gtissue_limit = pres_tissue_limit[ci]; 2109 pres_gtissue_limit = pres_tissue_limit[ci];
2218 char_O_gtissue_no = ci; 2110 char_O_gtissue_no = ci;
2219 }//if 2111 }//if
2220
2221 if(!char_I_step_is_1min)
2222 {
2223 // gradient factor array for graphical display
2224 // display range is 0 to 250! in steps of 5 for 1 pixel
2225 // the display is divided in 6 blocks
2226 // -> double the gradient 100% = 200
2227 // tissue > respiration (entsaettigungsvorgang)
2228 // gradient ist wieviel prozent an limit von tissue aus
2229 // dh. 0% = respiration == tissue
2230 // dh. 100% = respiration == limit
2231 temp1 = temp_tissue - pres_respiration;
2232 temp2 = temp_tissue - pres_tissue_limit[ci]; // changed in v.102
2233 temp2 = temp1/temp2;
2234 temp2 = temp2 * 200; // because of output in (Double-)percentage
2235 if (temp2 < 0)
2236 temp2 = 0;
2237 if (temp2 > 255)
2238 temp2 = 255;
2239 if (temp1 < 0)
2240 char_O_array_gradient_weighted[ci] = 0;
2241 else
2242 char_O_array_gradient_weighted[ci] = (char)temp2;
2243 }
2244 } // for 2112 } // for
2245 } // calc wo deco 1min 2113 } // calc wo deco 1min
2246 2114
2247 // ---------- 2115 // ----------
2248 // deco_hash // 2116 // deco_hash //