comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 339:cb77d1fa4535

More cleanups in internal deco structures.
author JeanDo
date Wed, 18 May 2011 02:01:52 +0200
parents b75564fb3d4b
children ecbbbd423e86
comparison
equal deleted inserted replaced
338:b75564fb3d4b 339:cb77d1fa4535
166 166
167 static unsigned char internal_deco_time[NUM_STOPS]; 167 static unsigned char internal_deco_time[NUM_STOPS];
168 static unsigned char internal_deco_depth[NUM_STOPS]; 168 static unsigned char internal_deco_depth[NUM_STOPS];
169 169
170 static float cns_vault; 170 static float cns_vault;
171 static float pres_tissue_vault[2*NUM_COMP]; 171 static float pres_tissue_N2_vault[NUM_COMP];
172 static float pres_tissue_He_vault[NUM_COMP];
172 173
173 //---- Bank 5 parameters ----------------------------------------------------- 174 //---- Bank 5 parameters -----------------------------------------------------
174 #pragma udata bank5=0x500 175 #pragma udata bank5=0x500
175 176
176 static unsigned char ci; 177 static unsigned char ci;
207 static unsigned char deco_gas_change[NUM_GAS]; // new in v.109 208 static unsigned char deco_gas_change[NUM_GAS]; // new in v.109
208 209
209 //---- Bank 6 parameters ----------------------------------------------------- 210 //---- Bank 6 parameters -----------------------------------------------------
210 #pragma udata bank6=0x600 211 #pragma udata bank6=0x600
211 212
212 float pres_tissue[2*NUM_COMP]; 213 float pres_tissue_N2[NUM_COMP];
214 float pres_tissue_He[NUM_COMP];
213 215
214 //---- Bank 7 parameters ----------------------------------------------------- 216 //---- Bank 7 parameters -----------------------------------------------------
215 #pragma udata bank7=0x700 217 #pragma udata bank7=0x700
216 218
217 float sim_pres_tissue[2*NUM_COMP]; // 32 floats = 128 bytes. 219 float sim_pres_tissue_N2[NUM_COMP]; // 32 floats = 128 bytes.
218 static float sim_pres_tissue_backup[2*NUM_COMP]; 220 float sim_pres_tissue_He[NUM_COMP]; // 32 floats = 128 bytes.
221 static float sim_pres_tissue_backup_N2[NUM_COMP];
222 static float sim_pres_tissue_backup_He[NUM_COMP];
219 223
220 //---- Bank 8 parameters ----------------------------------------------------- 224 //---- Bank 8 parameters -----------------------------------------------------
221 #pragma udata bank8=0x800 225 #pragma udata bank8=0x800
222 226
223 static char md_pi_subst[256]; 227 static char md_pi_subst[256];
327 //---- Setup some error (?) conditions ----------------------------------- 331 //---- Setup some error (?) conditions -----------------------------------
328 if(char_I_deco_model) 332 if(char_I_deco_model)
329 int_O_DBS_bitfield |= DBS_mode; 333 int_O_DBS_bitfield |= DBS_mode;
330 if(const_ppO2) 334 if(const_ppO2)
331 int_O_DBS_bitfield |= DBS_ppO2; 335 int_O_DBS_bitfield |= DBS_ppO2;
332 for(i = NUM_COMP; i < 2*NUM_COMP; i++) 336 for(i = 0; i < NUM_COMP; i++)
333 if(pres_tissue[i]) 337 if(pres_tissue_He[i])
334 int_O_DBS_bitfield |= DBS_HE_sat; 338 int_O_DBS_bitfield |= DBS_HE_sat;
335 if(float_saturation_multiplier < 0.99) 339 if(float_saturation_multiplier < 0.99)
336 int_O_DBS_bitfield |= DBS_SAT2l; 340 int_O_DBS_bitfield |= DBS_SAT2l;
337 if(float_saturation_multiplier > 1.3) 341 if(float_saturation_multiplier > 1.3)
338 int_O_DBS_bitfield |= DBS_SAT2h; 342 int_O_DBS_bitfield |= DBS_SAT2h;
416 temp_DBS |= DBG_C_MODE; 420 temp_DBS |= DBG_C_MODE;
417 if(DBG_pres_surface != pres_surface) 421 if(DBG_pres_surface != pres_surface)
418 temp_DBS |= DBG_C_SURF; 422 temp_DBS |= DBG_C_SURF;
419 423
420 if( !DBS_HE_sat && !He_ratio) 424 if( !DBS_HE_sat && !He_ratio)
421 for(i = NUM_COMP; i < 2*NUM_COMP; i++) 425 for(i = 0; i < NUM_COMP; i++)
422 if(pres_tissue[i]) 426 if(pres_tissue_He[i])
423 temp_DBS |= DBG_HEwoHE; 427 temp_DBS |= DBG_HEwoHE;
424 428
425 if( DBG_deco_gas_change != deco_gas_change[0] 429 if( DBG_deco_gas_change != deco_gas_change[0]
426 || DBG_deco_N2_ratio != char_I_deco_N2_ratio[0] 430 || DBG_deco_N2_ratio != char_I_deco_N2_ratio[0]
427 || DBG_deco_He_ratio != char_I_deco_He_ratio[0] ) 431 || DBG_deco_He_ratio != char_I_deco_He_ratio[0] )
849 if( read_custom_function(54) & 1 ) //---- Should we reverse table ? ------ 853 if( read_custom_function(54) & 1 ) //---- Should we reverse table ? ------
850 { 854 {
851 overlay unsigned char x, y; 855 overlay unsigned char x, y;
852 856
853 //---- First: search the first non-null depth 857 //---- First: search the first non-null depth
854 for(x=31; x != 0; --x) 858 for(x=(NUM_STOPS-1); x != 0; --x)
855 if( internal_deco_depth[x] != 0 ) break; 859 if( internal_deco_depth[x] != 0 ) break;
856 860
857 //---- Second: copy to output table (in reverse order) 861 //---- Second: copy to output table (in reverse order)
858 for(y=0; y<NUM_STOPS; y++, --x) 862 for(y=0; y<NUM_STOPS; y++, --x)
859 { 863 {
863 // Stop only once the last transfer is done. 867 // Stop only once the last transfer is done.
864 if( x == 0 ) break; 868 if( x == 0 ) break;
865 } 869 }
866 870
867 //---- Third: fill table end with null 871 //---- Third: fill table end with null
868 for(y++; y<2*NUM_COMP; y++) 872 for(y++; y<NUM_STOPS; y++)
869 { 873 {
870 char_O_deco_time [y] = 0; 874 char_O_deco_time [y] = 0;
871 char_O_deco_depth[y] = 0; 875 char_O_deco_depth[y] = 0;
872 } 876 }
873 } 877 }
874 else //---- Straight copy ------------------------------------------------ 878 else //---- Straight copy ------------------------------------------------
875 { 879 {
876 overlay unsigned char x; 880 overlay unsigned char x;
877 881
878 for(x=0; x<2*NUM_COMP; x++) 882 for(x=0; x<NUM_STOPS; x++)
879 { 883 {
880 char_O_deco_depth[x] = internal_deco_depth[x]; 884 char_O_deco_depth[x] = internal_deco_depth[x];
881 char_O_deco_time [x] = internal_deco_time [x]; 885 char_O_deco_time [x] = internal_deco_time [x];
882 } 886 }
883 } 887 }
1197 1201
1198 for(ci=0; ci<NUM_COMP; ci++) 1202 for(ci=0; ci<NUM_COMP; ci++)
1199 { 1203 {
1200 // cycle through the 16 Bühlmann tissues 1204 // cycle through the 16 Bühlmann tissues
1201 overlay float p = N2_ratio * (pres_respiration - ppWater); 1205 overlay float p = N2_ratio * (pres_respiration - ppWater);
1202 pres_tissue[ci] = p; 1206 pres_tissue_N2[ci] = p;
1203 1207
1204 // cycle through the 16 Bühlmann tissues for Helium 1208 // cycle through the 16 Bühlmann tissues for Helium
1205 (pres_tissue+NUM_COMP)[ci] = 0.0; 1209 pres_tissue_He[ci] = 0.0;
1206 } // for 0 to 15 1210 } // for 0 to 15
1207 1211
1208 clear_deco_table(); 1212 clear_deco_table();
1209 char_O_deco_status = 0; 1213 char_O_deco_status = 0;
1210 char_O_nullzeit = 0; 1214 char_O_nullzeit = 0;
1462 1466
1463 // Calc limit for surface, ie. GF_high. 1467 // Calc limit for surface, ie. GF_high.
1464 calc_limit(); 1468 calc_limit();
1465 1469
1466 int_O_gtissue_limit = (short)(calc_lead_tissue_limit * 1000); 1470 int_O_gtissue_limit = (short)(calc_lead_tissue_limit * 1000);
1467 int_O_gtissue_press = (short)((pres_tissue[char_O_gtissue_no] + (pres_tissue+NUM_COMP)[char_O_gtissue_no]) * 1000); 1471 int_O_gtissue_press = (short)((pres_tissue_N2[char_O_gtissue_no] + pres_tissue_He[char_O_gtissue_no]) * 1000);
1468 1472
1469 // if guiding tissue can not be exposed to surface pressure immediately 1473 // if guiding tissue can not be exposed to surface pressure immediately
1470 if( calc_lead_tissue_limit > pres_surface && char_O_deco_status == 0) 1474 if( calc_lead_tissue_limit > pres_surface && char_O_deco_status == 0)
1471 { 1475 {
1472 char_O_nullzeit = 0; // deco necessary 1476 char_O_nullzeit = 0; // deco necessary
1637 for (ci=0;ci<NUM_COMP;ci++) 1641 for (ci=0;ci<NUM_COMP;ci++)
1638 { 1642 {
1639 read_buhlmann_times(period); // 2 sec or 1 min period. 1643 read_buhlmann_times(period); // 2 sec or 1 min period.
1640 1644
1641 // N2 1645 // N2
1642 temp_tissue = (ppN2 - pres_tissue[ci]) * var_N2_e; 1646 temp_tissue = (ppN2 - pres_tissue_N2[ci]) * var_N2_e;
1643 temp_tissue_safety(); 1647 temp_tissue_safety();
1644 pres_tissue[ci] += temp_tissue; 1648 pres_tissue_N2[ci] += temp_tissue;
1645 1649
1646 // He 1650 // He
1647 temp_tissue = (ppHe - (pres_tissue+NUM_COMP)[ci]) * var_He_e; 1651 temp_tissue = (ppHe - pres_tissue_He[ci]) * var_He_e;
1648 temp_tissue_safety(); 1652 temp_tissue_safety();
1649 (pres_tissue+NUM_COMP)[ci] += temp_tissue; 1653 pres_tissue_He[ci] += temp_tissue;
1650 } 1654 }
1651 } 1655 }
1652 1656
1653 ////////////////////////////////////////////////////////////////////////////// 1657 //////////////////////////////////////////////////////////////////////////////
1654 // calc_limit 1658 // calc_limit
1660 char_O_gtissue_no = 255; 1664 char_O_gtissue_no = 255;
1661 calc_lead_tissue_limit = 0.0; 1665 calc_lead_tissue_limit = 0.0;
1662 1666
1663 for(ci=0; ci<NUM_COMP;ci++) 1667 for(ci=0; ci<NUM_COMP;ci++)
1664 { 1668 {
1665 overlay float N2 = pres_tissue[ci]; 1669 overlay float N2 = pres_tissue_N2[ci];
1666 overlay float He = (pres_tissue+NUM_COMP)[ci]; 1670 overlay float He = pres_tissue_He[ci];
1667 overlay float p = N2 + He; 1671 overlay float p = N2 + He;
1668 1672
1669 read_buhlmann_coefficients(); 1673 read_buhlmann_coefficients();
1670 var_N2_a = (var_N2_a * N2 + var_He_a * He) / p; 1674 var_N2_a = (var_N2_a * N2 + var_He_a * He) / p;
1671 var_N2_b = (var_N2_b * N2 + var_He_b * He) / p; 1675 var_N2_b = (var_N2_b * N2 + var_He_b * He) / p;
1744 // 1748 //
1745 void backup_sim_pres_tissue(void) 1749 void backup_sim_pres_tissue(void)
1746 { 1750 {
1747 overlay unsigned char x; 1751 overlay unsigned char x;
1748 1752
1749 for(x = 0; x<2*NUM_COMP; x++) 1753 for(x=0; x<NUM_COMP; x++)
1750 sim_pres_tissue_backup[x] = sim_pres_tissue[x]; 1754 {
1755 sim_pres_tissue_backup_N2[x] = sim_pres_tissue_N2[x];
1756 sim_pres_tissue_backup_He[x] = sim_pres_tissue_He[x];
1757 }
1751 } 1758 }
1752 1759
1753 ////////////////////////////////////////////////////////////////////////////// 1760 //////////////////////////////////////////////////////////////////////////////
1754 // restore_sim_pres_tissue 1761 // restore_sim_pres_tissue
1755 // 1762 //
1756 void restore_sim_pres_tissue(void) 1763 void restore_sim_pres_tissue(void)
1757 { 1764 {
1758 overlay unsigned char x; 1765 overlay unsigned char x;
1759 1766
1760 for(x = 0; x<2*NUM_COMP; x++) 1767 for(x=0; x<NUM_COMP; x++)
1761 sim_pres_tissue[x] = sim_pres_tissue_backup[x]; 1768 {
1769 sim_pres_tissue_N2[x] = sim_pres_tissue_backup_N2[x];
1770 sim_pres_tissue_He[x] = sim_pres_tissue_backup_He[x];
1771 }
1762 } 1772 }
1763 1773
1764 ////////////////////////////////////////////////////////////////////////////// 1774 //////////////////////////////////////////////////////////////////////////////
1765 // calc_ascenttime 1775 // calc_ascenttime
1766 // 1776 //
1796 void update_startvalues(void) 1806 void update_startvalues(void)
1797 { 1807 {
1798 overlay unsigned char x; 1808 overlay unsigned char x;
1799 1809
1800 // Start ascent simulation with current tissue partial pressures. 1810 // Start ascent simulation with current tissue partial pressures.
1801 for (x = 0;x<NUM_COMP;x++) 1811 for(x=0; x<NUM_COMP; x++)
1802 { 1812 {
1803 sim_pres_tissue[x] = pres_tissue[x]; 1813 sim_pres_tissue_N2[x] = pres_tissue_N2[x];
1804 (sim_pres_tissue+NUM_COMP)[x] = (pres_tissue+NUM_COMP)[x]; 1814 sim_pres_tissue_He[x] = pres_tissue_He[x];
1805 } 1815 }
1806 1816
1807 // No leading tissue (yet) for this ascent simulation. 1817 // No leading tissue (yet) for this ascent simulation.
1808 sim_lead_tissue_limit = 0.0; 1818 sim_lead_tissue_limit = 0.0;
1809 sim_lead_tissue_no = 255; 1819 sim_lead_tissue_no = 255;
1825 for(ci=0; ci<NUM_COMP; ci++) 1835 for(ci=0; ci<NUM_COMP; ci++)
1826 { 1836 {
1827 read_buhlmann_times(period); // 1 or 10 minute(s) interval 1837 read_buhlmann_times(period); // 1 or 10 minute(s) interval
1828 1838
1829 // N2 1839 // N2
1830 temp_tissue = (ppN2 - sim_pres_tissue[ci]) * var_N2_e; 1840 temp_tissue = (ppN2 - sim_pres_tissue_N2[ci]) * var_N2_e;
1831 temp_tissue_safety(); 1841 temp_tissue_safety();
1832 sim_pres_tissue[ci] += temp_tissue; 1842 sim_pres_tissue_N2[ci] += temp_tissue;
1833 1843
1834 // He 1844 // He
1835 temp_tissue = (ppHe - (sim_pres_tissue+NUM_COMP)[ci]) * var_He_e; 1845 temp_tissue = (ppHe - sim_pres_tissue_He[ci]) * var_He_e;
1836 temp_tissue_safety(); 1846 temp_tissue_safety();
1837 (sim_pres_tissue+NUM_COMP)[ci] += temp_tissue; 1847 sim_pres_tissue_He[ci] += temp_tissue;
1838 } 1848 }
1839 } 1849 }
1840 1850
1841 ////////////////////////////////////////////////////////////////////////////// 1851 //////////////////////////////////////////////////////////////////////////////
1842 // sim_limit() 1852 // sim_limit()
1853 sim_lead_tissue_limit = 0.0; 1863 sim_lead_tissue_limit = 0.0;
1854 sim_lead_tissue_no = 0; // If no one is critic, keep first tissue. 1864 sim_lead_tissue_no = 0; // If no one is critic, keep first tissue.
1855 1865
1856 for(ci=0; ci<NUM_COMP; ci++) 1866 for(ci=0; ci<NUM_COMP; ci++)
1857 { 1867 {
1858 overlay float N2 = sim_pres_tissue[ci]; 1868 overlay float N2 = sim_pres_tissue_N2[ci];
1859 overlay float He = (sim_pres_tissue+NUM_COMP)[ci]; 1869 overlay float He = sim_pres_tissue_He[ci];
1860 overlay float p = N2 + He; 1870 overlay float p = N2 + He;
1861 1871
1862 read_buhlmann_coefficients(); 1872 read_buhlmann_coefficients();
1863 var_N2_a = (var_N2_a * N2 + var_He_a * He) / p; 1873 var_N2_a = (var_N2_a * N2 + var_He_a * He) / p;
1864 var_N2_b = (var_N2_b * N2 + var_He_b * He) / p; 1874 var_N2_b = (var_N2_b * N2 + var_He_b * He) / p;
1958 // new code in v.102 1968 // new code in v.102
1959 // 1969 //
1960 static void calc_gradient_factor(void) 1970 static void calc_gradient_factor(void)
1961 { 1971 {
1962 overlay float gf; 1972 overlay float gf;
1963 overlay float N2 = pres_tissue[char_O_gtissue_no]; 1973 overlay float N2 = pres_tissue_N2[char_O_gtissue_no];
1964 overlay float He = (pres_tissue+NUM_COMP)[char_O_gtissue_no]; 1974 overlay float He = pres_tissue_He[char_O_gtissue_no];
1965 1975
1966 assert( char_O_gtissue_no < NUM_COMP ); 1976 assert( char_O_gtissue_no < NUM_COMP );
1967 assert( 0.800 <= pres_respiration && pres_respiration < 14.0 ); 1977 assert( 0.800 <= pres_respiration && pres_respiration < 14.0 );
1968 1978
1969 // tissue > respiration (currently off-gasing) 1979 // tissue > respiration (currently off-gasing)
2059 ppN2 = N2_ratio * (pres_surface - ppWater); 2069 ppN2 = N2_ratio * (pres_surface - ppWater);
2060 int_O_desaturation_time = 0; 2070 int_O_desaturation_time = 0;
2061 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142) 2071 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142)
2062 2072
2063 ptr = &buhlmann_ht[0]; 2073 ptr = &buhlmann_ht[0];
2064 for (ci=0;ci<NUM_COMP;ci++) 2074 for(ci=0; ci<NUM_COMP; ci++)
2065 { 2075 {
2066 overlay float var_N2_halftime = *ptr++; 2076 overlay float var_N2_halftime = *ptr++;
2067 overlay float var_He_halftime = *ptr++; 2077 overlay float var_He_halftime = *ptr++;
2068 overlay unsigned short desat_time; // For a particular compartiment, in min. 2078 overlay unsigned short desat_time; // For a particular compartiment, in min.
2069 overlay float temp1; 2079 overlay float temp1;
2077 // saturation_time (for flight) and N2_saturation in multiples of halftime 2087 // saturation_time (for flight) and N2_saturation in multiples of halftime
2078 // version v.100: 1.1 = 10 percent distance to totally clean (totally clean is not possible, would take infinite time ) 2088 // version v.100: 1.1 = 10 percent distance to totally clean (totally clean is not possible, would take infinite time )
2079 // new in version v.101: 1.07 = 7 percent distance to totally clean (totally clean is not possible, would take infinite time ) 2089 // new in version v.101: 1.07 = 7 percent distance to totally clean (totally clean is not possible, would take infinite time )
2080 // changes in v.101: 1.05 = 5 percent dist to totally clean is new desaturation point for display and NoFly calculations 2090 // changes in v.101: 1.05 = 5 percent dist to totally clean is new desaturation point for display and NoFly calculations
2081 // N2 2091 // N2
2082 temp1 = 1.05 * ppN2 - pres_tissue[ci]; 2092 temp1 = 1.05 * ppN2 - pres_tissue_N2[ci];
2083 temp2 = ppN2 - pres_tissue[ci]; 2093 temp2 = ppN2 - pres_tissue_N2[ci];
2084 if (temp2 >= 0.0) 2094 if (temp2 >= 0.0)
2085 { 2095 {
2086 temp1 = 0.0; 2096 temp1 = 0.0;
2087 temp2 = 0.0; 2097 temp2 = 0.0;
2088 } 2098 }
2101 temp1 = 0.0; 2111 temp1 = 0.0;
2102 temp2 = 0.0; 2112 temp2 = 0.0;
2103 } 2113 }
2104 2114
2105 // He 2115 // He
2106 temp3 = 0.1 - (pres_tissue+NUM_COMP)[ci]; 2116 temp3 = 0.1 - pres_tissue_He[ci];
2107 if (temp3 >= 0.0) 2117 if (temp3 >= 0.0)
2108 { 2118 {
2109 temp3 = 0.0; 2119 temp3 = 0.0;
2110 temp4 = 0.0; 2120 temp4 = 0.0;
2111 } 2121 }
2112 else 2122 else
2113 temp3 = - temp3 / (pres_tissue+NUM_COMP)[ci]; 2123 temp3 = - temp3 / pres_tissue_He[ci];
2114 if( 0.0 < temp3 && temp3 < 1.0 ) 2124 if( 0.0 < temp3 && temp3 < 1.0 )
2115 { 2125 {
2116 temp3 = log(1.0 - temp3) / -0.6931; // temp1 is the multiples of half times necessary. 2126 temp3 = log(1.0 - temp3) / -0.6931; // temp1 is the multiples of half times necessary.
2117 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested. 2127 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested.
2118 // minus because log is negative 2128 // minus because log is negative
2132 2142
2133 if(desat_time > int_O_desaturation_time) 2143 if(desat_time > int_O_desaturation_time)
2134 int_O_desaturation_time = desat_time; 2144 int_O_desaturation_time = desat_time;
2135 2145
2136 // N2 saturation in multiples of halftime for display purposes 2146 // N2 saturation in multiples of halftime for display purposes
2137 temp2 = temp1 * 20.0; // 0 = 1/8, 120 = 0, 249 = 8 2147 temp2 = temp1 * 20.0; // 0 = 1/8, 120 = 0, 249 = 8
2138 temp2 = temp2 + 80.0; // set center 2148 temp2 = temp2 + 80.0; // set center
2139 if (temp2 < 0.0) 2149 if (temp2 < 0.0)
2140 temp2 = 0.0; 2150 temp2 = 0.0;
2141 if (temp2 > 255.0) 2151 if (temp2 > 255.0)
2142 temp2 = 255.0; 2152 temp2 = 255.0;
2143 char_O_tissue_saturation[ci] = (char)temp2; 2153 char_O_tissue_N2_saturation[ci] = (char)temp2;
2144 2154
2145 // He saturation in multiples of halftime for display purposes 2155 // He saturation in multiples of halftime for display purposes
2146 temp4 = temp3 * 20.0; // 0 = 1/8, 120 = 0, 249 = 8 2156 temp4 = temp3 * 20.0; // 0 = 1/8, 120 = 0, 249 = 8
2147 temp4 = temp4 + 80.0; // set center 2157 temp4 = temp4 + 80.0; // set center
2148 if (temp4 < 0.0) 2158 if (temp4 < 0.0)
2149 temp4 = 0.0; 2159 temp4 = 0.0;
2150 if (temp4 > 255.0) 2160 if (temp4 > 255.0)
2151 temp4 = 255.0; 2161 temp4 = 255.0;
2152 (char_O_tissue_saturation+NUM_COMP)[ci] = (char)temp4; 2162 char_O_tissue_He_saturation[ci] = (char)temp4;
2153 } // for 2163 } // for
2154 } 2164 }
2155 2165
2156 ////////////////////////////////////////////////////////////////////////////// 2166 //////////////////////////////////////////////////////////////////////////////
2157 // calc_wo_deco_step_1_min 2167 // calc_wo_deco_step_1_min
2179 ppN2 = N2_ratio * (pres_respiration - ppWater); // ppWater is the extra pressure in the body 2189 ppN2 = N2_ratio * (pres_respiration - ppWater); // ppWater is the extra pressure in the body
2180 ppHe = 0.0; 2190 ppHe = 0.0;
2181 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142) 2191 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142)
2182 float_saturation_multiplier = char_I_saturation_multiplier * 0.01; 2192 float_saturation_multiplier = char_I_saturation_multiplier * 0.01;
2183 2193
2184 calc_tissue(1); // update the pressure in the 2*NUM_COMP tissues in accordance with the new ambient pressure 2194 calc_tissue(1); // update the pressure in the tissues N2/He in accordance with the new ambient pressure
2185 2195
2186 clear_deco_table(); 2196 clear_deco_table();
2187 char_O_deco_status = 3; // surface new in v.102 : stays in surface state. 2197 char_O_deco_status = 3; // surface new in v.102 : stays in surface state.
2188 char_O_nullzeit = 0; 2198 char_O_nullzeit = 0;
2189 int_O_ascenttime = 0; 2199 int_O_ascenttime = 0;
2527 { 2537 {
2528 overlay unsigned char x; 2538 overlay unsigned char x;
2529 RESET_C_STACK 2539 RESET_C_STACK
2530 2540
2531 cns_vault = CNS_fraction; 2541 cns_vault = CNS_fraction;
2532 for (x=0;x<2*NUM_COMP;x++) 2542 for (x=0;x<NUM_COMP;x++)
2533 pres_tissue_vault[x] = pres_tissue[x]; 2543 {
2544 pres_tissue_N2_vault[x] = pres_tissue_N2[x];
2545 pres_tissue_He_vault[x] = pres_tissue_He[x];
2546 }
2534 } 2547 }
2535 2548
2536 void deco_pull_tissues_from_vault(void) 2549 void deco_pull_tissues_from_vault(void)
2537 { 2550 {
2538 overlay unsigned char x; 2551 overlay unsigned char x;
2539 RESET_C_STACK 2552 RESET_C_STACK
2540 2553
2541 for (x=0;x<2*NUM_COMP;x++) 2554 for (x=0; x<NUM_COMP; x++)
2542 pres_tissue[x] = pres_tissue_vault[x]; 2555 {
2556 pres_tissue_N2[x] = pres_tissue_N2_vault[x];
2557 pres_tissue_He[x] = pres_tissue_He_vault[x];
2558 }
2543 2559
2544 // Restore both CNS variable, too. 2560 // Restore both CNS variable, too.
2545 CNS_fraction = cns_vault; 2561 CNS_fraction = cns_vault;
2546 char_O_CNS_fraction = (char)(CNS_fraction * 100.0 + 0.5); 2562 char_O_CNS_fraction = (char)(CNS_fraction * 100.0 + 0.5);
2547 } 2563 }