Mercurial > public > mk2
comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 601:d1719622111e
Minor LLVM compatibility cleanups.
author | JeanDo <jd.gascuel@free.fr> |
---|---|
date | Tue, 26 Jun 2012 21:32:09 +0200 |
parents | 855a00c21d0c |
children | 6526a5b058b7 |
comparison
equal
deleted
inserted
replaced
600:f1860c1237cc | 601:d1719622111e |
---|---|
151 static void gas_switch_set(void); | 151 static void gas_switch_set(void); |
152 | 152 |
153 static unsigned char calc_nextdecodepth(void); | 153 static unsigned char calc_nextdecodepth(void); |
154 | 154 |
155 //---- Bank 4 parameters ----------------------------------------------------- | 155 //---- Bank 4 parameters ----------------------------------------------------- |
156 #pragma udata bank4=0x400 | 156 #ifndef UNIX |
157 # pragma udata bank4=0x400 | |
158 #endif | |
157 | 159 |
158 static float GF_low; | 160 static float GF_low; |
159 static float GF_high; | 161 static float GF_high; |
160 static float GF_delta; | 162 static float GF_delta; |
161 static float locked_GF_step; // GF_delta / low_depth | 163 static float locked_GF_step; // GF_delta / low_depth |
176 static float cns_vault; | 178 static float cns_vault; |
177 static float pres_tissue_N2_vault[NUM_COMP]; | 179 static float pres_tissue_N2_vault[NUM_COMP]; |
178 static float pres_tissue_He_vault[NUM_COMP]; | 180 static float pres_tissue_He_vault[NUM_COMP]; |
179 | 181 |
180 //---- Bank 5 parameters ----------------------------------------------------- | 182 //---- Bank 5 parameters ----------------------------------------------------- |
181 #pragma udata bank5=0x500 | 183 #ifndef UNIX |
184 # pragma udata bank5=0x500 | |
185 #endif | |
182 | 186 |
183 static unsigned char ci; | 187 static unsigned char ci; |
184 static float pres_respiration; | 188 static float pres_respiration; |
185 static float pres_surface; | 189 static float pres_surface; |
186 static float temp_deco; | 190 static float temp_deco; |
214 static char flag_in_divemode; // new in v.108 | 218 static char flag_in_divemode; // new in v.108 |
215 | 219 |
216 static unsigned char deco_gas_change[NUM_GAS]; // new in v.109 | 220 static unsigned char deco_gas_change[NUM_GAS]; // new in v.109 |
217 | 221 |
218 //---- Bank 6 parameters ----------------------------------------------------- | 222 //---- Bank 6 parameters ----------------------------------------------------- |
219 #pragma udata bank6=0x600 | 223 #ifndef UNIX |
224 # pragma udata bank6=0x600 | |
225 #endif | |
220 | 226 |
221 float pres_tissue_N2[NUM_COMP]; | 227 float pres_tissue_N2[NUM_COMP]; |
222 float pres_tissue_He[NUM_COMP]; | 228 float pres_tissue_He[NUM_COMP]; |
223 float sim_pres_tissue_N2[NUM_COMP]; // 16 floats = 64 bytes. | 229 float sim_pres_tissue_N2[NUM_COMP]; // 16 floats = 64 bytes. |
224 float sim_pres_tissue_He[NUM_COMP]; // 16 floats = 64 bytes. | 230 float sim_pres_tissue_He[NUM_COMP]; // 16 floats = 64 bytes. |
225 | 231 |
226 //---- Bank 7 parameters ----------------------------------------------------- | 232 //---- Bank 7 parameters ----------------------------------------------------- |
227 #pragma udata bank7=0x700 | 233 #ifndef UNIX |
234 # pragma udata bank7=0x700 | |
235 #endif | |
236 | |
228 // EMPTY ... | 237 // EMPTY ... |
229 | 238 |
230 //---- Bank 8 parameters ----------------------------------------------------- | 239 //---- Bank 8 parameters ----------------------------------------------------- |
231 #pragma udata bank8=0x800 | 240 #ifndef UNIX |
232 | 241 # pragma udata bank8=0x800 |
233 static char md_pi_subst[256]; | 242 |
234 #define C_STACK md_pi_subst // Overlay C-code data stack here, too. | 243 static char md_pi_subst[256]; |
244 # define C_STACK md_pi_subst // Overlay C-code data stack here, too. | |
245 | |
246 #endif | |
235 | 247 |
236 //---- Bank 9 parameters ----------------------------------------------------- | 248 //---- Bank 9 parameters ----------------------------------------------------- |
237 #pragma udata bank9=0x900 | 249 #ifndef UNIX |
238 | 250 # pragma udata bank9=0x900 |
239 static char md_state[48]; // DONT MOVE !! // has to be at the beginning of bank 9 for the asm code!!! | 251 |
252 static char md_state[48]; // DONT MOVE : has to be at the beginning of bank 9 for the asm code!!! | |
253 #endif | |
254 | |
240 | 255 |
241 ////////////////////////////////////////////////////////////////////////////// | 256 ////////////////////////////////////////////////////////////////////////////// |
242 ////////////////////////////////////////////////////////////////////////////// | 257 ////////////////////////////////////////////////////////////////////////////// |
243 ///////////////////////////// THE LOOKUP TABLES ////////////////////////////// | 258 ///////////////////////////// THE LOOKUP TABLES ////////////////////////////// |
244 ////////////////////////////////////////////////////////////////////////////// | 259 ////////////////////////////////////////////////////////////////////////////// |
245 ////////////////////////////////////////////////////////////////////////////// | 260 ////////////////////////////////////////////////////////////////////////////// |
246 // | 261 // |
247 // End of PROM code is 17F00, So push tables on PROM top... | 262 // End of PROM code is 17F00, So push tables on PROM top... |
248 // | 263 // |
249 #pragma romdata buhlmann_tables = 0x017B00 // Needs to be in UPPER bank. | 264 #ifndef UNIX |
265 # pragma romdata buhlmann_tables = 0x017B00 // Needs to be in UPPER bank. | |
266 #endif | |
267 | |
250 #include "p2_tables.romdata" // new table for deco_main_v.101 (var_N2_a modified) | 268 #include "p2_tables.romdata" // new table for deco_main_v.101 (var_N2_a modified) |
251 | 269 |
252 // Magic table to compute the MD2 HASH | 270 // Magic table to compute the MD2 HASH |
253 // | 271 // |
254 #pragma romdata hash_tables = 0x017E00 // Address fixed by ASM access... | 272 #ifndef UNIX |
255 rom const rom unsigned short md_pi[] = | 273 # pragma romdata hash_tables = 0x017E00 // Address fixed by ASM access... |
256 { | 274 rom const rom unsigned short md_pi[] = |
257 0x292E, 0x43C9, 0xA2D8, 0x7C01, 0x3D36, 0x54A1, 0xECF0, 0x0613 | 275 { |
258 , 0x62A7, 0x05F3, 0xC0C7, 0x738C, 0x9893, 0x2BD9, 0xBC4C, 0x82CA | 276 0x292E, 0x43C9, 0xA2D8, 0x7C01, 0x3D36, 0x54A1, 0xECF0, 0x0613 |
259 , 0x1E9B, 0x573C, 0xFDD4, 0xE016, 0x6742, 0x6F18, 0x8A17, 0xE512 | 277 , 0x62A7, 0x05F3, 0xC0C7, 0x738C, 0x9893, 0x2BD9, 0xBC4C, 0x82CA |
260 , 0xBE4E, 0xC4D6, 0xDA9E, 0xDE49, 0xA0FB, 0xF58E, 0xBB2F, 0xEE7A | 278 , 0x1E9B, 0x573C, 0xFDD4, 0xE016, 0x6742, 0x6F18, 0x8A17, 0xE512 |
261 , 0xA968, 0x7991, 0x15B2, 0x073F, 0x94C2, 0x1089, 0x0B22, 0x5F21 | 279 , 0xBE4E, 0xC4D6, 0xDA9E, 0xDE49, 0xA0FB, 0xF58E, 0xBB2F, 0xEE7A |
262 , 0x807F, 0x5D9A, 0x5A90, 0x3227, 0x353E, 0xCCE7, 0xBFF7, 0x9703 | 280 , 0xA968, 0x7991, 0x15B2, 0x073F, 0x94C2, 0x1089, 0x0B22, 0x5F21 |
263 , 0xFF19, 0x30B3, 0x48A5, 0xB5D1, 0xD75E, 0x922A, 0xAC56, 0xAAC6 | 281 , 0x807F, 0x5D9A, 0x5A90, 0x3227, 0x353E, 0xCCE7, 0xBFF7, 0x9703 |
264 , 0x4FB8, 0x38D2, 0x96A4, 0x7DB6, 0x76FC, 0x6BE2, 0x9C74, 0x04F1 | 282 , 0xFF19, 0x30B3, 0x48A5, 0xB5D1, 0xD75E, 0x922A, 0xAC56, 0xAAC6 |
265 , 0x459D, 0x7059, 0x6471, 0x8720, 0x865B, 0xCF65, 0xE62D, 0xA802 | 283 , 0x4FB8, 0x38D2, 0x96A4, 0x7DB6, 0x76FC, 0x6BE2, 0x9C74, 0x04F1 |
266 , 0x1B60, 0x25AD, 0xAEB0, 0xB9F6, 0x1C46, 0x6169, 0x3440, 0x7E0F | 284 , 0x459D, 0x7059, 0x6471, 0x8720, 0x865B, 0xCF65, 0xE62D, 0xA802 |
267 , 0x5547, 0xA323, 0xDD51, 0xAF3A, 0xC35C, 0xF9CE, 0xBAC5, 0xEA26 | 285 , 0x1B60, 0x25AD, 0xAEB0, 0xB9F6, 0x1C46, 0x6169, 0x3440, 0x7E0F |
268 , 0x2C53, 0x0D6E, 0x8528, 0x8409, 0xD3DF, 0xCDF4, 0x4181, 0x4D52 | 286 , 0x5547, 0xA323, 0xDD51, 0xAF3A, 0xC35C, 0xF9CE, 0xBAC5, 0xEA26 |
269 , 0x6ADC, 0x37C8, 0x6CC1, 0xABFA, 0x24E1, 0x7B08, 0x0CBD, 0xB14A | 287 , 0x2C53, 0x0D6E, 0x8528, 0x8409, 0xD3DF, 0xCDF4, 0x4181, 0x4D52 |
270 , 0x7888, 0x958B, 0xE363, 0xE86D, 0xE9CB, 0xD5FE, 0x3B00, 0x1D39 | 288 , 0x6ADC, 0x37C8, 0x6CC1, 0xABFA, 0x24E1, 0x7B08, 0x0CBD, 0xB14A |
271 , 0xF2EF, 0xB70E, 0x6658, 0xD0E4, 0xA677, 0x72F8, 0xEB75, 0x4B0A | 289 , 0x7888, 0x958B, 0xE363, 0xE86D, 0xE9CB, 0xD5FE, 0x3B00, 0x1D39 |
272 , 0x3144, 0x50B4, 0x8FED, 0x1F1A, 0xDB99, 0x8D33, 0x9F11, 0x8314 | 290 , 0xF2EF, 0xB70E, 0x6658, 0xD0E4, 0xA677, 0x72F8, 0xEB75, 0x4B0A |
273 }; | 291 , 0x3144, 0x50B4, 0x8FED, 0x1F1A, 0xDB99, 0x8D33, 0x9F11, 0x8314 |
292 }; | |
293 #endif | |
274 | 294 |
275 ////////////////////////////////////////////////////////////////////////////// | 295 ////////////////////////////////////////////////////////////////////////////// |
276 ////////////////////////////////////////////////////////////////////////////// | 296 ////////////////////////////////////////////////////////////////////////////// |
277 ////////////////////////////// THE SUBROUTINES /////////////////////////////// | 297 ////////////////////////////// THE SUBROUTINES /////////////////////////////// |
278 ////////////////////////////////////////////////////////////////////////////// | 298 ////////////////////////////////////////////////////////////////////////////// |
279 ////////////////////////////////////////////////////////////////////////////// | 299 ////////////////////////////////////////////////////////////////////////////// |
280 // | 300 // |
281 // all new in v.102 | 301 // all new in v.102 |
282 // moved from 0x0D000 to 0x0C000 in v.108 | 302 // moved from 0x0D000 to 0x0C000 in v.108 |
283 | 303 #ifndef UNIX |
284 #pragma code p2_deco = 0x0C000 | 304 # pragma code p2_deco = 0x0C000 |
305 #endif | |
285 | 306 |
286 ////////////////////////////////////////////////////////////////////////////// | 307 ////////////////////////////////////////////////////////////////////////////// |
287 ////////////////////////////////////////////////////////////////////////////// | 308 ////////////////////////////////////////////////////////////////////////////// |
288 /////////////////////// U T I L I T I E S ///////////////////////////////// | 309 /////////////////////// U T I L I T I E S ///////////////////////////////// |
289 ////////////////////////////////////////////////////////////////////////////// | 310 ////////////////////////////////////////////////////////////////////////////// |
1826 // changes in v.101: 1.05 = 5 percent dist to totally clean is new desaturation point for display and NoFly calculations | 1847 // changes in v.101: 1.05 = 5 percent dist to totally clean is new desaturation point for display and NoFly calculations |
1827 // N2 | 1848 // N2 |
1828 temp1 = 1.05 * ppN2 - pres_tissue_N2[ci]; | 1849 temp1 = 1.05 * ppN2 - pres_tissue_N2[ci]; |
1829 temp2 = ppN2 - pres_tissue_N2[ci]; | 1850 temp2 = ppN2 - pres_tissue_N2[ci]; |
1830 if (temp2 >= 0.0) | 1851 if (temp2 >= 0.0) |
1831 { | |
1832 temp1 = 0.0; | 1852 temp1 = 0.0; |
1833 temp2 = 0.0; | |
1834 } | |
1835 else | 1853 else |
1836 temp1 = temp1 / temp2; | 1854 temp1 = temp1 / temp2; |
1855 | |
1837 if( 0.0 < temp1 && temp1 < 1.0 ) | 1856 if( 0.0 < temp1 && temp1 < 1.0 ) |
1838 { | 1857 { |
1839 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested. | 1858 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested. |
1840 // minus because log is negative. | 1859 // minus because log is negative. |
1841 temp1 = log(1.0 - temp1) / -0.6931; // temp1 is the multiples of half times necessary. | 1860 temp1 = log(1.0 - temp1) / -0.6931; // temp1 is the multiples of half times necessary. |
1849 } | 1868 } |
1850 | 1869 |
1851 // He | 1870 // He |
1852 temp3 = 0.1 - pres_tissue_He[ci]; | 1871 temp3 = 0.1 - pres_tissue_He[ci]; |
1853 if (temp3 >= 0.0) | 1872 if (temp3 >= 0.0) |
1854 { | |
1855 temp3 = 0.0; | 1873 temp3 = 0.0; |
1856 temp4 = 0.0; | |
1857 } | |
1858 else | 1874 else |
1859 temp3 = - temp3 / pres_tissue_He[ci]; | 1875 temp3 = - temp3 / pres_tissue_He[ci]; |
1876 | |
1860 if( 0.0 < temp3 && temp3 < 1.0 ) | 1877 if( 0.0 < temp3 && temp3 < 1.0 ) |
1861 { | 1878 { |
1862 temp3 = log(1.0 - temp3) / -0.6931; // temp1 is the multiples of half times necessary. | 1879 temp3 = log(1.0 - temp3) / -0.6931; // temp1 is the multiples of half times necessary. |
1863 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested. | 1880 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested. |
1864 // minus because log is negative | 1881 // minus because log is negative |