# HG changeset patch # User JeanDo # Date 1297017131 -3600 # Node ID 016c45a0caaf9e8ee378e0cf03ab7a153b0a802a # Parent f720ce017244743c213fb7e7cbd48f844d3442db Enable to compile p2_deco.c on other platforms. diff -r f720ce017244 -r 016c45a0caaf code_part1/OSTC_code_asm_part1/simulator.asm --- a/code_part1/OSTC_code_asm_part1/simulator.asm Sun Feb 06 19:29:43 2011 +0100 +++ b/code_part1/OSTC_code_asm_part1/simulator.asm Sun Feb 06 19:32:11 2011 +0100 @@ -158,23 +158,34 @@ call PLED_simdata_screen call divemenu_see_decoplan + WIN_LEFT .0 + call PLED_standard_color + ; Display TTS, if any... movff int_O_ascenttime+0,lo movff int_O_ascenttime+1,hi movf lo,W iorwf hi,W bz simulator_decoplan_notts - - WIN_LEFT .0 + WIN_TOP .160 - call PLED_standard_color - - STRCPY "TTS: " + lfsr FSR2, letter + OUTPUTTEXT .85 ; TTS (for translation). + STRCAT ": " + bsf leftbind + output_16 + STRCAT_PRINT "'" + +simulator_decoplan_notts: + movff int_I_pres_surface+0,lo + movff int_I_pres_surface+1,hi + + WIN_TOP .190 ; Print Pamb used for compute + lfsr FSR2, letter bsf leftbind output_16 bcf leftbind - STRCAT_PRINT "'" -simulator_decoplan_notts: + STRCAT_PRINT " mbar" WIN_INVERT .1 ; Init new Wordprocessor DISPLAYTEXT .188 ; Sim. Results: diff -r f720ce017244 -r 016c45a0caaf code_part1/OSTC_code_c_part2/p2_deco.c --- a/code_part1/OSTC_code_c_part2/p2_deco.c Sun Feb 06 19:29:43 2011 +0100 +++ b/code_part1/OSTC_code_c_part2/p2_deco.c Sun Feb 06 19:32:11 2011 +0100 @@ -122,7 +122,7 @@ // *********************************************** #include "p2_definitions.h" -#include "../OSTC_code_c_part2/shared_definitions.h" +#include "shared_definitions.h" //---- Bank 3 parameters ----------------------------------------------------- #pragma udata bank4=0x400 @@ -407,14 +407,14 @@ { char_O_NDL_at_20mtr = char_O_nullzeit; // change to max bottom time. if( char_O_NDL_at_20mtr == 255) // and avoid confusion. - char_O_NDL_at_20mtr == 254; + char_O_NDL_at_20mtr = 254; } } ////////////////////////////////////////////////////////////////////////////// // DBG - multi main during dive // -static void check_dbg(static char is_post_check) +static void check_dbg(PARAMETER char is_post_check) { overlay unsigned int temp_DBS = 0; overlay char i; // Local loop index. @@ -484,8 +484,12 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -static int read_custom_function(static unsigned char cf) +static int read_custom_function(PARAMETER unsigned char cf) { +#ifdef CROSS_COMPILE + extern unsigned short custom_functions[]; + return custom_functions[cf]; +#else extern unsigned char hi, lo; extern void getcustom15(); _asm @@ -494,6 +498,7 @@ movff lo,PRODL movff hi,PRODH _endasm +#endif } ////////////////////////////////////////////////////////////////////////////// @@ -501,8 +506,9 @@ // If period == 0 : 2sec interval // 1 : 1 min interval // 2 : 10 min interval. -static void read_buhlmann_coeffifients(static char period) +static void read_buhlmann_coefficients(PARAMETER char period) { +#ifndef CROSS_COMPILE // Note: we don't use far rom pointer, because the // 24 bits is to complex, hence we have to set // the UPPER page ourself... @@ -511,6 +517,7 @@ movlw 1 movwf TBLPTRU,0 _endasm +#endif var_N2_a = buhlmann_a[ci]; var_N2_b = buhlmann_b[ci]; @@ -782,6 +789,7 @@ void fillDataStack(void) { +#ifndef CROSS_COMPILE _asm LFSR 1,C_STACK MOVLW 0xCC @@ -792,25 +800,31 @@ LFSR 1,C_STACK LFSR 2,C_STACK _endasm +#endif } ////////////////////////////////////////////////////////////////////////////// // When calling C code from ASM context, the data stack pointer and // frames should be reset. Bank3 is dedicated to the stack (see the // .lkr script). -#ifdef __DEBUG -# define RESET_C_STACK fillDataStack(); +#ifdef CROSS_COMPILE +# define RESET_C_STACK #else -# define RESET_C_STACK \ - _asm \ - LFSR 1, C_STACK \ - LFSR 2, C_STACK \ - _endasm +# ifdef __DEBUG +# define RESET_C_STACK fillDataStack(); +# else +# define RESET_C_STACK \ + _asm \ + LFSR 1, C_STACK \ + LFSR 2, C_STACK \ + _endasm +# endif #endif ////////////////////////////////////////////////////////////////////////////// // Called every 2 seconds during diving. // update tissues every time. +// // Every 6 seconds (or slower when TTS > 16): // - update deco table (char_O_deco_time/depth) with new values. // - update ascent time, @@ -833,12 +847,14 @@ } ////////////////////////////////////////////////////////////////////////////// - +// Reset decompression model: +// + Set all tissues to equilibrium with Air at ambient pressure. +// + Reset last stop to 0m +// + Reset all model output. void deco_clear_tissue(void) { RESET_C_STACK clear_tissue(); - char_I_depth_last_deco = 0; // for compatibility with v.101pre_no_last_deco } ////////////////////////////////////////////////////////////////////////////// @@ -885,7 +901,7 @@ overlay float p = N2_ratio * (pres_respiration - 0.0627); pres_tissue[ci] = p; - read_buhlmann_coeffifients(-1); + read_buhlmann_coefficients(-1); p = (p - var_N2_a) * var_N2_b ; if( p < 0.0 ) @@ -902,6 +918,7 @@ int_O_ascenttime = 0; char_O_gradient_factor = 0; char_O_relative_gradient_GF = 0; + char_I_depth_last_deco = 0; // for compatibility with v.101pre_no_last_deco } ////////////////////////////////////////////////////////////////////////////// @@ -1023,7 +1040,7 @@ deco_He_ratio4 = char_I_deco_He_ratio4 / 100.0; deco_N2_ratio5 = char_I_deco_N2_ratio5 / 100.0; deco_He_ratio5 = char_I_deco_He_ratio5 / 100.0; - float_deco_distance = char_I_deco_distance / 100.0; + float_deco_distance = char_I_deco_distance / 100.0; // Get offset is in mbar. // ____________________________________________________ // @@ -1086,7 +1103,7 @@ const_ppO2 = (float)char_I_const_ppO2 / 100.0; deco_ppO2_change = (float)char_I_deco_ppO2_change / 99.95 + pres_surface; - deco_ppO2_change = deco_ppO2_change + float_deco_distance; + deco_ppO2_change += float_deco_distance; deco_ppO2 = (float)char_I_deco_ppO2 / 100.0; float_desaturation_multiplier = char_I_desaturation_multiplier / 100.0; float_saturation_multiplier = char_I_saturation_multiplier / 100.0; @@ -1126,7 +1143,7 @@ calc_tissue_1_min(); int_O_gtissue_limit = (int)(pres_tissue_limit[char_O_gtissue_no] * 1000); - int_O_gtissue_press = (int)((pres_tissue[char_O_gtissue_no] + pres_tissue[char_O_gtissue_no+16]) * 1000); + int_O_gtissue_press = (int)((pres_tissue[char_O_gtissue_no] + (pres_tissue+16)[char_O_gtissue_no]) * 1000); if (char_I_deco_model == 1) { temp1 = temp1 * GF_high; @@ -1298,14 +1315,14 @@ // // optimized in v.101 // -static void calc_tissue(static unsigned char period) +static void calc_tissue(PARAMETER unsigned char period) { char_O_gtissue_no = 255; pres_gtissue_limit = 0.0; for (ci=0;ci<16;ci++) { - read_buhlmann_coeffifients(period); // 2 sec or 1 min period. + read_buhlmann_coefficients(period); // 2 sec or 1 min period. // N2 temp_tissue = (temp_atem - pres_tissue[ci]) * var_N2_e; @@ -1483,14 +1500,14 @@ // + Do it on sim_pres_tissue, instead of pres_tissue. // + Update GF_low state for GF decompression model. // -static void sim_tissue(static unsigned char period) +static void sim_tissue(PARAMETER unsigned char period) { sim_pres_gtissue_limit = 0.0; sim_gtissue_no = 255; for (ci=0;ci<16;ci++) { - read_buhlmann_coeffifients(period); // 1 or 10 minute(s) interval + read_buhlmann_coefficients(period); // 1 or 10 minute(s) interval // N2 temp_tissue = (temp_atem - sim_pres_tissue[ci]) * var_N2_e; @@ -1667,7 +1684,7 @@ // void deco_calc_desaturation_time(void) { - overlay int desat_time; // For a particular compartiment, in min. + overlay unsigned int desat_time; // For a particular compartiment, in min. RESET_C_STACK @@ -1736,9 +1753,9 @@ // saturation_time (for flight) if (temp4 > temp2) - desat_time = (int)temp4; + desat_time = (unsigned int)temp4; else - desat_time = (int)temp2; + desat_time = (unsigned int)temp2; if(desat_time > int_O_desaturation_time) int_O_desaturation_time = desat_time; @@ -1800,6 +1817,7 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// +#ifndef CROSS_COMPILE void deco_hash(void) { overlay unsigned char md_i, md_j; // Loop index. @@ -1882,6 +1900,7 @@ } // for md_i 16 } // for md_pointer } // void deco_hash(void) +#endif ////////////////////////////////////////////////////////////////////////////// // deco_clear_CNS_fraction @@ -2016,4 +2035,6 @@ ////////////////////////////////////////////////////////////////////////////// // -void main() {} \ No newline at end of file +#ifndef CROSS_COMPILE +void main() {} +#endif diff -r f720ce017244 -r 016c45a0caaf code_part1/OSTC_code_c_part2/p2_deco.o Binary file code_part1/OSTC_code_c_part2/p2_deco.o has changed diff -r f720ce017244 -r 016c45a0caaf code_part1/OSTC_code_c_part2/p2_definitions.h --- a/code_part1/OSTC_code_c_part2/p2_definitions.h Sun Feb 06 19:29:43 2011 +0100 +++ b/code_part1/OSTC_code_c_part2/p2_definitions.h Sun Feb 06 19:32:11 2011 +0100 @@ -23,64 +23,56 @@ // history: // 12/25/10 v110: [jDG] split in three files (deco.c, main.c, definitions.h) -# define DBG_c_gas 0b0000000000000001 -# define DBG_c_ppO2 0b0000000000000010 -# define DBG_RUN 0b0000000000000100 -# define DBG_RESTART 0b0000000000001000 +#define DBG_c_gas 0x0001 +#define DBG_c_ppO2 0x0002 +#define DBG_RUN 0x0004 +#define DBG_RESTART 0x0008 -# define DBG_CdeSAT 0b0000000000010000 -# define DBG_C_MODE 0b0000000000100000 -# define DBG_C_SURF 0b0000000001000000 -# define DBG_HEwoHE 0b0000000010000000 +#define DBG_CdeSAT 0x0010 +#define DBG_C_MODE 0x0020 +#define DBG_C_SURF 0x0040 +#define DBG_HEwoHE 0x0080 -# define DBG_C_DPPO2 0b0000000100000000 -# define DBG_C_DGAS 0b0000001000000000 -# define DBG_C_DIST 0b0000010000000000 -# define DBG_C_LAST 0b0000100000000000 +#define DBG_C_DPPO2 0x0100 +#define DBG_C_DGAS 0x0200 +#define DBG_C_DIST 0x0400 +#define DBG_C_LAST 0x0800 -# define DBG_C_GF 0b0001000000000000 -# define DBG_ZH16ERR 0b0010000000000000 -# define DBG_PHIGH 0b0100000000000000 -# define DBG_PLOW 0b1000000000000000 - - -# define DBS_mode 0b0000000000000001 -# define DBS_ppO2 0b0000000000000010 -# define DBS_HE_sat 0b0000000000000100 -# define DBS_ppO2chg 0b0000000000001000 +#define DBG_C_GF 0x1000 +#define DBG_ZH16ERR 0x2000 +#define DBG_PHIGH 0x4000 +#define DBG_PLOW 0x8000 -# define DBS_SAT2l 0b0000000000010000 -# define DBS_SAT2h 0b0000000000100000 -# define DBS_GFLOW2l 0b0000000001000000 -# define DBS_GFLOW2h 0b0000000010000000 - -# define DBS_GFHGH2l 0b0000000100000000 -# define DBS_GFHGH2h 0b0000001000000000 -# define DBS_GASO22l 0b0000010000000000 -# define DBS_GASO22h 0b0000100000000000 - -# define DBS_DIST2h 0b0001000000000000 -# define DBS_LAST2h 0b0010000000000000 -# define DBS_DECOO2l 0b0100000000000000 -# define DBS_DECOO2h 0b1000000000000000 - +#define DBS_mode 0x0001 +#define DBS_ppO2 0x0002 +#define DBS_HE_sat 0x0004 +#define DBS_ppO2chg 0x0008 + +#define DBS_SAT2l 0x0010 +#define DBS_SAT2h 0x0020 +#define DBS_GFLOW2l 0x0040 +#define DBS_GFLOW2h 0x0080 + +#define DBS_GFHGH2l 0x0100 +#define DBS_GFHGH2h 0x0200 +#define DBS_GASO22l 0x0400 +#define DBS_GASO22h 0x0800 + +#define DBS_DIST2h 0x1000 +#define DBS_LAST2h 0x2000 +#define DBS_DECOO2l 0x4000 +#define DBS_DECOO2h 0x8000 -# define DBS2_PRES2h 0b0000000000000001 -# define DBS2_PRES2l 0b0000000000000010 -# define DBS2_SURF2l 0b0000000000000100 -# define DBS2_SURF2h 0b0000000000001000 +#define DBS2_PRES2h 0x0001 +#define DBS2_PRES2l 0x0002 +#define DBS2_SURF2l 0x0004 +#define DBS2_SURF2h 0x0008 + +#define DBS2_DESAT2l 0x0010 +#define DBS2_DESAT2h 0x0020 +#define DBS2_GFDneg 0x0040 -# define DBS2_DESAT2l 0b0000000000010000 -# define DBS2_DESAT2h 0b0000000000100000 -# define DBS2_GFDneg 0b0000000001000000 -# define DBS2_ 0b000000000000000 - -# define DBS2_ 0b000000000000000 -# define DBS2_ 0b000000000000000 -# define DBS2_ 0b000000000000000 -# define DBS2_ 0b000000000000000 - -# define MBAR_REACH_GASCHANGE_AUTO_CHANGE_OFF 150 +#define MBAR_REACH_GASCHANGE_AUTO_CHANGE_OFF 150 // ************************* // ** P R O T O T Y P E S ** @@ -101,4 +93,23 @@ extern void deco_push_tissues_to_vault(void); extern void deco_pull_tissues_from_vault(void); +// *********************************************** +// ** Allow compile on VisualC ** +// *********************************************** + +#ifdef WIN32 + // Some keywords just dont exists on Visual C++: +# define CROSS_COMPILE +# define __18CXX +# define ram +# define rom +# define overlay +# define PARAMETER + + // Avoid warnings about float/double mismatches: +# pragma warning(disable: 4244 4068 4305) +#else +# define PARAMETER static +#endif + //////////////////////////////////////////////////////////////////////////////