comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 126:ed275788a291

Re-indent c-code. Add .o file.
author JeanDo
date Tue, 04 Jan 2011 01:55:49 +0100
parents 3003a8040b78
children 144822282fa3
comparison
equal deleted inserted replaced
125:2907b42c195b 126:ed275788a291
687 // new in v.102 687 // new in v.102
688 void copy_deco_table_GF(void) 688 void copy_deco_table_GF(void)
689 { 689 {
690 if (char_I_deco_model == 1) 690 if (char_I_deco_model == 1)
691 { 691 {
692 int_temp = 32; 692 for (ci=0;ci<32;ci++)
693 for (ci=0;ci<int_temp;ci++)
694 char_O_deco_table[ci] = internal_deco_table[ci]; 693 char_O_deco_table[ci] = internal_deco_table[ci];
695 } 694 }
696 } // copy_deco_table_GF 695 } // copy_deco_table_GF
697 696
698 697
727 // temp_tissue_safety // 726 // temp_tissue_safety //
728 // --------------------- 727 // ---------------------
729 // outsourced in v.102 728 // outsourced in v.102
730 void temp_tissue_safety(void) 729 void temp_tissue_safety(void)
731 { 730 {
732 if (char_I_deco_model == 1) 731 if (char_I_deco_model != 1)
733 {
734 }
735 else
736 { 732 {
737 if (temp_tissue < 0.0) 733 if (temp_tissue < 0.0)
738 temp_tissue = temp_tissue * float_desaturation_multiplier; 734 temp_tissue *= float_desaturation_multiplier;
739 else 735 else
740 temp_tissue = temp_tissue * float_saturation_multiplier; 736 temp_tissue *= float_saturation_multiplier;
741 } 737 }
742 } // temp_tissue_safety 738 } // temp_tissue_safety
743 739
744 // ********************** 740 // **********************
745 // ********************** 741 // **********************
830 int_O_DBS2_bitfield = 0; 826 int_O_DBS2_bitfield = 0;
831 int_O_DBG_pre_bitfield = 0; 827 int_O_DBG_pre_bitfield = 0;
832 int_O_DBG_post_bitfield = 0; 828 int_O_DBG_post_bitfield = 0;
833 char_O_NDL_at_20mtr = 255; 829 char_O_NDL_at_20mtr = 255;
834 830
835 // N2_ratio = (float)char_I_N2_ratio; // the 0.0002 of 0.7902 are missing with standard air 831 // N2_ratio = (float)char_I_N2_ratio; // the 0.0002 of 0.7902 are missing with standard air
836 N2_ratio = 0.7902; // N2_ratio / 100.0; 832 N2_ratio = 0.7902; // N2_ratio / 100.0;
837 pres_respiration = (float)int_I_pres_respiration / 1000.0; 833 pres_respiration = (float)int_I_pres_respiration / 1000.0;
838 for (ci=0;ci<16;ci++) // cycle through the 16 b"uhlmann tissues 834 for (ci=0;ci<16;ci++) // cycle through the 16 b"uhlmann tissues
839 { 835 {
840 pres_tissue[ci] = N2_ratio * (pres_respiration - 0.0627) ; 836 pres_tissue[ci] = N2_ratio * (pres_respiration - 0.0627) ;
841 _asm 837 _asm
842 movlw 0x02 838 movlw 0x02
843 movwf TBLPTRH,0 839 movwf TBLPTRH,0
844 movlb 4 // fuer ci 840 movlb 4 // fuer ci
845 movf ci,0,1 841 movf ci,0,1
846 addwf ci,0,1 842 addwf ci,0,1
847 addwf ci,0,1 843 addwf ci,0,1
848 addwf ci,0,1 844 addwf ci,0,1
849 addlw 0x80 845 addlw 0x80
850 movwf TBLPTRL,0 846 movwf TBLPTRL,0
851 TBLRDPOSTINC 847 TBLRDPOSTINC
852 movff TABLAT,var_a+1 848 movff TABLAT,var_a+1
853 TBLRDPOSTINC 849 TBLRDPOSTINC
854 movff TABLAT,var_a 850 movff TABLAT,var_a
855 TBLRDPOSTINC 851 TBLRDPOSTINC
856 movff TABLAT,var_a+3 852 movff TABLAT,var_a+3
857 TBLRD 853 TBLRD
858 movff TABLAT,var_a+2 854 movff TABLAT,var_a+2
859 addlw 0x80 855 addlw 0x80
860 movwf TBLPTRL,0 856 movwf TBLPTRL,0
861 incf TBLPTRH,1,0 857 incf TBLPTRH,1,0
862 TBLRDPOSTINC 858 TBLRDPOSTINC
863 movff TABLAT,var_b+1 859 movff TABLAT,var_b+1
864 TBLRDPOSTINC 860 TBLRDPOSTINC
865 movff TABLAT,var_b 861 movff TABLAT,var_b
866 TBLRDPOSTINC 862 TBLRDPOSTINC
867 movff TABLAT,var_b+3 863 movff TABLAT,var_b+3
868 TBLRD 864 TBLRD
869 movff TABLAT,var_b+2 865 movff TABLAT,var_b+2
870 _endasm 866 _endasm
871 867
872 pres_tissue_limit[ci] = (pres_tissue[ci] - var_a) * var_b ; 868 pres_tissue_limit[ci] = (pres_tissue[ci] - var_a) * var_b ;
873 // now update the guiding tissue 869 // now update the guiding tissue
874 if (pres_tissue_limit[ci] < 0) 870 if (pres_tissue_limit[ci] < 0)
875 pres_tissue_limit[ci] = 0; 871 pres_tissue_limit[ci] = 0;
876 } // for 0 to 16 872 } // for 0 to 16
877 873
878 for (ci=16;ci<32;ci++) // cycle through the 16 b"uhlmann tissues for Helium 874 for (ci=16;ci<32;ci++) // cycle through the 16 b"uhlmann tissues for Helium
879 { 875 {
880 pres_tissue[ci] = 0.0; 876 pres_tissue[ci] = 0.0;
881 } // for 877 } // for
882 878
883 clear_decoarray(); 879 clear_decoarray();
884 char_O_deco_status = 0; 880 char_O_deco_status = 0;
885 char_O_nullzeit = 0; 881 char_O_nullzeit = 0;
886 char_O_ascenttime = 0; 882 char_O_ascenttime = 0;
887 char_O_gradient_factor = 0; 883 char_O_gradient_factor = 0;
888 char_O_relative_gradient_GF = 0; 884 char_O_relative_gradient_GF = 0;
889 } // clear_tissue(void) 885 } // clear_tissue(void)
890 886
891 887
892 // -------------------- 888 // --------------------
893 // calc_without_deco // 889 // calc_without_deco //
895 // -------------------- 891 // --------------------
896 // optimized in v.101 (float_..saturation_multiplier) 892 // optimized in v.101 (float_..saturation_multiplier)
897 893
898 void calc_without_deco(void) 894 void calc_without_deco(void)
899 { 895 {
900 N2_ratio = 0.7902; // FIXED RATIO !! sum as stated in b"uhlmann 896 N2_ratio = 0.7902; // FIXED RATIO !! sum as stated in b"uhlmann
901 pres_respiration = (float)int_I_pres_respiration / 1000.0; // assembler code uses different digit system 897 pres_respiration = (float)int_I_pres_respiration / 1000.0; // assembler code uses different digit system
902 pres_surface = (float)int_I_pres_surface / 1000.0; 898 pres_surface = (float)int_I_pres_surface / 1000.0;
903 temp_atem = N2_ratio * (pres_respiration - 0.0627); // 0.0627 is the extra pressure in the body 899 temp_atem = N2_ratio * (pres_respiration - 0.0627); // 0.0627 is the extra pressure in the body
904 temp2_atem = 0.0; 900 temp2_atem = 0.0;
905 temp_surface = pres_surface; // the b"uhlmann formula using temp_surface does apply to the pressure without any inert ratio 901 temp_surface = pres_surface; // the b"uhlmann formula using temp_surface does apply to the pressure without any inert ratio
906 float_desaturation_multiplier = char_I_desaturation_multiplier / 100.0; 902 float_desaturation_multiplier = char_I_desaturation_multiplier / 100.0;
907 float_saturation_multiplier = char_I_saturation_multiplier / 100.0; 903 float_saturation_multiplier = char_I_saturation_multiplier / 100.0;
908 904
909 calc_tissue(); // update the pressure in the 16 tissues in accordance with the new ambient pressure 905 calc_tissue(); // update the pressure in the 16 tissues in accordance with the new ambient pressure
910 906
911 clear_decoarray(); 907 clear_decoarray();
912 char_O_deco_status = 0; 908 char_O_deco_status = 0;
913 char_O_nullzeit = 0; 909 char_O_nullzeit = 0;
914 char_O_ascenttime = 0; 910 char_O_ascenttime = 0;
915 calc_gradient_factor(); 911 calc_gradient_factor();
916
917 } // calc_without_deco 912 } // calc_without_deco
918 913
919 914
920 // -------------------- 915 // --------------------
921 // calc_hauptroutine // 916 // calc_hauptroutine //
952 break; 947 break;
953 case 1: 948 case 1:
954 if (char_O_deco_status == 3) 949 if (char_O_deco_status == 3)
955 break; 950 break;
956 char_O_deco_status = 0; 951 char_O_deco_status = 0;
957 // char_O_lock_depth_list = 255;
958 calc_hauptroutine_calc_deco(); 952 calc_hauptroutine_calc_deco();
959 // build_debug_output();
960 break; 953 break;
961 case 3: // new dive 954 case 3: // new dive
962 clear_decoarray(); 955 clear_decoarray();
963 clear_internal_deco_table_GF(); 956 clear_internal_deco_table_GF();
964 copy_deco_table_GF(); 957 copy_deco_table_GF();
975 output[6] = 1; 968 output[6] = 1;
976 calc_hauptroutine_calc_ascend_to_deco(); 969 calc_hauptroutine_calc_ascend_to_deco();
977 if (char_O_deco_status > 15) // can't go up to first deco, too deep to calculate in the given time slot 970 if (char_O_deco_status > 15) // can't go up to first deco, too deep to calculate in the given time slot
978 { 971 {
979 char_O_deco_status = 2; 972 char_O_deco_status = 2;
980 // char_O_lock_depth_list = 255;
981 } 973 }
982 else 974 else
983 { 975 {
984 // char_O_lock_depth_list = lock_GF_depth_list;
985 calc_hauptroutine_calc_deco(); 976 calc_hauptroutine_calc_deco();
986 } 977 }
987 // build_debug_output();
988 break; 978 break;
989 } 979 }
990 calc_ascenttime(); 980 calc_ascenttime();
991 check_post_dbg(); 981 check_post_dbg();
992 } 982 }
993 983
994 void calc_hauptroutine_data_input(void) 984 void calc_hauptroutine_data_input(void)
995 { 985 {
996 pres_respiration = (float)int_I_pres_respiration / 1000.0; 986 pres_respiration = (float)int_I_pres_respiration / 1000.0;
997 pres_surface = (float)int_I_pres_surface / 1000.0; 987 pres_surface = (float)int_I_pres_surface / 1000.0;
998 988
999 N2_ratio = (float)char_I_N2_ratio / 100.0;; // the 0.0002 of 0.7902 are missing with standard air 989 N2_ratio = (float)char_I_N2_ratio / 100.0;; // the 0.0002 of 0.7902 are missing with standard air
1000 He_ratio = (float)char_I_He_ratio / 100.0;; 990 He_ratio = (float)char_I_He_ratio / 100.0;;
1001 deco_N2_ratio = (float)char_I_deco_N2_ratio / 100.0; 991 deco_N2_ratio = (float)char_I_deco_N2_ratio / 100.0;
1002 deco_He_ratio = (float)char_I_deco_He_ratio / 100.0; 992 deco_He_ratio = (float)char_I_deco_He_ratio / 100.0;
1003 deco_N2_ratio2 = (float)char_I_deco_N2_ratio2 / 100.0; 993 deco_N2_ratio2 = (float)char_I_deco_N2_ratio2 / 100.0;
1004 deco_He_ratio2 = (float)char_I_deco_He_ratio2 / 100.0; 994 deco_He_ratio2 = (float)char_I_deco_He_ratio2 / 100.0;
1005 deco_N2_ratio3 = (float)char_I_deco_N2_ratio3 / 100.0; 995 deco_N2_ratio3 = (float)char_I_deco_N2_ratio3 / 100.0;
1006 deco_He_ratio3 = (float)char_I_deco_He_ratio3 / 100.0; 996 deco_He_ratio3 = (float)char_I_deco_He_ratio3 / 100.0;
1007 deco_N2_ratio4 = (float)char_I_deco_N2_ratio4 / 100.0; 997 deco_N2_ratio4 = (float)char_I_deco_N2_ratio4 / 100.0;
1008 deco_He_ratio4 = (float)char_I_deco_He_ratio4 / 100.0; 998 deco_He_ratio4 = (float)char_I_deco_He_ratio4 / 100.0;
1009 deco_N2_ratio5 = (float)char_I_deco_N2_ratio5 / 100.0; 999 deco_N2_ratio5 = (float)char_I_deco_N2_ratio5 / 100.0;
1010 deco_He_ratio5 = (float)char_I_deco_He_ratio5 / 100.0; 1000 deco_He_ratio5 = (float)char_I_deco_He_ratio5 / 100.0;
1011 float_deco_distance = (float)char_I_deco_distance / 100.0; 1001 float_deco_distance = (float)char_I_deco_distance / 100.0;
1012 1002
1013 // ____________________________________________________ 1003 // ____________________________________________________
1014 // 1004 //
1015 // _____________ G A S _ C H A N G E S ________________ 1005 // _____________ G A S _ C H A N G E S ________________
1016 // ____________________________________________________ 1006 // ____________________________________________________
1017 1007
1018 int_temp = (int_I_pres_respiration - int_I_pres_surface) + MBAR_REACH_GASCHANGE_AUTO_CHANGE_OFF; 1008 int_temp = (int_I_pres_respiration - int_I_pres_surface) + MBAR_REACH_GASCHANGE_AUTO_CHANGE_OFF;
1019 1009
1020 deco_gas_change = 0; 1010 deco_gas_change = 0;
1021 deco_gas_change2 = 0; 1011 deco_gas_change2 = 0;
1022 deco_gas_change3 = 0; 1012 deco_gas_change3 = 0;
1023 deco_gas_change4 = 0; 1013 deco_gas_change4 = 0;
1024 deco_gas_change5 = 0; 1014 deco_gas_change5 = 0;
1025 1015
1026 if(char_I_deco_gas_change) 1016 if(char_I_deco_gas_change)
1027 { 1017 {
1028 int_temp2 = ((int)char_I_deco_gas_change) * 100; 1018 int_temp2 = ((int)char_I_deco_gas_change) * 100;
1029 if(int_temp > int_temp2) 1019 if(int_temp > int_temp2)
1030 { 1020 {
1031 deco_gas_change = (float)char_I_deco_gas_change / 9.995 + pres_surface; 1021 deco_gas_change = (float)char_I_deco_gas_change / 9.995 + pres_surface;
1032 deco_gas_change += float_deco_distance; 1022 deco_gas_change += float_deco_distance;
1033 } 1023 }
1034 } 1024 }
1035 if(char_I_deco_gas_change2) 1025 if(char_I_deco_gas_change2)
1036 { 1026 {
1037 int_temp2 = ((int)char_I_deco_gas_change2) * 100; 1027 int_temp2 = ((int)char_I_deco_gas_change2) * 100;
1038 if(int_temp > int_temp2) 1028 if(int_temp > int_temp2)
1039 { 1029 {
1040 deco_gas_change2 = (float)char_I_deco_gas_change2 / 9.995 + pres_surface; 1030 deco_gas_change2 = (float)char_I_deco_gas_change2 / 9.995 + pres_surface;
1041 deco_gas_change2 += float_deco_distance; 1031 deco_gas_change2 += float_deco_distance;
1042 } 1032 }
1043 } 1033 }
1044 if(char_I_deco_gas_change3) 1034 if(char_I_deco_gas_change3)
1045 { 1035 {
1046 int_temp2 = ((int)char_I_deco_gas_change3) * 100; 1036 int_temp2 = ((int)char_I_deco_gas_change3) * 100;
1047 if(int_temp > int_temp2) 1037 if(int_temp > int_temp2)
1048 { 1038 {
1049 deco_gas_change3 = (float)char_I_deco_gas_change3 / 9.995 + pres_surface; 1039 deco_gas_change3 = (float)char_I_deco_gas_change3 / 9.995 + pres_surface;
1050 deco_gas_change3 += float_deco_distance; 1040 deco_gas_change3 += float_deco_distance;
1051 } 1041 }
1052 } 1042 }
1053 if(char_I_deco_gas_change4) 1043 if(char_I_deco_gas_change4)
1054 { 1044 {
1055 int_temp2 = ((int)char_I_deco_gas_change4) * 100; 1045 int_temp2 = ((int)char_I_deco_gas_change4) * 100;
1056 if(int_temp > int_temp2) 1046 if(int_temp > int_temp2)
1057 { 1047 {
1058 deco_gas_change4 = (float)char_I_deco_gas_change4 / 9.995 + pres_surface; 1048 deco_gas_change4 = (float)char_I_deco_gas_change4 / 9.995 + pres_surface;
1059 deco_gas_change4 += float_deco_distance; 1049 deco_gas_change4 += float_deco_distance;
1060 } 1050 }
1061 } 1051 }
1062 if(char_I_deco_gas_change5) 1052 if(char_I_deco_gas_change5)
1063 { 1053 {
1064 int_temp2 = ((int)char_I_deco_gas_change5) * 100; 1054 int_temp2 = ((int)char_I_deco_gas_change5) * 100;
1065 if(int_temp > int_temp2) 1055 if(int_temp > int_temp2)
1066 { 1056 {
1067 deco_gas_change5 = (float)char_I_deco_gas_change5 / 9.995 + pres_surface; 1057 deco_gas_change5 = (float)char_I_deco_gas_change5 / 9.995 + pres_surface;
1068 deco_gas_change5 += float_deco_distance; 1058 deco_gas_change5 += float_deco_distance;
1069 } 1059 }
1070 } 1060 }
1071 1061
1072 const_ppO2 = (float)char_I_const_ppO2 / 100.0; 1062 const_ppO2 = (float)char_I_const_ppO2 / 100.0;
1073 deco_ppO2_change = (float)char_I_deco_ppO2_change / 99.95 + pres_surface; 1063 deco_ppO2_change = (float)char_I_deco_ppO2_change / 99.95 + pres_surface;
1074 deco_ppO2_change = deco_ppO2_change + float_deco_distance; 1064 deco_ppO2_change = deco_ppO2_change + float_deco_distance;
1075 deco_ppO2 = (float)char_I_deco_ppO2 / 100.0; 1065 deco_ppO2 = (float)char_I_deco_ppO2 / 100.0;
1076 float_desaturation_multiplier = char_I_desaturation_multiplier / 100.0; 1066 float_desaturation_multiplier = char_I_desaturation_multiplier / 100.0;
1077 float_saturation_multiplier = char_I_saturation_multiplier / 100.0; 1067 float_saturation_multiplier = char_I_saturation_multiplier / 100.0;
1078 GF_low = (float)char_I_GF_Low_percentage / 100.0; 1068 GF_low = (float)char_I_GF_Low_percentage / 100.0;
1079 GF_high = (float)char_I_GF_High_percentage / 100.0; 1069 GF_high = (float)char_I_GF_High_percentage / 100.0;
1080 GF_delta = GF_high - GF_low; 1070 GF_delta = GF_high - GF_low;
1081 1071
1082 temp2 = (pres_respiration - pres_surface) / 0.29985; 1072 temp2 = (pres_respiration - pres_surface) / 0.29985;
1083 int_temp = (int)(temp2); 1073 int_temp = (int)(temp2);
1084 if (int_temp < 0) 1074 if (int_temp < 0)
1085 int_temp = 0; 1075 int_temp = 0;
1086 if (int_temp > 255) 1076 if (int_temp > 255)
1087 int_temp = 255; 1077 int_temp = 255;
1088 char_O_actual_pointer = int_temp; 1078 char_O_actual_pointer = int_temp;
1089 1079
1090 temp_depth_last_deco = (int)char_I_depth_last_deco; 1080 temp_depth_last_deco = (int)char_I_depth_last_deco;
1091 } 1081 }
1092 1082
1093 void calc_hauptroutine_update_tissues(void) 1083 void calc_hauptroutine_update_tissues(void)
1094 { 1084 {
1095 int_O_calc_tissue_call_counter = int_O_calc_tissue_call_counter + 1; 1085 int_O_calc_tissue_call_counter = int_O_calc_tissue_call_counter + 1;
1309 // -------------- 1299 // --------------
1310 // optimized in v.101 1300 // optimized in v.101
1311 1301
1312 void calc_tissue(void) 1302 void calc_tissue(void)
1313 { 1303 {
1314 char_O_gtissue_no = 255; 1304 char_O_gtissue_no = 255;
1315 pres_gtissue_limit = 0.0; 1305 pres_gtissue_limit = 0.0;
1316 1306
1317 for (ci=0;ci<16;ci++) 1307 for (ci=0;ci<16;ci++)
1318 { 1308 {
1319 _asm 1309 _asm
1320 movlw 0x02 1310 movlw 0x02
1321 movwf TBLPTRH,0 1311 movwf TBLPTRH,0
1322 movlb 4 // fuer ci 1312 movlb 4 // fuer ci
1323 movf ci,0,1 1313 movf ci,0,1
1324 addwf ci,0,1 1314 addwf ci,0,1
1325 addwf ci,0,1 1315 addwf ci,0,1
1326 addwf ci,0,1 1316 addwf ci,0,1
1327 movwf TBLPTRL,0 1317 movwf TBLPTRL,0
1328 TBLRDPOSTINC 1318 TBLRDPOSTINC
1329 movff TABLAT,var_e2secs+1 // the order is confussing 1319 movff TABLAT,var_e2secs+1 // the order is confussing
1330 TBLRDPOSTINC 1320 TBLRDPOSTINC
1331 movff TABLAT,var_e2secs // low byte first, high afterwards 1321 movff TABLAT,var_e2secs // low byte first, high afterwards
1332 TBLRDPOSTINC 1322 TBLRDPOSTINC
1333 movff TABLAT,var_e2secs+3 1323 movff TABLAT,var_e2secs+3
1334 TBLRD 1324 TBLRD
1335 movff TABLAT,var_e2secs+2 1325 movff TABLAT,var_e2secs+2
1336 addlw 0x40 1326 addlw 0x40
1337 movwf TBLPTRL,0 1327 movwf TBLPTRL,0
1338 TBLRDPOSTINC 1328 TBLRDPOSTINC
1339 movff TABLAT,var2_e2secs+1 1329 movff TABLAT,var2_e2secs+1
1340 TBLRDPOSTINC 1330 TBLRDPOSTINC
1341 movff TABLAT,var2_e2secs 1331 movff TABLAT,var2_e2secs
1342 TBLRDPOSTINC 1332 TBLRDPOSTINC
1343 movff TABLAT,var2_e2secs+3 1333 movff TABLAT,var2_e2secs+3
1344 TBLRD 1334 TBLRD
1345 movff TABLAT,var2_e2secs+2 1335 movff TABLAT,var2_e2secs+2
1346 addlw 0x40 1336 addlw 0x40
1347 movwf TBLPTRL,0 1337 movwf TBLPTRL,0
1348 TBLRDPOSTINC 1338 TBLRDPOSTINC
1349 movff TABLAT,var_a+1 1339 movff TABLAT,var_a+1
1350 TBLRDPOSTINC 1340 TBLRDPOSTINC
1351 movff TABLAT,var_a 1341 movff TABLAT,var_a
1352 TBLRDPOSTINC 1342 TBLRDPOSTINC
1353 movff TABLAT,var_a+3 1343 movff TABLAT,var_a+3
1354 TBLRD 1344 TBLRD
1355 movff TABLAT,var_a+2 1345 movff TABLAT,var_a+2
1356 addlw 0x40 1346 addlw 0x40
1357 movwf TBLPTRL,0 1347 movwf TBLPTRL,0
1358 TBLRDPOSTINC 1348 TBLRDPOSTINC
1359 movff TABLAT,var2_a+1 1349 movff TABLAT,var2_a+1
1360 TBLRDPOSTINC 1350 TBLRDPOSTINC
1361 movff TABLAT,var2_a 1351 movff TABLAT,var2_a
1362 TBLRDPOSTINC 1352 TBLRDPOSTINC
1363 movff TABLAT,var2_a+3 1353 movff TABLAT,var2_a+3
1364 TBLRD 1354 TBLRD
1365 movff TABLAT,var2_a+2 1355 movff TABLAT,var2_a+2
1366 addlw 0x40 1356 addlw 0x40
1367 movwf TBLPTRL,0 1357 movwf TBLPTRL,0
1368 incf TBLPTRH,1,0 1358 incf TBLPTRH,1,0
1369 TBLRDPOSTINC 1359 TBLRDPOSTINC
1370 movff TABLAT,var_b+1 1360 movff TABLAT,var_b+1
1371 TBLRDPOSTINC 1361 TBLRDPOSTINC
1372 movff TABLAT,var_b 1362 movff TABLAT,var_b
1373 TBLRDPOSTINC 1363 TBLRDPOSTINC
1374 movff TABLAT,var_b+3 1364 movff TABLAT,var_b+3
1375 TBLRD 1365 TBLRD
1376 movff TABLAT,var_b+2 1366 movff TABLAT,var_b+2
1377 addlw 0x40 1367 addlw 0x40
1378 movwf TBLPTRL,0 1368 movwf TBLPTRL,0
1379 TBLRDPOSTINC 1369 TBLRDPOSTINC
1380 movff TABLAT,var2_b+1 1370 movff TABLAT,var2_b+1
1381 TBLRDPOSTINC 1371 TBLRDPOSTINC
1382 movff TABLAT,var2_b 1372 movff TABLAT,var2_b
1383 TBLRDPOSTINC 1373 TBLRDPOSTINC
1384 movff TABLAT,var2_b+3 1374 movff TABLAT,var2_b+3
1385 TBLRD 1375 TBLRD
1386 movff TABLAT,var2_b+2 1376 movff TABLAT,var2_b+2
1387 _endasm 1377 _endasm
1388 // the start values are the previous end values // write new values in temp 1378 // the start values are the previous end values // write new values in temp
1389 1379
1390 if( (var_e2secs < 0.0000363) 1380 if( (var_e2secs < 0.0000363)
1391 || (var_e2secs > 0.00577) 1381 || (var_e2secs > 0.00577)
1392 || (var2_e2secs < 0.0000961) 1382 || (var2_e2secs < 0.0000961)
1393 || (var2_e2secs > 0.150) 1383 || (var2_e2secs > 0.150)
1394 || (var_a < 0.231) 1384 || (var_a < 0.231)
1395 || (var_a > 1.27) 1385 || (var_a > 1.27)
1396 || (var_b < 0.504) 1386 || (var_b < 0.504)
1397 || (var_b > 0.966) 1387 || (var_b > 0.966)
1398 || (var2_a < 0.510) 1388 || (var2_a < 0.510)
1399 || (var2_a > 1.75) 1389 || (var2_a > 1.75)
1400 || (var2_b < 0.423) 1390 || (var2_b < 0.423)
1401 || (var2_b > 0.927) 1391 || (var2_b > 0.927)
1402 ) 1392 )
1403 int_O_DBG_pre_bitfield |= DBG_ZH16ERR; 1393 int_O_DBG_pre_bitfield |= DBG_ZH16ERR;
1404 1394
1405 // N2 1395 // N2
1406 temp_tissue = (temp_atem - pres_tissue[ci]) * var_e2secs; 1396 temp_tissue = (temp_atem - pres_tissue[ci]) * var_e2secs;
1407 temp_tissue_safety(); 1397 temp_tissue_safety();
1408 pres_tissue[ci] = pres_tissue[ci] + temp_tissue; 1398 pres_tissue[ci] = pres_tissue[ci] + temp_tissue;
1409 1399
1410 // He 1400 // He
1411 temp_tissue = (temp2_atem - pres_tissue[ci+16]) * var2_e2secs; 1401 temp_tissue = (temp2_atem - pres_tissue[ci+16]) * var2_e2secs;
1412 temp_tissue_safety(); 1402 temp_tissue_safety();
1413 pres_tissue[ci+16] = pres_tissue[ci+16] + temp_tissue; 1403 pres_tissue[ci+16] = pres_tissue[ci+16] + temp_tissue;
1414 1404
1415 temp_tissue = pres_tissue[ci] + pres_tissue[ci+16]; 1405 temp_tissue = pres_tissue[ci] + pres_tissue[ci+16];
1416 1406
1417 var_a = (var_a * pres_tissue[ci] + var2_a * pres_tissue[ci+16]) / temp_tissue; 1407 var_a = (var_a * pres_tissue[ci] + var2_a * pres_tissue[ci+16]) / temp_tissue;
1418 var_b = (var_b * pres_tissue[ci] + var2_b * pres_tissue[ci+16]) / temp_tissue; 1408 var_b = (var_b * pres_tissue[ci] + var2_b * pres_tissue[ci+16]) / temp_tissue;
1419 pres_tissue_limit[ci] = (temp_tissue - var_a) * var_b; 1409 pres_tissue_limit[ci] = (temp_tissue - var_a) * var_b;
1420 if (pres_tissue_limit[ci] < 0) 1410 if (pres_tissue_limit[ci] < 0)
1421 pres_tissue_limit[ci] = 0; 1411 pres_tissue_limit[ci] = 0;
1422 if (pres_tissue_limit[ci] > pres_gtissue_limit) 1412 if (pres_tissue_limit[ci] > pres_gtissue_limit)
1423 { 1413 {
1424 pres_gtissue_limit = pres_tissue_limit[ci]; 1414 pres_gtissue_limit = pres_tissue_limit[ci];
1425 char_O_gtissue_no = ci; 1415 char_O_gtissue_no = ci;
1426 }//if 1416 }//if
1427 } // for 1417 } // for
1428 }//calc_tissue(void) 1418 }//calc_tissue(void)
1429 1419
1430 // ---------------- 1420 // ----------------
1431 // calc_nullzeit // 1421 // calc_nullzeit //
1432 // ---------------- 1422 // ----------------
1479 // ------------------------- 1469 // -------------------------
1480 // backup_sim_pres_tissue // 1470 // backup_sim_pres_tissue //
1481 // ------------------------- 1471 // -------------------------
1482 void backup_sim_pres_tissue(void) 1472 void backup_sim_pres_tissue(void)
1483 { 1473 {
1484 for (x = 0;x<16;x++) 1474 for (x = 0;x<16;x++)
1485 { 1475 {
1486 sim_pres_tissue_backup[x] = sim_pres_tissue[x]; 1476 sim_pres_tissue_backup[x] = sim_pres_tissue[x];
1487 sim_pres_tissue_backup[x+16] = sim_pres_tissue[x+16]; 1477 sim_pres_tissue_backup[x+16] = sim_pres_tissue[x+16];
1488 } 1478 }
1489 } // backup_sim 1479 } // backup_sim
1490 1480
1491 // -------------------------- 1481 // --------------------------
1492 // restore_sim_pres_tissue // 1482 // restore_sim_pres_tissue //
1493 // -------------------------- 1483 // --------------------------
1494 void restore_sim_pres_tissue(void) 1484 void restore_sim_pres_tissue(void)
1495 { 1485 {
1496 for (x = 0;x<16;x++) 1486 for (x = 0;x<16;x++)
1497 { 1487 {
1498 sim_pres_tissue[x] = sim_pres_tissue_backup[x]; 1488 sim_pres_tissue[x] = sim_pres_tissue_backup[x];
1499 sim_pres_tissue[x+16] = sim_pres_tissue_backup[x+16]; 1489 sim_pres_tissue[x+16] = sim_pres_tissue_backup[x+16];
1500 } 1490 }
1501 } // restore_sim 1491 } // restore_sim
1502 1492
1503 // ------------------ 1493 // ------------------
1504 // calc_ascenttime // 1494 // calc_ascenttime //
1505 // ------------------ 1495 // ------------------
1506 1496
1507 void calc_ascenttime(void) 1497 void calc_ascenttime(void)
1508 { 1498 {
1509 if (pres_respiration > pres_surface) 1499 if (pres_respiration > pres_surface)
1510 { 1500 {
1511 switch (char_O_deco_status) 1501 switch (char_O_deco_status)
1512 { 1502 {
1513 case 2: 1503 case 2:
1514 char_O_ascenttime = 255; 1504 char_O_ascenttime = 255;
1515 break; 1505 break;
1516 case 1: 1506 case 1:
1517 break; 1507 break;
1518 default: 1508 default:
1519 temp1 = pres_respiration - pres_surface + 0.6; // + 0.6 hence 1 minute ascent time from a depth of 4 meter on 1509 temp1 = pres_respiration - pres_surface + 0.6; // + 0.6 hence 1 minute ascent time from a depth of 4 meter on
1520 if (temp1 < 0) 1510 if (temp1 < 0)
1521 temp1 = 0; 1511 temp1 = 0;
1522 if (temp1 > 255) 1512 if (temp1 > 255)
1523 temp1 = 255; 1513 temp1 = 255;
1524 char_O_ascenttime = (char)temp1; 1514 char_O_ascenttime = (char)temp1;
1525 1515
1526 for(ci=0;ci<7;ci++) 1516 for(ci=0;ci<7;ci++)
1527 { 1517 {
1528 x = char_O_ascenttime + char_O_array_decotime[ci]; 1518 x = char_O_ascenttime + char_O_array_decotime[ci];
1529 if (x < char_O_ascenttime) 1519 if (x < char_O_ascenttime)
1530 char_O_ascenttime = 255; 1520 char_O_ascenttime = 255;
1531 else 1521 else
1532 char_O_ascenttime = x; 1522 char_O_ascenttime = x;
1533 } 1523 }
1534 } 1524 break;
1535 } 1525 }
1536 else 1526 }
1537 char_O_ascenttime = 0; 1527 else
1528 char_O_ascenttime = 0;
1538 } // calc_ascenttime() 1529 } // calc_ascenttime()
1539 1530
1540 1531
1541 // --------------------- 1532 // ---------------------
1542 // update_startvalues // 1533 // update_startvalues //
1568 // ------------------ 1559 // ------------------
1569 // optimized in v.101 1560 // optimized in v.101
1570 1561
1571 void sim_tissue_1min(void) 1562 void sim_tissue_1min(void)
1572 { 1563 {
1573 temp_pres_gtissue_limit = 0.0; 1564 temp_pres_gtissue_limit = 0.0;
1574 temp_gtissue_no = 255; 1565 temp_gtissue_no = 255;
1575 1566
1576 for (ci=0;ci<16;ci++) 1567 for (ci=0;ci<16;ci++)
1577 { 1568 {
1578 _asm 1569 _asm
1579 movlw 0x02 1570 movlw 0x02
1580 movwf TBLPTRH,0 1571 movwf TBLPTRH,0
1581 movlb 4 // fuer ci 1572 movlb 4 // fuer ci
1582 movf ci,0,1 1573 movf ci,0,1
1583 addwf ci,0,1 1574 addwf ci,0,1
1584 addwf ci,0,1 1575 addwf ci,0,1
1585 addwf ci,0,1 1576 addwf ci,0,1
1586 addlw 0x80 1577 addlw 0x80
1587 movwf TBLPTRL,0 1578 movwf TBLPTRL,0
1588 TBLRDPOSTINC 1579 TBLRDPOSTINC
1589 movff TABLAT,var_a+1 1580 movff TABLAT,var_a+1
1590 TBLRDPOSTINC 1581 TBLRDPOSTINC
1591 movff TABLAT,var_a 1582 movff TABLAT,var_a
1592 TBLRDPOSTINC 1583 TBLRDPOSTINC
1593 movff TABLAT,var_a+3 1584 movff TABLAT,var_a+3
1594 TBLRD 1585 TBLRD
1595 movff TABLAT,var_a+2 1586 movff TABLAT,var_a+2
1596 addlw 0x40 1587 addlw 0x40
1597 movwf TBLPTRL,0 1588 movwf TBLPTRL,0
1598 TBLRDPOSTINC 1589 TBLRDPOSTINC
1599 movff TABLAT,var2_a+1 1590 movff TABLAT,var2_a+1
1600 TBLRDPOSTINC 1591 TBLRDPOSTINC
1601 movff TABLAT,var2_a 1592 movff TABLAT,var2_a
1602 TBLRDPOSTINC 1593 TBLRDPOSTINC
1603 movff TABLAT,var2_a+3 1594 movff TABLAT,var2_a+3
1604 TBLRD 1595 TBLRD
1605 movff TABLAT,var2_a+2 1596 movff TABLAT,var2_a+2
1606 addlw 0x40 1597 addlw 0x40
1607 movwf TBLPTRL,0 1598 movwf TBLPTRL,0
1608 incf TBLPTRH,1,0 1599 incf TBLPTRH,1,0
1609 TBLRDPOSTINC 1600 TBLRDPOSTINC
1610 movff TABLAT,var_b+1 1601 movff TABLAT,var_b+1
1611 TBLRDPOSTINC 1602 TBLRDPOSTINC
1612 movff TABLAT,var_b 1603 movff TABLAT,var_b
1613 TBLRDPOSTINC 1604 TBLRDPOSTINC
1614 movff TABLAT,var_b+3 1605 movff TABLAT,var_b+3
1615 TBLRD 1606 TBLRD
1616 movff TABLAT,var_b+2 1607 movff TABLAT,var_b+2
1617 addlw 0x40 1608 addlw 0x40
1618 movwf TBLPTRL,0 1609 movwf TBLPTRL,0
1619 TBLRDPOSTINC 1610 TBLRDPOSTINC
1620 movff TABLAT,var2_b+1 1611 movff TABLAT,var2_b+1
1621 TBLRDPOSTINC 1612 TBLRDPOSTINC
1622 movff TABLAT,var2_b 1613 movff TABLAT,var2_b
1623 TBLRDPOSTINC 1614 TBLRDPOSTINC
1624 movff TABLAT,var2_b+3 1615 movff TABLAT,var2_b+3
1625 TBLRD 1616 TBLRD
1626 movff TABLAT,var2_b+2 1617 movff TABLAT,var2_b+2
1627 addlw 0xC0 1618 addlw 0xC0
1628 movwf TBLPTRL,0 1619 movwf TBLPTRL,0
1629 incf TBLPTRH,1,0 1620 incf TBLPTRH,1,0
1630 TBLRDPOSTINC 1621 TBLRDPOSTINC
1631 movff TABLAT,var_e1min+1 1622 movff TABLAT,var_e1min+1
1632 TBLRDPOSTINC 1623 TBLRDPOSTINC
1633 movff TABLAT,var_e1min 1624 movff TABLAT,var_e1min
1634 TBLRDPOSTINC 1625 TBLRDPOSTINC
1635 movff TABLAT,var_e1min+3 1626 movff TABLAT,var_e1min+3
1636 TBLRD 1627 TBLRD
1637 movff TABLAT,var_e1min+2 1628 movff TABLAT,var_e1min+2
1638 addlw 0x40 1629 addlw 0x40
1639 movwf TBLPTRL,0 1630 movwf TBLPTRL,0
1640 TBLRDPOSTINC 1631 TBLRDPOSTINC
1641 movff TABLAT,var2_e1min+1 1632 movff TABLAT,var2_e1min+1
1642 TBLRDPOSTINC 1633 TBLRDPOSTINC
1643 movff TABLAT,var2_e1min 1634 movff TABLAT,var2_e1min
1644 TBLRDPOSTINC 1635 TBLRDPOSTINC
1645 movff TABLAT,var2_e1min+3 1636 movff TABLAT,var2_e1min+3
1646 TBLRD 1637 TBLRD
1647 movff TABLAT,var2_e1min+2 1638 movff TABLAT,var2_e1min+2
1648 _endasm 1639 _endasm
1649 // N2 1640
1650 temp_tissue = (temp_atem - sim_pres_tissue[ci]) * var_e1min; 1641 // N2
1651 temp_tissue_safety(); 1642 temp_tissue = (temp_atem - sim_pres_tissue[ci]) * var_e1min;
1652 sim_pres_tissue[ci] = sim_pres_tissue[ci] + temp_tissue; 1643 temp_tissue_safety();
1653 // He 1644 sim_pres_tissue[ci] = sim_pres_tissue[ci] + temp_tissue;
1654 temp_tissue = (temp2_atem - sim_pres_tissue[ci+16]) * var2_e1min; 1645
1655 temp_tissue_safety(); 1646 // He
1656 sim_pres_tissue[ci+16] = sim_pres_tissue[ci+16] + temp_tissue; 1647 temp_tissue = (temp2_atem - sim_pres_tissue[ci+16]) * var2_e1min;
1657 // pressure limit 1648 temp_tissue_safety();
1658 temp_tissue = sim_pres_tissue[ci] + sim_pres_tissue[ci+16]; 1649 sim_pres_tissue[ci+16] = sim_pres_tissue[ci+16] + temp_tissue;
1659 var_a = (var_a * sim_pres_tissue[ci] + var2_a * sim_pres_tissue[ci+16]) / temp_tissue; 1650
1660 var_b = (var_b * sim_pres_tissue[ci] + var2_b * sim_pres_tissue[ci+16]) / temp_tissue; 1651 // pressure limit
1661 sim_pres_tissue_limit[ci] = (temp_tissue - var_a) * var_b; 1652 temp_tissue = sim_pres_tissue[ci] + sim_pres_tissue[ci+16];
1662 1653 var_a = (var_a * sim_pres_tissue[ci] + var2_a * sim_pres_tissue[ci+16]) / temp_tissue;
1663 if (sim_pres_tissue_limit[ci] < 0) 1654 var_b = (var_b * sim_pres_tissue[ci] + var2_b * sim_pres_tissue[ci+16]) / temp_tissue;
1664 sim_pres_tissue_limit[ci] = 0; 1655 sim_pres_tissue_limit[ci] = (temp_tissue - var_a) * var_b;
1665 if (sim_pres_tissue_limit[ci] > temp_pres_gtissue_limit) 1656
1666 { 1657 if (sim_pres_tissue_limit[ci] < 0)
1667 temp_pres_gtissue = temp_tissue; 1658 sim_pres_tissue_limit[ci] = 0;
1668 temp_pres_gtissue_limit = sim_pres_tissue_limit[ci]; 1659 if (sim_pres_tissue_limit[ci] > temp_pres_gtissue_limit)
1669 temp_gtissue_no = ci; 1660 {
1670 } 1661 temp_pres_gtissue = temp_tissue;
1671 } // for 1662 temp_pres_gtissue_limit = sim_pres_tissue_limit[ci];
1672 temp_pres_gtissue_diff = temp_pres_gtissue_limit - temp_pres_gtissue; 1663 temp_gtissue_no = ci;
1673 temp_pres_gtissue_limit_GF_low = GF_low * temp_pres_gtissue_diff + temp_pres_gtissue; 1664 }
1674 temp_pres_gtissue_limit_GF_low_below_surface = temp_pres_gtissue_limit_GF_low - pres_surface; 1665 } // for
1675 if (temp_pres_gtissue_limit_GF_low_below_surface < 0) 1666
1676 temp_pres_gtissue_limit_GF_low_below_surface = 0; 1667 temp_pres_gtissue_diff = temp_pres_gtissue_limit - temp_pres_gtissue;
1668 temp_pres_gtissue_limit_GF_low = GF_low * temp_pres_gtissue_diff + temp_pres_gtissue;
1669 temp_pres_gtissue_limit_GF_low_below_surface = temp_pres_gtissue_limit_GF_low - pres_surface;
1670 if (temp_pres_gtissue_limit_GF_low_below_surface < 0)
1671 temp_pres_gtissue_limit_GF_low_below_surface = 0;
1677 } //sim_tissue_1min() 1672 } //sim_tissue_1min()
1678 1673
1679 //-------------------- 1674 //--------------------
1680 // sim_tissue_10min // 1675 // sim_tissue_10min //
1681 //-------------------- 1676 //--------------------
1685 1680
1686 // optimized in v.101 1681 // optimized in v.101
1687 1682
1688 void sim_tissue_10min(void) 1683 void sim_tissue_10min(void)
1689 { 1684 {
1690 temp_pres_gtissue_limit = 0.0; 1685 temp_pres_gtissue_limit = 0.0;
1691 temp_gtissue_no = 255; 1686 temp_gtissue_no = 255;
1692 1687
1693 for (ci=0;ci<16;ci++) 1688 for (ci=0;ci<16;ci++)
1694 { 1689 {
1695 _asm 1690 _asm
1696 movlw 0x02 1691 movlw 0x02
1697 movwf TBLPTRH,0 1692 movwf TBLPTRH,0
1698 movlb 4 // fuer ci 1693 movlb 4 // fuer ci
1699 movf ci,0,1 1694 movf ci,0,1
1700 addwf ci,0,1 1695 addwf ci,0,1
1701 addwf ci,0,1 1696 addwf ci,0,1
1702 addwf ci,0,1 1697 addwf ci,0,1
1703 addlw 0x80 1698 addlw 0x80
1704 movwf TBLPTRL,0 1699 movwf TBLPTRL,0
1705 TBLRDPOSTINC 1700 TBLRDPOSTINC
1706 movff TABLAT,var_a+1 1701 movff TABLAT,var_a+1
1707 TBLRDPOSTINC 1702 TBLRDPOSTINC
1708 movff TABLAT,var_a 1703 movff TABLAT,var_a
1709 TBLRDPOSTINC 1704 TBLRDPOSTINC
1710 movff TABLAT,var_a+3 1705 movff TABLAT,var_a+3
1711 TBLRD 1706 TBLRD
1712 movff TABLAT,var_a+2 1707 movff TABLAT,var_a+2
1713 addlw 0x40 1708 addlw 0x40
1714 movwf TBLPTRL,0 1709 movwf TBLPTRL,0
1715 TBLRDPOSTINC 1710 TBLRDPOSTINC
1716 movff TABLAT,var2_a+1 1711 movff TABLAT,var2_a+1
1717 TBLRDPOSTINC 1712 TBLRDPOSTINC
1718 movff TABLAT,var2_a 1713 movff TABLAT,var2_a
1719 TBLRDPOSTINC 1714 TBLRDPOSTINC
1720 movff TABLAT,var2_a+3 1715 movff TABLAT,var2_a+3
1721 TBLRD 1716 TBLRD
1722 movff TABLAT,var2_a+2 1717 movff TABLAT,var2_a+2
1723 addlw 0x40 1718 addlw 0x40
1724 movwf TBLPTRL,0 1719 movwf TBLPTRL,0
1725 incf TBLPTRH,1,0 1720 incf TBLPTRH,1,0
1726 TBLRDPOSTINC 1721 TBLRDPOSTINC
1727 movff TABLAT,var_b+1 1722 movff TABLAT,var_b+1
1728 TBLRDPOSTINC 1723 TBLRDPOSTINC
1729 movff TABLAT,var_b 1724 movff TABLAT,var_b
1730 TBLRDPOSTINC 1725 TBLRDPOSTINC
1731 movff TABLAT,var_b+3 1726 movff TABLAT,var_b+3
1732 TBLRD 1727 TBLRD
1733 movff TABLAT,var_b+2 1728 movff TABLAT,var_b+2
1734 addlw 0x40 1729 addlw 0x40
1735 movwf TBLPTRL,0 1730 movwf TBLPTRL,0
1736 TBLRDPOSTINC 1731 TBLRDPOSTINC
1737 movff TABLAT,var2_b+1 1732 movff TABLAT,var2_b+1
1738 TBLRDPOSTINC 1733 TBLRDPOSTINC
1739 movff TABLAT,var2_b 1734 movff TABLAT,var2_b
1740 TBLRDPOSTINC 1735 TBLRDPOSTINC
1741 movff TABLAT,var2_b+3 1736 movff TABLAT,var2_b+3
1742 TBLRD 1737 TBLRD
1743 movff TABLAT,var2_b+2 1738 movff TABLAT,var2_b+2
1744 addlw 0xC0 // different to 1 min 1739 addlw 0xC0 // different to 1 min
1745 movwf TBLPTRL,0 1740 movwf TBLPTRL,0
1746 incf TBLPTRH,1,0 1741 incf TBLPTRH,1,0
1747 incf TBLPTRH,1,0 // different to 1 min 1742 incf TBLPTRH,1,0 // different to 1 min
1748 TBLRDPOSTINC 1743 TBLRDPOSTINC
1749 movff TABLAT,var_e1min+1 1744 movff TABLAT,var_e1min+1
1750 TBLRDPOSTINC 1745 TBLRDPOSTINC
1751 movff TABLAT,var_e1min 1746 movff TABLAT,var_e1min
1752 TBLRDPOSTINC 1747 TBLRDPOSTINC
1753 movff TABLAT,var_e1min+3 1748 movff TABLAT,var_e1min+3
1754 TBLRD 1749 TBLRD
1755 movff TABLAT,var_e1min+2 1750 movff TABLAT,var_e1min+2
1756 addlw 0x40 1751 addlw 0x40
1757 movwf TBLPTRL,0 1752 movwf TBLPTRL,0
1758 //incf TBLPTRH,1,0 // different to 1 min 1753 //incf TBLPTRH,1,0 // different to 1 min
1759 TBLRDPOSTINC 1754 TBLRDPOSTINC
1760 movff TABLAT,var2_e1min+1 1755 movff TABLAT,var2_e1min+1
1761 TBLRDPOSTINC 1756 TBLRDPOSTINC
1762 movff TABLAT,var2_e1min 1757 movff TABLAT,var2_e1min
1763 TBLRDPOSTINC 1758 TBLRDPOSTINC
1764 movff TABLAT,var2_e1min+3 1759 movff TABLAT,var2_e1min+3
1765 TBLRD 1760 TBLRD
1766 movff TABLAT,var2_e1min+2 1761 movff TABLAT,var2_e1min+2
1767 _endasm 1762 _endasm
1768 // N2 1763
1769 temp_tissue = (temp_atem - sim_pres_tissue[ci]) * var_e1min; 1764 // N2
1770 temp_tissue_safety(); 1765 temp_tissue = (temp_atem - sim_pres_tissue[ci]) * var_e1min;
1771 sim_pres_tissue[ci] = sim_pres_tissue[ci] + temp_tissue; 1766 temp_tissue_safety();
1772 // He 1767 sim_pres_tissue[ci] = sim_pres_tissue[ci] + temp_tissue;
1773 temp_tissue = (temp2_atem - sim_pres_tissue[ci+16]) * var2_e1min; 1768 // He
1774 temp_tissue_safety(); 1769 temp_tissue = (temp2_atem - sim_pres_tissue[ci+16]) * var2_e1min;
1775 sim_pres_tissue[ci+16] = sim_pres_tissue[ci+16] + temp_tissue; 1770 temp_tissue_safety();
1776 // pressure limit 1771 sim_pres_tissue[ci+16] = sim_pres_tissue[ci+16] + temp_tissue;
1777 temp_tissue = sim_pres_tissue[ci] + sim_pres_tissue[ci+16]; 1772
1778 var_a = (var_a * sim_pres_tissue[ci] + var2_a * sim_pres_tissue[ci+16]) / temp_tissue; 1773 // pressure limit
1779 var_b = (var_b * sim_pres_tissue[ci] + var2_b * sim_pres_tissue[ci+16]) / temp_tissue; 1774 temp_tissue = sim_pres_tissue[ci] + sim_pres_tissue[ci+16];
1780 1775 var_a = (var_a * sim_pres_tissue[ci] + var2_a * sim_pres_tissue[ci+16]) / temp_tissue;
1781 sim_pres_tissue_limit[ci] = (temp_tissue - var_a) * var_b; 1776 var_b = (var_b * sim_pres_tissue[ci] + var2_b * sim_pres_tissue[ci+16]) / temp_tissue;
1782 if (sim_pres_tissue_limit[ci] < 0) 1777
1783 sim_pres_tissue_limit[ci] = 0; 1778 sim_pres_tissue_limit[ci] = (temp_tissue - var_a) * var_b;
1784 if (sim_pres_tissue_limit[ci] > temp_pres_gtissue_limit) 1779 if (sim_pres_tissue_limit[ci] < 0)
1785 { 1780 sim_pres_tissue_limit[ci] = 0;
1786 temp_pres_gtissue = temp_tissue; 1781 if (sim_pres_tissue_limit[ci] > temp_pres_gtissue_limit)
1787 temp_pres_gtissue_limit = sim_pres_tissue_limit[ci]; 1782 {
1788 temp_gtissue_no = ci; 1783 temp_pres_gtissue = temp_tissue;
1789 } 1784 temp_pres_gtissue_limit = sim_pres_tissue_limit[ci];
1790 } // for 1785 temp_gtissue_no = ci;
1786 }
1787 } // for
1788
1791 temp_pres_gtissue_diff = temp_pres_gtissue_limit - temp_pres_gtissue; // negative number 1789 temp_pres_gtissue_diff = temp_pres_gtissue_limit - temp_pres_gtissue; // negative number
1792 temp_pres_gtissue_limit_GF_low = GF_low * temp_pres_gtissue_diff + temp_pres_gtissue; 1790 temp_pres_gtissue_limit_GF_low = GF_low * temp_pres_gtissue_diff + temp_pres_gtissue;
1793 temp_pres_gtissue_limit_GF_low_below_surface = temp_pres_gtissue_limit_GF_low - pres_surface; 1791 temp_pres_gtissue_limit_GF_low_below_surface = temp_pres_gtissue_limit_GF_low - pres_surface;
1794 if (temp_pres_gtissue_limit_GF_low_below_surface < 0) 1792 if (temp_pres_gtissue_limit_GF_low_below_surface < 0)
1795 temp_pres_gtissue_limit_GF_low_below_surface = 0; 1793 temp_pres_gtissue_limit_GF_low_below_surface = 0;
1801 // ------------------ 1799 // ------------------
1802 // unchanged in v.101 1800 // unchanged in v.101
1803 1801
1804 void clear_decoarray(void) 1802 void clear_decoarray(void)
1805 { 1803 {
1806 char_O_array_decodepth[0] = 0; 1804 char_O_array_decodepth[0] = 0;
1807 char_O_array_decodepth[1] = 0; 1805 char_O_array_decodepth[1] = 0;
1808 char_O_array_decodepth[2] = 0; 1806 char_O_array_decodepth[2] = 0;
1809 char_O_array_decodepth[3] = 0; 1807 char_O_array_decodepth[3] = 0;
1810 char_O_array_decodepth[4] = 0; 1808 char_O_array_decodepth[4] = 0;
1811 char_O_array_decodepth[5] = 0; 1809 char_O_array_decodepth[5] = 0;
1812 char_O_array_decotime[0] = 0; 1810 char_O_array_decotime[0] = 0;
1813 char_O_array_decotime[1] = 0; 1811 char_O_array_decotime[1] = 0;
1814 char_O_array_decotime[2] = 0; 1812 char_O_array_decotime[2] = 0;
1815 char_O_array_decotime[3] = 0; 1813 char_O_array_decotime[3] = 0;
1816 char_O_array_decotime[4] = 0; 1814 char_O_array_decotime[4] = 0;
1817 char_O_array_decotime[5] = 0; 1815 char_O_array_decotime[5] = 0;
1818 char_O_array_decotime[6] = 0; 1816 char_O_array_decotime[6] = 0;
1819 } // clear_decoarray 1817 } // clear_decoarray
1820 1818
1821 1819
1822 // ------------------- 1820 // -------------------
1823 // update_decoarray // 1821 // update_decoarray //
1929 // optimized in v.101 (var_a) 1927 // optimized in v.101 (var_a)
1930 // new code in v.102 1928 // new code in v.102
1931 1929
1932 void deco_gradient_array() 1930 void deco_gradient_array()
1933 { 1931 {
1934 RESET_C_STACK 1932 RESET_C_STACK
1935 pres_respiration = (float)int_I_pres_respiration / 1000.0; // assembler code uses different digit system 1933 pres_respiration = (float)int_I_pres_respiration / 1000.0; // assembler code uses different digit system
1936 for (ci=0;ci<16;ci++) 1934 for (ci=0;ci<16;ci++)
1937 { 1935 {
1938 temp_tissue = pres_tissue[ci] + pres_tissue[ci+16]; 1936 temp_tissue = pres_tissue[ci] + pres_tissue[ci+16];
1939 temp1 = temp_tissue - pres_respiration; 1937 temp1 = temp_tissue - pres_respiration;
1940 temp2 = temp_tissue - pres_tissue_limit[ci]; 1938 temp2 = temp_tissue - pres_tissue_limit[ci];
1941 temp2 = temp1/temp2; 1939 temp2 = temp1/temp2;
1942 temp2 = temp2 * 200; // because of output in (Double-)percentage 1940 temp2 = temp2 * 200; // because of output in (Double-)percentage
1943 if (temp2 < 0) 1941 if (temp2 < 0)
1944 temp2 = 0; 1942 temp2 = 0;
1945 if (temp2 > 255) 1943 if (temp2 > 255)
1946 temp2 = 255; 1944 temp2 = 255;
1947 if (temp1 < 0) 1945 if (temp1 < 0)
1948 char_O_array_gradient_weighted[ci] = 0; 1946 char_O_array_gradient_weighted[ci] = 0;
1949 else 1947 else
1950 char_O_array_gradient_weighted[ci] = (char)temp2; 1948 char_O_array_gradient_weighted[ci] = (char)temp2;
1951 } // for 1949 } // for
1952 } // deco_gradient_array 1950 } // deco_gradient_array
1953 1951
1954 1952
1955 // ------------------------------ 1953 // ------------------------------
1956 // deco_calc_desaturation_time // 1954 // deco_calc_desaturation_time //
1960 1958
1961 void deco_calc_desaturation_time(void) 1959 void deco_calc_desaturation_time(void)
1962 { 1960 {
1963 RESET_C_STACK 1961 RESET_C_STACK
1964 1962
1965 N2_ratio = 0.7902; // FIXED sum as stated in b"uhlmann 1963 N2_ratio = 0.7902; // FIXED sum as stated in b"uhlmann
1966 pres_surface = (float)int_I_pres_surface / 1000.0; 1964 pres_surface = (float)int_I_pres_surface / 1000.0;
1967 temp_atem = N2_ratio * (pres_surface - 0.0627); 1965 temp_atem = N2_ratio * (pres_surface - 0.0627);
1968 int_O_desaturation_time = 0; 1966 int_O_desaturation_time = 0;
1969 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142) 1967 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142)
1970 1968
1971 for (ci=0;ci<16;ci++) 1969 for (ci=0;ci<16;ci++)
1972 { 1970 {
1973 _asm 1971 _asm
1974 movlw 0x04 1972 movlw 0x04
1975 movwf TBLPTRH,0 1973 movwf TBLPTRH,0
1976 movlb 4 // fuer ci 1974 movlb 4 // fuer ci
1977 movf ci,0,1 1975 movf ci,0,1
1978 addwf ci,0,1 1976 addwf ci,0,1
1979 addwf ci,0,1 1977 addwf ci,0,1
1980 addwf ci,0,1 1978 addwf ci,0,1
1981 addlw 0x80 1979 addlw 0x80
1982 movwf TBLPTRL,0 1980 movwf TBLPTRL,0
1983 TBLRDPOSTINC 1981 TBLRDPOSTINC
1984 movff TABLAT,var_halftimes+1 1982 movff TABLAT,var_halftimes+1
1985 TBLRDPOSTINC 1983 TBLRDPOSTINC
1986 movff TABLAT,var_halftimes 1984 movff TABLAT,var_halftimes
1987 TBLRDPOSTINC 1985 TBLRDPOSTINC
1988 movff TABLAT,var_halftimes+3 1986 movff TABLAT,var_halftimes+3
1989 TBLRD 1987 TBLRD
1990 movff TABLAT,var_halftimes+2 1988 movff TABLAT,var_halftimes+2
1991 addlw 0x40 1989 addlw 0x40
1992 movwf TBLPTRL,0 1990 movwf TBLPTRL,0
1993 TBLRDPOSTINC 1991 TBLRDPOSTINC
1994 movff TABLAT,var2_halftimes+1 1992 movff TABLAT,var2_halftimes+1
1995 TBLRDPOSTINC 1993 TBLRDPOSTINC
1996 movff TABLAT,var2_halftimes 1994 movff TABLAT,var2_halftimes
1997 TBLRDPOSTINC 1995 TBLRDPOSTINC
1998 movff TABLAT,var2_halftimes+3 1996 movff TABLAT,var2_halftimes+3
1999 TBLRD 1997 TBLRD
2000 movff TABLAT,var2_halftimes+2 1998 movff TABLAT,var2_halftimes+2
2001 _endasm 1999 _endasm
2002 2000
2003 // saturation_time (for flight) and N2_saturation in multiples of halftime 2001 // saturation_time (for flight) and N2_saturation in multiples of halftime
2004 // version v.100: 1.1 = 10 percent distance to totally clean (totally clean is not possible, would take infinite time ) 2002 // version v.100: 1.1 = 10 percent distance to totally clean (totally clean is not possible, would take infinite time )
2005 // new in version v.101: 1.07 = 7 percent distance to totally clean (totally clean is not possible, would take infinite time ) 2003 // new in version v.101: 1.07 = 7 percent distance to totally clean (totally clean is not possible, would take infinite time )
2006 // changes in v.101: 1.05 = 5 percent dist to totally clean is new desaturation point for display and noFly calculations 2004 // changes in v.101: 1.05 = 5 percent dist to totally clean is new desaturation point for display and noFly calculations
2007 // N2 2005 // N2
2008 temp1 = 1.05 * temp_atem; 2006 temp1 = 1.05 * temp_atem;
2009 temp1 = temp1 - pres_tissue[ci]; 2007 temp1 = temp1 - pres_tissue[ci];
2010 temp2 = temp_atem - pres_tissue[ci]; 2008 temp2 = temp_atem - pres_tissue[ci];
2011 if (temp2 >= 0.0) 2009 if (temp2 >= 0.0)
2012 { 2010 {
2013 temp1 = 0; 2011 temp1 = 0;
2014 temp2 = 0; 2012 temp2 = 0;
2015 } 2013 }
2016 else 2014 else
2017 temp1 = temp1 / temp2; 2015 temp1 = temp1 / temp2;
2018 if (temp1 > 0.0) 2016 if (temp1 > 0.0)
2019 { 2017 {
2020 temp1 = log(1.0 - temp1); 2018 temp1 = log(1.0 - temp1);
2021 temp1 = temp1 / -0.6931; // temp1 is the multiples of half times necessary. 2019 temp1 = temp1 / -0.6931; // temp1 is the multiples of half times necessary.
2022 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested. 2020 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested.
2023 // minus because log is negative 2021 // minus because log is negative
2024 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 2022 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
2025 } 2023 }
2026 else 2024 else
2027 { 2025 {
2028 temp1 = 0; 2026 temp1 = 0;
2029 temp2 = 0; 2027 temp2 = 0;
2030 } 2028 }
2031 2029
2032 // He 2030 // He
2033 temp3 = 0.1 - pres_tissue[ci+16]; 2031 temp3 = 0.1 - pres_tissue[ci+16];
2034 if (temp3 >= 0.0) 2032 if (temp3 >= 0.0)
2035 { 2033 {
2036 temp3 = 0; 2034 temp3 = 0;
2037 temp4 = 0; 2035 temp4 = 0;
2038 } 2036 }
2039 else 2037 else
2040 temp3 = -1.0 * temp3 / pres_tissue[ci+16]; 2038 temp3 = -1.0 * temp3 / pres_tissue[ci+16];
2041 if (temp3 > 0.0) 2039 if (temp3 > 0.0)
2042 { 2040 {
2043 temp3 = log(1.0 - temp3); 2041 temp3 = log(1.0 - temp3);
2044 temp3 = temp3 / -0.6931; // temp1 is the multiples of half times necessary. 2042 temp3 = temp3 / -0.6931; // temp1 is the multiples of half times necessary.
2045 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested. 2043 // 0.6931 is ln(2), because the math function log() calculates with a base of e not 2 as requested.
2046 // minus because log is negative 2044 // minus because log is negative
2047 temp4 = var2_halftimes * temp3 / float_desaturation_multiplier; // time necessary (in minutes ) for "complete" desaturation, new in v.101 float_desaturation_multiplier 2045 temp4 = var2_halftimes * temp3 / float_desaturation_multiplier; // time necessary (in minutes ) for "complete" desaturation, new in v.101 float_desaturation_multiplier
2048 } 2046 }
2049 else 2047 else
2050 { 2048 {
2051 temp3 = 0; 2049 temp3 = 0;
2052 temp4 = 0; 2050 temp4 = 0;
2053 } 2051 }
2054 2052
2055 // saturation_time (for flight) 2053 // saturation_time (for flight)
2056 if (temp4 > temp2) 2054 if (temp4 > temp2)
2057 int_temp = (int)temp4; 2055 int_temp = (int)temp4;
2058 else 2056 else
2059 int_temp = (int)temp2; 2057 int_temp = (int)temp2;
2060 if(int_temp > int_O_desaturation_time) 2058 if(int_temp > int_O_desaturation_time)
2061 int_O_desaturation_time = int_temp; 2059 int_O_desaturation_time = int_temp;
2062 2060
2063 // N2 saturation in multiples of halftime for display purposes 2061 // N2 saturation in multiples of halftime for display purposes
2064 temp2 = temp1 * 20.0; // 0 = 1/8, 120 = 0, 249 = 8 2062 temp2 = temp1 * 20.0; // 0 = 1/8, 120 = 0, 249 = 8
2065 temp2 = temp2 + 80.0; // set center 2063 temp2 = temp2 + 80.0; // set center
2066 if (temp2 < 0.0) 2064 if (temp2 < 0.0)
2067 temp2 = 0.0; 2065 temp2 = 0.0;
2068 if (temp2 > 255.0) 2066 if (temp2 > 255.0)
2069 temp2 = 255.0; 2067 temp2 = 255.0;
2070 char_O_tissue_saturation[ci] = (char)temp2; 2068 char_O_tissue_saturation[ci] = (char)temp2;
2071 // He saturation in multiples of halftime for display purposes 2069 // He saturation in multiples of halftime for display purposes
2072 temp4 = temp3 * 20.0; // 0 = 1/8, 120 = 0, 249 = 8 2070 temp4 = temp3 * 20.0; // 0 = 1/8, 120 = 0, 249 = 8
2073 temp4 = temp4 + 80.0; // set center 2071 temp4 = temp4 + 80.0; // set center
2074 if (temp4 < 0.0) 2072 if (temp4 < 0.0)
2075 temp4 = 0.0; 2073 temp4 = 0.0;
2076 if (temp4 > 255.0) 2074 if (temp4 > 255.0)
2077 temp4 = 255.0; 2075 temp4 = 255.0;
2078 char_O_tissue_saturation[ci+16] = (char)temp4; 2076 char_O_tissue_saturation[ci+16] = (char)temp4;
2079 } // for 2077 } // for
2080 } // deco_calc_desaturation_time 2078 } // deco_calc_desaturation_time
2081 2079
2082 2080
2083 // -------------------------- 2081 // --------------------------
2084 // calc_wo_deco_step_1_min // 2082 // calc_wo_deco_step_1_min //
2093 { 2091 {
2094 flag_in_divemode = 0; 2092 flag_in_divemode = 0;
2095 set_dbg_end_of_dive(); 2093 set_dbg_end_of_dive();
2096 } 2094 }
2097 2095
2098 N2_ratio = 0.7902; // FIXED, sum lt. buehlmann 2096 N2_ratio = 0.7902; // FIXED, sum lt. buehlmann
2099 pres_respiration = (float)int_I_pres_respiration / 1000.0; // assembler code uses different digit system 2097 pres_respiration = (float)int_I_pres_respiration / 1000.0; // assembler code uses different digit system
2100 pres_surface = (float)int_I_pres_surface / 1000.0; 2098 pres_surface = (float)int_I_pres_surface / 1000.0;
2101 temp_atem = N2_ratio * (pres_respiration - 0.0627); // 0.0627 is the extra pressure in the body 2099 temp_atem = N2_ratio * (pres_respiration - 0.0627); // 0.0627 is the extra pressure in the body
2102 temp2_atem = 0.0; 2100 temp2_atem = 0.0;
2103 temp_surface = pres_surface; // the b"uhlmann formula using temp_surface does not use the N2_ratio 2101 temp_surface = pres_surface; // the b"uhlmann formula using temp_surface does not use the N2_ratio
2104 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142) 2102 float_desaturation_multiplier = char_I_desaturation_multiplier / 142.0; // new in v.101 (70,42%/100.=142)
2105 float_saturation_multiplier = char_I_saturation_multiplier / 100.0; 2103 float_saturation_multiplier = char_I_saturation_multiplier / 100.0;
2106 2104
2107 calc_tissue_step_1_min(); // update the pressure in the 16 tissues in accordance with the new ambient pressure 2105 calc_tissue_step_1_min(); // update the pressure in the 16 tissues in accordance with the new ambient pressure
2108 clear_decoarray(); 2106 clear_decoarray();
2109 char_O_deco_status = 0; 2107 char_O_deco_status = 0;
2110 char_O_nullzeit = 0; 2108 char_O_nullzeit = 0;
2111 char_O_ascenttime = 0; 2109 char_O_ascenttime = 0;
2112 calc_gradient_factor(); 2110 calc_gradient_factor();
2113 2111
2114 } // calc_wo_deco_step_1_min(void) 2112 } // calc_wo_deco_step_1_min(void)
2115 2113
2116 2114
2117 // ------------------------- 2115 // -------------------------
2119 // ------------------------- 2117 // -------------------------
2120 // optimized in v.101 2118 // optimized in v.101
2121 2119
2122 void calc_tissue_step_1_min(void) 2120 void calc_tissue_step_1_min(void)
2123 { 2121 {
2124 char_O_gtissue_no = 255; 2122 char_O_gtissue_no = 255;
2125 pres_gtissue_limit = 0.0; 2123 pres_gtissue_limit = 0.0;
2126 2124
2127 for (ci=0;ci<16;ci++) 2125 for (ci=0;ci<16;ci++)
2128 { 2126 {
2129 _asm 2127 _asm
2130 movlw 0x02 2128 movlw 0x02
2131 movwf TBLPTRH,0 2129 movwf TBLPTRH,0
2132 movlb 4 // fuer ci 2130 movlb 4 // fuer ci
2133 movf ci,0,1 2131 movf ci,0,1
2134 addwf ci,0,1 2132 addwf ci,0,1
2135 addwf ci,0,1 2133 addwf ci,0,1
2136 addwf ci,0,1 2134 addwf ci,0,1
2137 addlw 0x80 2135 addlw 0x80
2138 movwf TBLPTRL,0 2136 movwf TBLPTRL,0
2139 TBLRDPOSTINC 2137 TBLRDPOSTINC
2140 movff TABLAT,var_a+1 2138 movff TABLAT,var_a+1
2141 TBLRDPOSTINC 2139 TBLRDPOSTINC
2142 movff TABLAT,var_a 2140 movff TABLAT,var_a
2143 TBLRDPOSTINC 2141 TBLRDPOSTINC
2144 movff TABLAT,var_a+3 2142 movff TABLAT,var_a+3
2145 TBLRD 2143 TBLRD
2146 movff TABLAT,var_a+2 2144 movff TABLAT,var_a+2
2147 addlw 0x40 2145 addlw 0x40
2148 movwf TBLPTRL,0 2146 movwf TBLPTRL,0
2149 TBLRDPOSTINC 2147 TBLRDPOSTINC
2150 movff TABLAT,var2_a+1 2148 movff TABLAT,var2_a+1
2151 TBLRDPOSTINC 2149 TBLRDPOSTINC
2152 movff TABLAT,var2_a 2150 movff TABLAT,var2_a
2153 TBLRDPOSTINC 2151 TBLRDPOSTINC
2154 movff TABLAT,var2_a+3 2152 movff TABLAT,var2_a+3
2155 TBLRD 2153 TBLRD
2156 movff TABLAT,var2_a+2 2154 movff TABLAT,var2_a+2
2157 addlw 0x40 2155 addlw 0x40
2158 movwf TBLPTRL,0 2156 movwf TBLPTRL,0
2159 incf TBLPTRH,1,0 2157 incf TBLPTRH,1,0
2160 TBLRDPOSTINC 2158 TBLRDPOSTINC
2161 movff TABLAT,var_b+1 2159 movff TABLAT,var_b+1
2162 TBLRDPOSTINC 2160 TBLRDPOSTINC
2163 movff TABLAT,var_b 2161 movff TABLAT,var_b
2164 TBLRDPOSTINC 2162 TBLRDPOSTINC
2165 movff TABLAT,var_b+3 2163 movff TABLAT,var_b+3
2166 TBLRD 2164 TBLRD
2167 movff TABLAT,var_b+2 2165 movff TABLAT,var_b+2
2168 addlw 0x40 2166 addlw 0x40
2169 movwf TBLPTRL,0 2167 movwf TBLPTRL,0
2170 TBLRDPOSTINC 2168 TBLRDPOSTINC
2171 movff TABLAT,var2_b+1 2169 movff TABLAT,var2_b+1
2172 TBLRDPOSTINC 2170 TBLRDPOSTINC
2173 movff TABLAT,var2_b 2171 movff TABLAT,var2_b
2174 TBLRDPOSTINC 2172 TBLRDPOSTINC
2175 movff TABLAT,var2_b+3 2173 movff TABLAT,var2_b+3
2176 TBLRD 2174 TBLRD
2177 movff TABLAT,var2_b+2 2175 movff TABLAT,var2_b+2
2178 addlw 0xC0 2176 addlw 0xC0
2179 movwf TBLPTRL,0 2177 movwf TBLPTRL,0
2180 incf TBLPTRH,1,0 2178 incf TBLPTRH,1,0
2181 TBLRDPOSTINC 2179 TBLRDPOSTINC
2182 movff TABLAT,var_e1min+1 2180 movff TABLAT,var_e1min+1
2183 TBLRDPOSTINC 2181 TBLRDPOSTINC
2184 movff TABLAT,var_e1min 2182 movff TABLAT,var_e1min
2185 TBLRDPOSTINC 2183 TBLRDPOSTINC
2186 movff TABLAT,var_e1min+3 2184 movff TABLAT,var_e1min+3
2187 TBLRD 2185 TBLRD
2188 movff TABLAT,var_e1min+2 2186 movff TABLAT,var_e1min+2
2189 addlw 0x40 2187 addlw 0x40
2190 movwf TBLPTRL,0 2188 movwf TBLPTRL,0
2191 TBLRDPOSTINC 2189 TBLRDPOSTINC
2192 movff TABLAT,var2_e1min+1 2190 movff TABLAT,var2_e1min+1
2193 TBLRDPOSTINC 2191 TBLRDPOSTINC
2194 movff TABLAT,var2_e1min 2192 movff TABLAT,var2_e1min
2195 TBLRDPOSTINC 2193 TBLRDPOSTINC
2196 movff TABLAT,var2_e1min+3 2194 movff TABLAT,var2_e1min+3
2197 TBLRD 2195 TBLRD
2198 movff TABLAT,var2_e1min+2 2196 movff TABLAT,var2_e1min+2
2199 _endasm 2197 _endasm
2200 2198
2201 // N2 1 min 2199 // N2 1 min
2202 temp_tissue = (temp_atem - pres_tissue[ci]) * var_e1min; 2200 temp_tissue = (temp_atem - pres_tissue[ci]) * var_e1min;
2203 temp_tissue_safety(); 2201 temp_tissue_safety();
2204 pres_tissue[ci] = pres_tissue[ci] + temp_tissue; 2202 pres_tissue[ci] = pres_tissue[ci] + temp_tissue;
2205 2203
2206 // He 1 min 2204 // He 1 min
2207 temp_tissue = (temp2_atem - pres_tissue[ci+16]) * var2_e1min; 2205 temp_tissue = (temp2_atem - pres_tissue[ci+16]) * var2_e1min;
2208 temp_tissue_safety(); 2206 temp_tissue_safety();
2209 pres_tissue[ci+16] = pres_tissue[ci+16] + temp_tissue; 2207 pres_tissue[ci+16] = pres_tissue[ci+16] + temp_tissue;
2210 2208
2211 temp_tissue = pres_tissue[ci] + pres_tissue[ci+16]; 2209 temp_tissue = pres_tissue[ci] + pres_tissue[ci+16];
2212 var_a = (var_a * pres_tissue[ci] + var2_a * pres_tissue[ci+16]) / temp_tissue; 2210 var_a = (var_a * pres_tissue[ci] + var2_a * pres_tissue[ci+16]) / temp_tissue;
2213 var_b = (var_b * pres_tissue[ci] + var2_b * pres_tissue[ci+16]) / temp_tissue; 2211 var_b = (var_b * pres_tissue[ci] + var2_b * pres_tissue[ci+16]) / temp_tissue;
2214 pres_tissue_limit[ci] = (temp_tissue - var_a) * var_b; 2212 pres_tissue_limit[ci] = (temp_tissue - var_a) * var_b;
2215 if (pres_tissue_limit[ci] < 0) 2213 if (pres_tissue_limit[ci] < 0)
2216 pres_tissue_limit[ci] = 0; 2214 pres_tissue_limit[ci] = 0;
2217 if (pres_tissue_limit[ci] > pres_gtissue_limit) 2215 if (pres_tissue_limit[ci] > pres_gtissue_limit)
2218 { 2216 {
2219 pres_gtissue_limit = pres_tissue_limit[ci]; 2217 pres_gtissue_limit = pres_tissue_limit[ci];
2220 char_O_gtissue_no = ci; 2218 char_O_gtissue_no = ci;
2221 }//if 2219 }//if
2222 2220
2223 if(!char_I_step_is_1min) 2221 if(!char_I_step_is_1min)
2224 { 2222 {
2225 // gradient factor array for graphical display 2223 // gradient factor array for graphical display
2226 // display range is 0 to 250! in steps of 5 for 1 pixel 2224 // display range is 0 to 250! in steps of 5 for 1 pixel
2227 // the display is divided in 6 blocks 2225 // the display is divided in 6 blocks
2228 // -> double the gradient 100% = 200 2226 // -> double the gradient 100% = 200
2229 // tissue > respiration (entsaettigungsvorgang) 2227 // tissue > respiration (entsaettigungsvorgang)
2230 // gradient ist wieviel prozent an limit von tissue aus 2228 // gradient ist wieviel prozent an limit von tissue aus
2231 // dh. 0% = respiration == tissue 2229 // dh. 0% = respiration == tissue
2232 // dh. 100% = respiration == limit 2230 // dh. 100% = respiration == limit
2233 temp1 = temp_tissue - pres_respiration; 2231 temp1 = temp_tissue - pres_respiration;
2234 temp2 = temp_tissue - pres_tissue_limit[ci]; // changed in v.102 2232 temp2 = temp_tissue - pres_tissue_limit[ci]; // changed in v.102
2235 temp2 = temp1/temp2; 2233 temp2 = temp1/temp2;
2236 temp2 = temp2 * 200; // because of output in (Double-)percentage 2234 temp2 = temp2 * 200; // because of output in (Double-)percentage
2237 if (temp2 < 0) 2235 if (temp2 < 0)
2238 temp2 = 0; 2236 temp2 = 0;
2239 if (temp2 > 255) 2237 if (temp2 > 255)
2240 temp2 = 255; 2238 temp2 = 255;
2241 if (temp1 < 0) 2239 if (temp1 < 0)
2242 char_O_array_gradient_weighted[ci] = 0; 2240 char_O_array_gradient_weighted[ci] = 0;
2243 else 2241 else
2244 char_O_array_gradient_weighted[ci] = (char)temp2; 2242 char_O_array_gradient_weighted[ci] = (char)temp2;
2245 } 2243 }
2246 } // for 2244 } // for
2247 } // calc wo deco 1min 2245 } // calc wo deco 1min
2248 2246
2249 // ---------- 2247 // ----------
2250 // deco_hash // 2248 // deco_hash //
2251 // ---------- 2249 // ----------
2252 void deco_hash(void) 2250 void deco_hash(void)
2253 { 2251 {
2254 RESET_C_STACK 2252 RESET_C_STACK
2255 // init 2253
2256 for (md_i=0;md_i<16;md_i++) 2254 // init
2257 { 2255 for (md_i=0;md_i<16;md_i++)
2258 md_state[md_i] = 0; 2256 {
2259 md_cksum[md_i] = 0; 2257 md_state[md_i] = 0;
2260 } // for md_i 16 2258 md_cksum[md_i] = 0;
2261 2259 } // for md_i 16
2262 _asm 2260
2263 movlw 0x01 2261 _asm
2264 movwf TBLPTRU,0 2262 movlw 0x01
2265 movlw 0x06 2263 movwf TBLPTRU,0
2266 movwf TBLPTRH,0 2264 movlw 0x06
2267 movlw 0x00 2265 movwf TBLPTRH,0
2268 movwf TBLPTRL,0 2266 movlw 0x00
2269 _endasm; 2267 movwf TBLPTRL,0
2270 for (md_i=0;md_i<127;md_i++) 2268 _endasm;
2271 { 2269 for (md_i=0;md_i<127;md_i++)
2272 _asm 2270 {
2273 TBLRDPOSTINC 2271 _asm
2274 movff TABLAT,md_temp 2272 TBLRDPOSTINC
2275 _endasm 2273 movff TABLAT,md_temp
2276 md_pi_subst[md_i] = md_temp; 2274 _endasm
2277 } // for md_i 256 2275 md_pi_subst[md_i] = md_temp;
2278 _asm 2276 } // for md_i 256
2279 TBLRDPOSTINC 2277 _asm
2280 movff TABLAT,md_temp 2278 TBLRDPOSTINC
2281 _endasm; 2279 movff TABLAT,md_temp
2282 md_pi_subst[127] = md_temp; 2280 _endasm;
2283 for (md_i=0;md_i<127;md_i++) 2281 md_pi_subst[127] = md_temp;
2284 { 2282 for (md_i=0;md_i<127;md_i++)
2285 _asm 2283 {
2286 TBLRDPOSTINC 2284 _asm
2287 movff TABLAT,md_temp 2285 TBLRDPOSTINC
2288 _endasm 2286 movff TABLAT,md_temp
2289 md_pi_subst[md_i+128] = md_temp; 2287 _endasm
2290 } // for md_i 256 2288 md_pi_subst[md_i+128] = md_temp;
2291 _asm 2289 } // for md_i 256
2292 TBLRD 2290 _asm
2293 movff TABLAT,md_temp 2291 TBLRD
2294 _endasm 2292 movff TABLAT,md_temp
2295 md_pi_subst[255] = md_temp; 2293 _endasm
2296 2294 md_pi_subst[255] = md_temp;
2297 _asm 2295
2298 movlw 0x00 2296 _asm
2299 movwf TBLPTRU,0 2297 movlw 0x00
2300 movlw 0x00 2298 movwf TBLPTRU,0
2301 movwf TBLPTRH,0 2299 movlw 0x00
2302 movlw 0x00 2300 movwf TBLPTRH,0
2303 movwf TBLPTRL,0 2301 movlw 0x00
2304 _endasm 2302 movwf TBLPTRL,0
2305 // cycle buffers 2303 _endasm
2306 for (md_pointer=0x0000;md_pointer<0x17f3;md_pointer++) 2304 // cycle buffers
2307 { 2305 for (md_pointer=0x0000;md_pointer<0x17f3;md_pointer++)
2308 md_t = 0; 2306 {
2309 for (md_i=0;md_i<16;md_i++) 2307 md_t = 0;
2310 { 2308 for (md_i=0;md_i<16;md_i++)
2311 if(md_pointer == 9) 2309 {
2312 md_temp = md_cksum[md_i]; 2310 if(md_pointer == 9)
2313 else 2311 md_temp = md_cksum[md_i];
2314 { 2312 else
2315 _asm 2313 {
2316 TBLRDPOSTINC 2314 _asm
2317 movff TABLAT,md_temp 2315 TBLRDPOSTINC
2318 _endasm 2316 movff TABLAT,md_temp
2319 } // else 2317 _endasm
2320 md_buffer[md_i] = md_temp; 2318 } // else
2321 md_state[md_i+16] = md_buffer[md_i]; 2319 md_buffer[md_i] = md_temp;
2322 md_state[md_i+32] = (unsigned char)(md_buffer[md_i] ^ md_state[md_i]); 2320 md_state[md_i+16] = md_buffer[md_i];
2323 } // for md_i 16 2321 md_state[md_i+32] = (unsigned char)(md_buffer[md_i] ^ md_state[md_i]);
2324 2322 } // for md_i 16
2325 for (md_i=0;md_i<18;md_i++) 2323
2326 { 2324 for (md_i=0;md_i<18;md_i++)
2327 for (md_j=0;md_j<48;md_j++) 2325 {
2328 { 2326 for (md_j=0;md_j<48;md_j++)
2329 md_state[md_j] = (unsigned char)(md_state[md_j] ^ md_pi_subst[md_t]); 2327 {
2330 md_t = md_state[md_j]; 2328 md_state[md_j] = (unsigned char)(md_state[md_j] ^ md_pi_subst[md_t]);
2331 } // for md_j 48 2329 md_t = md_state[md_j];
2332 md_t = (unsigned char)(md_t+1); 2330 } // for md_j 48
2333 } // for md_i 18 2331 md_t = (unsigned char)(md_t+1);
2334 md_t = md_cksum[15]; 2332 } // for md_i 18
2335 2333 md_t = md_cksum[15];
2336 for (md_i=0;md_i<16;md_i++) 2334
2337 { 2335 for (md_i=0;md_i<16;md_i++)
2338 md_cksum[md_i] = (unsigned char)(md_cksum[md_i] ^ md_pi_subst[(md_buffer[md_i] ^ md_t)]); 2336 {
2339 md_t = md_cksum[md_i]; 2337 md_cksum[md_i] = (unsigned char)(md_cksum[md_i] ^ md_pi_subst[(md_buffer[md_i] ^ md_t)]);
2340 } // for md_i 16 2338 md_t = md_cksum[md_i];
2341 } // for md_pointer 2339 } // for md_i 16
2340 } // for md_pointer
2342 } // void deco_hash(void) 2341 } // void deco_hash(void)
2343 2342
2344 // --------------------- 2343 // ---------------------
2345 // deco_clear_CNS_fraction // 2344 // deco_clear_CNS_fraction //
2346 // --------------------- 2345 // ---------------------
2347 // new in v.101 2346 // new in v.101
2348 2347
2349 void deco_clear_CNS_fraction(void) 2348 void deco_clear_CNS_fraction(void)
2350 { 2349 {
2351 RESET_C_STACK 2350 RESET_C_STACK
2352 CNS_fraction = 0.0; 2351 CNS_fraction = 0.0;
2353 char_O_CNS_fraction = 0; 2352 char_O_CNS_fraction = 0;
2354 } // void deco_clear_CNS_fraction(void) 2353 } // void deco_clear_CNS_fraction(void)
2355 2354
2356 2355
2357 // ------------------------- 2356 // -------------------------
2358 // deco_calc_CNS_fraction // 2357 // deco_calc_CNS_fraction //
2365 // Uses and Updates: CNS_fraction 2364 // Uses and Updates: CNS_fraction
2366 // Uses: acutal_ppO2 2365 // Uses: acutal_ppO2
2367 2366
2368 void deco_calc_CNS_fraction(void) 2367 void deco_calc_CNS_fraction(void)
2369 { 2368 {
2370 RESET_C_STACK 2369 RESET_C_STACK
2371 actual_ppO2 = (float)char_I_actual_ppO2 / 100.0; 2370 actual_ppO2 = (float)char_I_actual_ppO2 / 100.0;
2372 2371
2373 if (char_I_actual_ppO2 < 50) 2372 if (char_I_actual_ppO2 < 50)
2374 CNS_fraction = CNS_fraction;// no changes 2373 CNS_fraction = CNS_fraction;// no changes
2375 else if (char_I_actual_ppO2 < 60) 2374 else if (char_I_actual_ppO2 < 60)
2376 CNS_fraction = 1/(-54000.0 * actual_ppO2 + 54000.0) + CNS_fraction; 2375 CNS_fraction = 1/(-54000.0 * actual_ppO2 + 54000.0) + CNS_fraction;
2377 else if (char_I_actual_ppO2 < 70) 2376 else if (char_I_actual_ppO2 < 70)
2378 CNS_fraction = 1/(-45000.0 * actual_ppO2 + 48600.0) + CNS_fraction; 2377 CNS_fraction = 1/(-45000.0 * actual_ppO2 + 48600.0) + CNS_fraction;
2379 else if (char_I_actual_ppO2 < 80) 2378 else if (char_I_actual_ppO2 < 80)
2380 CNS_fraction = 1/(-36000.0 * actual_ppO2 + 42300.0) + CNS_fraction; 2379 CNS_fraction = 1/(-36000.0 * actual_ppO2 + 42300.0) + CNS_fraction;
2381 else if (char_I_actual_ppO2 < 90) 2380 else if (char_I_actual_ppO2 < 90)
2382 CNS_fraction = 1/(-27000.0 * actual_ppO2 + 35100.0) + CNS_fraction; 2381 CNS_fraction = 1/(-27000.0 * actual_ppO2 + 35100.0) + CNS_fraction;
2383 else if (char_I_actual_ppO2 < 110) 2382 else if (char_I_actual_ppO2 < 110)
2384 CNS_fraction = 1/(-18000.0 * actual_ppO2 + 27000.0) + CNS_fraction; 2383 CNS_fraction = 1/(-18000.0 * actual_ppO2 + 27000.0) + CNS_fraction;
2385 else if (char_I_actual_ppO2 < 150) 2384 else if (char_I_actual_ppO2 < 150)
2386 CNS_fraction = 1/(-9000.0 * actual_ppO2 + 17100.0) + CNS_fraction; 2385 CNS_fraction = 1/(-9000.0 * actual_ppO2 + 17100.0) + CNS_fraction;
2387 else if (char_I_actual_ppO2 < 160) 2386 else if (char_I_actual_ppO2 < 160)
2388 CNS_fraction = 1/(-22500.0 * actual_ppO2 + 37350.0) + CNS_fraction; 2387 CNS_fraction = 1/(-22500.0 * actual_ppO2 + 37350.0) + CNS_fraction;
2389 else if (char_I_actual_ppO2 < 165) 2388 else if (char_I_actual_ppO2 < 165)
2390 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 2389 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
2391 else if (char_I_actual_ppO2 < 170) 2390 else if (char_I_actual_ppO2 < 170)
2392 CNS_fraction = 0.00102 + CNS_fraction; // example calculation: Sqrt((1.7/1.55)^20)*0.000404 2391 CNS_fraction = 0.00102 + CNS_fraction; // example calculation: Sqrt((1.7/1.55)^20)*0.000404
2393 else if (char_I_actual_ppO2 < 175) 2392 else if (char_I_actual_ppO2 < 175)
2394 CNS_fraction = 0.00136 + CNS_fraction; 2393 CNS_fraction = 0.00136 + CNS_fraction;
2395 else if (char_I_actual_ppO2 < 180) 2394 else if (char_I_actual_ppO2 < 180)
2396 CNS_fraction = 0.00180 + CNS_fraction; 2395 CNS_fraction = 0.00180 + CNS_fraction;
2397 else if (char_I_actual_ppO2 < 185) 2396 else if (char_I_actual_ppO2 < 185)
2398 CNS_fraction = 0.00237 + CNS_fraction; 2397 CNS_fraction = 0.00237 + CNS_fraction;
2399 else if (char_I_actual_ppO2 < 190) 2398 else if (char_I_actual_ppO2 < 190)
2400 CNS_fraction = 0.00310 + CNS_fraction; 2399 CNS_fraction = 0.00310 + CNS_fraction;
2401 else if (char_I_actual_ppO2 < 195) 2400 else if (char_I_actual_ppO2 < 195)
2402 CNS_fraction = 0.00401 + CNS_fraction; 2401 CNS_fraction = 0.00401 + CNS_fraction;
2403 else if (char_I_actual_ppO2 < 200) 2402 else if (char_I_actual_ppO2 < 200)
2404 CNS_fraction = 0.00517 + CNS_fraction; 2403 CNS_fraction = 0.00517 + CNS_fraction;
2405 else if (char_I_actual_ppO2 < 230) 2404 else if (char_I_actual_ppO2 < 230)
2406 CNS_fraction = 0.0209 + CNS_fraction; 2405 CNS_fraction = 0.0209 + CNS_fraction;
2407 else 2406 else
2408 CNS_fraction = 0.0482 + CNS_fraction; // value for 2.5 2407 CNS_fraction = 0.0482 + CNS_fraction; // value for 2.5
2409 2408
2410 if (CNS_fraction > 2.5) 2409 if (CNS_fraction > 2.5)
2411 CNS_fraction = 2.5; 2410 CNS_fraction = 2.5;
2412 if (CNS_fraction < 0.0) 2411 if (CNS_fraction < 0.0)
2413 CNS_fraction = 0.0; 2412 CNS_fraction = 0.0;
2414 char_O_CNS_fraction = (char)((CNS_fraction + 0.005)* 100.0); 2413
2414 char_O_CNS_fraction = (char)((CNS_fraction + 0.005)* 100.0);
2415 } // void deco_calc_CNS_fraction(void) 2415 } // void deco_calc_CNS_fraction(void)
2416 2416
2417 // ------------------------------- 2417 // -------------------------------
2418 // deco_calc_CNS_decrease_15min // 2418 // deco_calc_CNS_decrease_15min //
2419 // ------------------------------- 2419 // -------------------------------
2425 // Uses and Updates: CNS_fraction 2425 // Uses and Updates: CNS_fraction
2426 2426
2427 void deco_calc_CNS_decrease_15min(void) 2427 void deco_calc_CNS_decrease_15min(void)
2428 { 2428 {
2429 RESET_C_STACK 2429 RESET_C_STACK
2430 CNS_fraction = 0.890899 * CNS_fraction; 2430 CNS_fraction = 0.890899 * CNS_fraction;
2431 char_O_CNS_fraction = (char)((CNS_fraction + 0.005)* 100.0); 2431 char_O_CNS_fraction = (char)((CNS_fraction + 0.005)* 100.0);
2432 }// deco_calc_CNS_decrease_15min(void) 2432 }// deco_calc_CNS_decrease_15min(void)
2433 2433
2434 2434
2435 // ----------------------- 2435 // -----------------------
2436 // deco_calc_percentage // 2436 // deco_calc_percentage //
2441 // output is int_I_temp 2441 // output is int_I_temp
2442 2442
2443 void deco_calc_percentage(void) 2443 void deco_calc_percentage(void)
2444 { 2444 {
2445 RESET_C_STACK 2445 RESET_C_STACK
2446 temp1 = (float)int_I_temp; 2446 temp1 = (float)int_I_temp;
2447 temp2 = (float)char_I_temp / 100.0; 2447 temp2 = (float)char_I_temp / 100.0;
2448 temp3 = temp1 * temp2; 2448 temp3 = temp1 * temp2;
2449 int_I_temp = (int)temp3; 2449 int_I_temp = (int)temp3;
2450 } 2450 }
2451 2451
2452 void deco_push_tissues_to_vault(void) 2452 void deco_push_tissues_to_vault(void)
2453 { 2453 {
2454 RESET_C_STACK 2454 RESET_C_STACK