changeset 163:144822282fa3

Fusion declaration of shared C/ASM variables. + remove unused variables. + sort all in variables in BANK3, and out variables in BANK2.
author JeanDo
date Fri, 21 Jan 2011 01:44:37 +0100
parents fdebc43c8372
children 999abb01c78f
files code_part1/OSTC_code_asm_part1/definitions.asm code_part1/OSTC_code_asm_part1/divemode.asm code_part1/OSTC_code_asm_part1/pled_outputs.asm code_part1/OSTC_code_asm_part1/start.asm code_part1/OSTC_code_c_part2/p2_deco.c code_part1/OSTC_code_c_part2/p2_deco.o code_part1/OSTC_code_c_part2/p2_definitions.h code_part1/OSTC_code_c_part2/shared_definitions.h
diffstat 8 files changed, 184 insertions(+), 341 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Fri Jan 21 01:48:40 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Fri Jan 21 01:44:37 2011 +0100
@@ -17,6 +17,7 @@
 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
 ; written: 10/30/05
 ; last updated: 01/23/08
+; 2011/01/20: [jDG] Create a common file included in ASM and C code.
 ; known bugs:
 ; ToDo:
 
@@ -76,17 +77,11 @@
 
 ;=============================================================================
 
-    CBLOCK  0x800
-        c_code_data_stack:.64       ; Reserve space for C-code data space. Eg.when calling log.
-    endc
+#include "../OSTC_code_c_part2/shared_definitions.h"
 
-    CBLOCK  0x3F0
-        pressureSum:2               ; Stabilize surface presure by a long averaging window [mbar]
-        pressureCount               ; Count of pressure values.
-        pressureAvg:2               ; save averaged pressure x16, for altimeter_menu
-        pressureRef:2               ; Pressure at sea level [mbar]
-        altitude:2                  ; Last computed altitude [m]
-    ENDC
+;=============================================================================
+
+c_code_data_stack   EQU 0x800           ; Reserve space for C-code data space. Eg.when calling log.
 
 ;Variable definitions
 ; arrays are in hex size!! 20 = .032
@@ -103,6 +98,13 @@
 	win_invert
 	win_bargraph                ; PLED_box swicth to black after this position (0..159).
 	win_flags                   ; flip_screen flag, transparent fonts, etc...
+	
+    pressureSum:2               ; Stabilize surface presure by a long averaging window [mbar]
+    pressureCount               ; Count of pressure values.
+    pressureAvg:2               ; save averaged pressure x16, for altimeter_menu
+    pressureRef:2               ; Pressure at sea level [mbar]
+    altitude:2                  ; Last computed altitude [m]
+	
 	ENDC
 
 	CBLOCK	0x100				;Bank 1
@@ -318,89 +320,6 @@
 	time_correction_value		; Adds to Seconds on midnight
 	ENDC
 
-	CBLOCK	0x200				;Bank 2
- int_O_tissue_for_debug:.32		; deco_debug copies pressure of tissue to this variable
- int_O_GF_spare____:2;					// 0x240
- int_O_GF_step:2;						// 0x242
- int_O_gtissue_limit:2;					// 0x244
- int_O_gtissue_press:2;					// 0x246
- int_O_limit_GF_low:2;					// 0x248
- int_O_gtissue_press_at_GF_low:2;		// 0x24A
-	ENDC
-
-	CBLOCK	0x24C  
- char_I_step_is_1min; 					// 0x24C 
-	ENDC
-	
-	CBLOCK	0x24E				;Bank 2
- char_O_GF_low_pointer;					// 0x24E
- char_O_actual_pointer;					// 0x24F
-	ENDC
-	CBLOCK	0x250				;Bank 2
- char_O_deco_table:.32;				// 0x250
-	ENDC
-	CBLOCK	0x270				;Bank 2
- char_I_table_deco_done:.32;			// 0x270
-	ENDC
-	CBLOCK	0x290				;Bank 2
- int_O_calc_tissue_call_counter:2
-	ENDC
-	CBLOCK	0x380				;Bank 3
-	; some used in C code!
-	ENDC
-								
-	CBLOCK	0x500
-; used by deco_main c-code for data transfer with the asm code
-; input of c-code
- int_I_pres_respiration:2;			; 0x500
- int_I_pres_surface:2;				; 0x502
- int_I_temp:2;						; 0x504
- char_I_temp;						; 0x506
- char_I_actual_ppO2;				; 0x507
- char_I_deco_N2_ratio2;    			// 0x508 new in v.102
- char_I_deco_He_ratio2;    			// 0x509 new in v.102
- char_I_deco_N2_ratio3;    			// 0x50A new in v.102
- char_I_deco_He_ratio3;    			// 0x50B new in v.102
- char_I_deco_N2_ratio4;    			// 0x50C new in v.102
- char_I_deco_He_ratio4;    			// 0x50D new in v.102
- char_I_deco_N2_ratio5;    			// 0x50E new in v.102
- char_I_deco_He_ratio5;    			// 0x50F new in v.102
- char_I_N2_ratio;					; 0x510
- char_I_He_ratio;					; 0x511
- char_I_saturation_multiplier;		; for conservatism/safety values 1.0 (no conservatism) to 1.5 (50% faster saturation
- char_I_desaturation_multiplier;	; for conservatism/safety values 0.66 (50% slower desaturation) to 1.0 (no conservatism); consveratism used in calc_tissue(), calc_tissue_step_1_min() and sim_tissue_1min()
- char_I_GF_Hi_percentage;			; 0x514
- char_I_GF_Lo_percentage;			; 0x515
- char_I_GF_Spare;					; 0x516
- char_I_deco_distance;				; 0x517
- char_I_const_ppO2;					; 0x518	new in v.101 (C-Code), new in v109 (asm)
- char_I_deco_ppO2_change;			; 0x519	new in v.101
- char_I_deco_ppO2;					; 0x51A	new in v.101
- char_I_deco_gas_change;			; 0x51B	new in v.101
- char_I_deco_N2_ratio;				; 0x51C	new in v.101
- char_I_deco_He_ratio;				; 0x51D	new in v.101
- char_I_depth_last_deco;			; 0x51E	new in v.101
- char_I_deco_model;					; 0x51F	new in v.102
-; output of c-code:
- int_O_desaturation_time:2;			; 0x520
- char_O_nullzeit;					; 0x522
- char_O_deco_status;				; 0x523
- char_O_array_decotime:7;			; 0x524
- char_O_array_decodepth:6;			; 0x52B
- char_O_ascenttime;					; 0x531
- char_O_gradient_factor;			; 0x532
- char_O_tissue_saturation:.32;		; 0x533, He starts at 0x543
- char_O_array_gradient_weighted:.16 ; 0x553
- char_O_gtissue_no;					; 0x563
- char_O_diluent;					; 0x564 new in v.101 (C-Code), new in v109 (asm)
- char_O_CNS_fraction;				; 0x565	new in v.101
- char_O_relative_gradient_GF;		; 0x566	new in v.102
- char_I_deco_gas_change2;   		// 0x567 new in v.102
- char_I_deco_gas_change3;   		// 0x568 new in v.102
- char_I_deco_gas_change4;   		// 0x569 new in v.102
- char_I_deco_gas_change5;   		// 0x56A new in v.102 
-	ENDC
-
 	CBLOCK	0x700				;Bank 7
 ; variables used exclusively in dd:
 	dd_temp_BSR ; has to be first in bank7
@@ -444,7 +363,6 @@
     extern deco_calc_wo_deco_step_1_min
     extern deco_clear_CNS_fraction
     extern deco_clear_tissue
-    extern deco_gradient_array
     extern deco_hash    
     extern deco_pull_tissues_from_vault
     extern deco_push_tissues_to_vault
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Fri Jan 21 01:48:40 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Fri Jan 21 01:44:37 2011 +0100
@@ -1283,9 +1283,6 @@
 	btfsc	restore_deco_data			; Restore decodata?
 	call	simulator_restore_tissue_data		; Yes!
 
-	call	deco_gradient_array
-	movlb	b'00000001'					; select ram bank 1
-
 	goto	surfloop					; and return to surfaceloop
 
 timeout_divemode:
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Fri Jan 21 01:48:40 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Fri Jan 21 01:44:37 2011 +0100
@@ -980,9 +980,9 @@
     movff   WREG,letter+5		; collision with sat graphs
 	bcf		leftbind
 	call	word_processor
-;	rcall	PLED_active_gas_divemode_better_gas	; show *, if required
+;	rcall	PLED_active_better_gas	; show *, if required
 ;	return
-PLED_active_gas_divemode_better_gas:
+PLED_active_better_gas:
 	WIN_TOP		.192
 	WIN_LEFT	.43
 	WIN_FONT 	FT_SMALL
@@ -1007,7 +1007,7 @@
     movff   WREG,letter+5		; collision with sat graphs
 	bcf		leftbind
 	call	word_processor
-	rcall	PLED_active_gas_divemode_better_gas	; show *, if required
+	rcall	PLED_active_better_gas	; show *, if required
 	return
 
 PLED_display_decotype_surface:
--- a/code_part1/OSTC_code_asm_part1/start.asm	Fri Jan 21 01:48:40 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/start.asm	Fri Jan 21 01:44:37 2011 +0100
@@ -218,8 +218,8 @@
 ; Load GF values into RAM
 	movlw	d'90'
 	movwf	wait_temp
-	movff	wait_temp,char_I_GF_Lo_percentage
-	movff	wait_temp,char_I_GF_Hi_percentage		; Set to 90/90...
+	movff	wait_temp,char_I_GF_Low_percentage
+	movff	wait_temp,char_I_GF_High_percentage		; Set to 90/90...
 	clrf	EEADRH
 	read_int_eeprom d'34'			; Read deco data	
 	movlw	d'1'					; Gauge mode
@@ -250,9 +250,9 @@
 	movff	wait_temp,char_I_deco_model	; Set Flagbyte for GF method
 ; Load GF values into RAM
 	GETCUSTOM8	d'32'			; GF low
-	movff		EEDATA,char_I_GF_Lo_percentage
+	movff		EEDATA,char_I_GF_Low_percentage
 	GETCUSTOM8	d'33'			; GF high
-	movff		EEDATA,char_I_GF_Hi_percentage
+	movff		EEDATA,char_I_GF_High_percentage
 	return							; start in Surfacemode
 restart_5_test_gfO2_mode:
 	movlw	d'5'					; GF CC mode
@@ -264,9 +264,9 @@
 	movff	wait_temp,char_I_deco_model	; Set Flagbyte for GF method
 	; Load GF values into RAM
 	GETCUSTOM8	d'32'			; GF low
-	movff		EEDATA,char_I_GF_Lo_percentage
+	movff		EEDATA,char_I_GF_Low_percentage
 	GETCUSTOM8	d'33'			; GF high
-	movff		EEDATA,char_I_GF_Hi_percentage
+	movff		EEDATA,char_I_GF_High_percentage
 	return							; start in Surfacemode
 
 startup_screen1:
--- a/code_part1/OSTC_code_c_part2/p2_deco.c	Fri Jan 21 01:48:40 2011 +0100
+++ b/code_part1/OSTC_code_c_part2/p2_deco.c	Fri Jan 21 01:44:37 2011 +0100
@@ -63,6 +63,7 @@
 // 05/23/10 v109: 5 gas changes & 1 min timer
 // 07/13/10 v110: cns vault added
 // 12/25/10 v110: split in three files (deco.c, main.c, definitions.h)
+// 2011/01/20: [jDG] Create a common file included in ASM and C code.
 //
 //
 // literature:
@@ -85,33 +86,11 @@
 // ** V A R I A B L E S   D E F I N I T I O N S **
 // ***********************************************
 
-
-#pragma udata bank2a=0x200
-// output:
-unsigned int	int_O_tissue_for_debug[32];
-unsigned int	int_O_GF_spare____;						// 0x240
-unsigned int	int_O_GF_step;							// 0x242
-unsigned int 	int_O_gtissue_limit;					// 0x244
-unsigned int 	int_O_gtissue_press;					// 0x246
-unsigned int 	int_O_limit_GF_low;						// 0x248
-unsigned int 	int_O_gtissue_press_at_GF_low;			// 0x24A
-unsigned char	char_I_step_is_1min;					// 0x24C
+#include "../OSTC_code_c_part2/shared_definitions.h"
 
-// ...
-#pragma udata bank2b=0x24E
-unsigned char	char_O_GF_low_pointer;					// 0x24E
-unsigned char	char_O_actual_pointer;					// 0x24F
-
-#pragma udata bank2c=0x250
-unsigned char	char_O_deco_table[32];					// 0x250
+//---- Bank 3 parameters -----------------------------------------------------
+#pragma udata bank4=0x400
 
-#pragma udata bank2d=0x270
-unsigned char	char_I_table_deco_done[32];
-
-#pragma udata bank2e=0x290
-unsigned int 	int_O_calc_tissue_call_counter;			// 0x290
-
-// internal:
 static unsigned char 	lock_GF_depth_list;
 static float			temp_limit;
 static float			GF_low;
@@ -133,21 +112,18 @@
 static unsigned char	temp_depth_GF_low_number;
 static unsigned char	internal_deco_pointer;
 
-#pragma udata bank2f=0x2C8
 static unsigned char	internal_deco_table[32];			//  0x2C8
 static float			temp_pres_deco_GF_low;
 
-#pragma udata bank3a=0x300
 static char output[32];                 // used by the math routines
 
-#pragma udata bank3b=0x37C
 static float cns_vault;
 
-#pragma udata bank3c=0x380
 static float pres_tissue_vault[32];
 
- #pragma udata bank4a=0x400
-// internal:
+//---- Bank 5 parameters -----------------------------------------------------
+#pragma udata bank5=0x500
+
 static unsigned char	ci ; // don't move - used in _asm routines - if moved then modify movlb commands
 static unsigned char 	x;
 static unsigned int 	main_i_dummy;
@@ -184,62 +160,11 @@
 static float			temp_pres_gtissue_limit;
 static float			actual_ppO2;						// new in v.102
 
-#pragma udata bank4b=0x480
 static float			pres_tissue[32];
 
-#pragma udata bank5=0x500
-// don't move positions in this bank, the registers are addressed directly from assembler code
-// input:
-unsigned int  int_I_pres_respiration;	        // 0x500
-unsigned int  int_I_pres_surface;		        // 0x502
-unsigned int  int_I_temp;				        // 0x504  new in v101
-unsigned char char_I_temp;			            // 0x506  new in v101
-unsigned char char_I_actual_ppO2;		        // 0x507
-unsigned char char_I_deco_N2_ratio2;            // 0x508 new in v.109
-unsigned char char_I_deco_He_ratio2;            // 0x509 new in v.109
-unsigned char char_I_deco_N2_ratio3;            // 0x50A new in v.109
-unsigned char char_I_deco_He_ratio3;            // 0x50B new in v.109
-unsigned char char_I_deco_N2_ratio4;            // 0x50C new in v.109
-unsigned char char_I_deco_He_ratio4;            // 0x50D new in v.109
-unsigned char char_I_deco_N2_ratio5;            // 0x50E new in v.109
-unsigned char char_I_deco_He_ratio5;            // 0x50F new in v.109
-unsigned char char_I_N2_ratio;		            // 0x510
-unsigned char char_I_He_ratio;		            // 0x511
-unsigned char char_I_saturation_multiplier;		// for conservatism/safety values 1.0 (no conservatism) to 1.5 (50% faster saturation
-unsigned char char_I_desaturation_multiplier; 	// for conservatism/safety values 0.66 (50% slower desaturation) to 1.0 (no conservatism)// consveratism used in calc_tissue(), calc_tissue_step_1_min() and sim_tissue_1min()
-unsigned char char_I_GF_High_percentage;        // 0x514	new in v.102
-unsigned char char_I_GF_Low_percentage;			// 0x515	new in v.102
-unsigned char char_I_spare;					    // 0x516
-unsigned char char_I_deco_distance;				// 0x517
-unsigned char char_I_const_ppO2;				// 0x518	new in v.101
-unsigned char char_I_deco_ppO2_change;			// 0x519	new in v.101
-unsigned char char_I_deco_ppO2;					// 0x51A	new in v.101
-unsigned char char_I_deco_gas_change;			// 0x51B	new in v.101
-unsigned char char_I_deco_N2_ratio;				// 0x51C	new in v.101
-unsigned char char_I_deco_He_ratio;				// 0x51D	new in v.101
-unsigned char char_I_depth_last_deco;			// 0x51E	new in v.101 unit: [m]
-unsigned char char_I_deco_model;				// 0x51F	new in v.102	( 1 = MultiGraF, sonst Std. mit (de-)saturation_multiplier)
+//---- Bank 6 parameters -----------------------------------------------------
+#pragma udata bank6=0x600
 
-// output:
-unsigned int  int_O_desaturation_time;			// 0x520
-unsigned char char_O_nullzeit;					// 0x522
-unsigned char char_O_deco_status;				// 0x523
-unsigned char char_O_array_decotime[7];			// 0x524
-unsigned char char_O_array_decodepth[6];		// 0x52B
-unsigned char char_O_ascenttime;				// 0x531
-unsigned char char_O_gradient_factor;			// 0x532
-unsigned char char_O_tissue_saturation[32];		// 0x533
-unsigned char char_O_array_gradient_weighted[16];	// 0x553
-unsigned char char_O_gtissue_no;				// 0x563
-unsigned char char_O_diluent;					// 0x564	new in v.101
-unsigned char char_O_CNS_fraction;				// 0x565	new in v.101
-unsigned char char_O_relative_gradient_GF;		// 0x566	new in v.102
-unsigned char char_I_deco_gas_change2;          // 0x567 new in v.109
-unsigned char char_I_deco_gas_change3;          // 0x568 new in v.109
-unsigned char char_I_deco_gas_change4;          // 0x569 new in v.109
-unsigned char char_I_deco_gas_change5;          // 0x56A new in v.109
-
-// internal:
 static float  pres_tissue_limit[16];
 static float  sim_pres_tissue_limit[16];
 static float  pres_diluent;			            // new in v.101
@@ -248,26 +173,22 @@
 static float  deco_ppO2_change;	            	// new in v.101
 static float  deco_ppO2;				        // new in v.101
 
-#pragma udata bank6=0x600
-// internal:
-static float  sim_pres_tissue[32];
+//---- Bank 7 parameters -----------------------------------------------------
+#pragma udata bank7=0x700
+
+static float  sim_pres_tissue[32];              // 32 floats = 128 bytes.
 static float  sim_pres_tissue_backup[32];
 
+//---- Bank 8 parameters -----------------------------------------------------
 #pragma udata bank8=0x800
+
 static char	  md_pi_subst[256];
 #define C_STACK md_pi_subst                     // Overlay C-code data stack here, too.
 
+//---- Bank 9 parameters -----------------------------------------------------
 #pragma udata bank9a=0x900
-// output:
-static char	  md_state[48];		        // DONT MOVE !! // has to be at the beginning of bank 9 for the asm code!!!
 
-#pragma udata bank9b=0x930
-// output:
-unsigned int  int_O_DBS_bitfield;				// 0x930	new in v.108
-unsigned int  int_O_DBS2_bitfield;				// 0x932	new in v.108
-unsigned int  int_O_DBG_pre_bitfield;			// 0x934	new in v.108
-unsigned int  int_O_DBG_post_bitfield;			// 0x936	new in v.108
-unsigned char char_O_NDL_at_20mtr;				// 0x938	new in v.108 // 0xFF == undefined, max. 254
+static char	  md_state[48];		        // DONT MOVE !! // has to be at the beginning of bank 9 for the asm code!!!
 
 // internal:
  static char            md_t;
@@ -1921,35 +1842,6 @@
 	}
 } // calc_gradient
 
-// ---------------------------
-// deco_gradient_array //
-// ---------------------------
-// optimized in v.101 (var_a)
-// new code in v.102
-
-void deco_gradient_array()
-{
-    RESET_C_STACK
-    pres_respiration = (float)int_I_pres_respiration / 1000.0; // assembler code uses different digit system
-    for (ci=0;ci<16;ci++)
-    {
-    	temp_tissue = pres_tissue[ci] + pres_tissue[ci+16];
-    	temp1 = temp_tissue - pres_respiration;
-    	temp2 = temp_tissue - pres_tissue_limit[ci];
-    	temp2 = temp1/temp2;
-    	temp2 = temp2 * 200; // because of output in (Double-)percentage
-    	if (temp2 < 0)
-    		temp2 = 0;
-    	if (temp2 > 255)
-    		temp2 = 255;
-    	if (temp1 < 0)
-     		char_O_array_gradient_weighted[ci] = 0;
-    	else
-     		char_O_array_gradient_weighted[ci] = (char)temp2;
-    } // for
-} // deco_gradient_array
-
-
 // ------------------------------
 // deco_calc_desaturation_time //
 // ------------------------------
@@ -2217,30 +2109,6 @@
             pres_gtissue_limit = pres_tissue_limit[ci];
             char_O_gtissue_no = ci;
         }//if
-
-        if(!char_I_step_is_1min)
-        {
-            // gradient factor array for graphical display
-            // display range is 0 to 250! in steps of 5 for 1 pixel
-            // the display is divided in 6 blocks
-            // -> double the gradient 100% = 200
-            // tissue > respiration (entsaettigungsvorgang)
-            // gradient ist wieviel prozent an limit von tissue aus
-            // dh. 0% = respiration == tissue
-            // dh. 100% = respiration == limit
-            temp1 = temp_tissue - pres_respiration;
-            temp2 = temp_tissue - pres_tissue_limit[ci];	// changed in v.102
-            temp2 = temp1/temp2;
-            temp2 = temp2 * 200; // because of output in (Double-)percentage
-            if (temp2 < 0)
-            	temp2 = 0;
-            if (temp2 > 255)
-            	temp2 = 255;
-            if (temp1 < 0)
-                char_O_array_gradient_weighted[ci] = 0;
-            else
-                char_O_array_gradient_weighted[ci] = (char)temp2;
-        }
     } // for
 } // calc wo deco 1min
 
Binary file code_part1/OSTC_code_c_part2/p2_deco.o has changed
--- a/code_part1/OSTC_code_c_part2/p2_definitions.h	Fri Jan 21 01:48:40 2011 +0100
+++ b/code_part1/OSTC_code_c_part2/p2_definitions.h	Fri Jan 21 01:44:37 2011 +0100
@@ -128,89 +128,3 @@
 void deco_clear_CNS_fraction(void);
 void deco_push_tissues_to_vault(void);
 void deco_pull_tissues_from_vault(void);
-
-// *************************************************
-// ** V A R I A B L E S   D E C L A R A T I O N S **
-// *************************************************
-// prefixes etc:
-// _O_ = output for use in the assembler code
-// _I_ = input from the assembler code for the c code
-// char_ and int_ = used to identify output and input size
-// var = variable (from b"uhlmann)
-// pres = pressure
-// gtissue = guiding tissue, the one limiting the ascent
-// e2secs = exp of the b"uhlmann formula precalculated for a 2 second step
-// e1min = same for 1 minute step
-// sim = used in simulating the ascent to the surface
-// nullzeit = remaining ground/bottom time for "no deco"
-// hauptroutine = main
-
-extern unsigned int  int_O_tissue_for_debug[32];
-extern unsigned int	 int_O_GF_spare____;					
-extern unsigned int	 int_O_GF_step;						
-extern unsigned int  int_O_gtissue_limit;			
-extern unsigned int  int_O_gtissue_press;			
-extern unsigned int  int_O_limit_GF_low;				
-extern unsigned int  int_O_gtissue_press_at_GF_low;	
-extern unsigned char char_I_step_is_1min;		
-extern unsigned char char_O_GF_low_pointer;		
-extern unsigned char char_O_actual_pointer;		
-extern unsigned char char_O_deco_table[32];		
-extern unsigned char char_I_table_deco_done[32];
-extern unsigned int  int_O_calc_tissue_call_counter;
-
-//---- Bank 5 parameters -----------------------------------------------------
-extern unsigned int  int_I_pres_respiration;
-extern unsigned int  int_I_pres_surface;	
-extern unsigned int  int_I_temp;
-extern unsigned char char_I_temp;
-extern unsigned char char_I_actual_ppO2;	
-extern unsigned char char_I_deco_N2_ratio2; 
-extern unsigned char char_I_deco_He_ratio2; 
-extern unsigned char char_I_deco_N2_ratio3; 
-extern unsigned char char_I_deco_He_ratio3; 
-extern unsigned char char_I_deco_N2_ratio4; 
-extern unsigned char char_I_deco_He_ratio4; 
-extern unsigned char char_I_deco_N2_ratio5; 
-extern unsigned char char_I_deco_He_ratio5; 
-extern unsigned char char_I_N2_ratio;		
-extern unsigned char char_I_He_ratio;		
-extern unsigned char char_I_saturation_multiplier;
-extern unsigned char char_I_desaturation_multiplier;
-extern unsigned char char_I_GF_High_percentage;
-extern unsigned char char_I_GF_Low_percentage;
-extern unsigned char char_I_spare;
-extern unsigned char char_I_deco_distance;
-extern unsigned char char_I_const_ppO2;
-extern unsigned char char_I_deco_ppO2_change;
-extern unsigned char char_I_deco_ppO2;
-extern unsigned char char_I_deco_gas_change;
-extern unsigned char char_I_deco_N2_ratio;
-extern unsigned char char_I_deco_He_ratio;
-extern unsigned char char_I_depth_last_deco;
-extern unsigned char char_I_deco_model;
-
-extern unsigned int  int_O_desaturation_time;			
-extern unsigned char char_O_nullzeit;					
-extern unsigned char char_O_deco_status;				
-extern unsigned char char_O_array_decotime[7];			
-extern unsigned char char_O_array_decodepth[6];		
-extern unsigned char char_O_ascenttime;				
-extern unsigned char char_O_gradient_factor;			
-extern unsigned char char_O_tissue_saturation[32];		
-extern unsigned char char_O_array_gradient_weighted[16];
-extern unsigned char char_O_gtissue_no;				
-extern unsigned char char_O_diluent;				
-extern unsigned char char_O_CNS_fraction;			
-extern unsigned char char_O_relative_gradient_GF;	
-extern unsigned char char_I_deco_gas_change2;       
-extern unsigned char char_I_deco_gas_change3;       
-extern unsigned char char_I_deco_gas_change4;       
-extern unsigned char char_I_deco_gas_change5;       
-
-//---- Bank 9 parameters -----------------------------------------------------
-extern unsigned int  int_O_DBS_bitfield;				
-extern unsigned int  int_O_DBS2_bitfield;				
-extern unsigned int  int_O_DBG_pre_bitfield;			
-extern unsigned int  int_O_DBG_post_bitfield;			
-extern unsigned char char_O_NDL_at_20mtr;				
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/code_part1/OSTC_code_c_part2/shared_definitions.h	Fri Jan 21 01:44:37 2011 +0100
@@ -0,0 +1,146 @@
+#ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+;
+;    shared_definitions.h
+;
+;    Declare variables used both in C and ASM code
+;
+;    This program is free software: you can redistribute it and/or modify
+;    it under the terms of the GNU General Public License as published by
+;    the Free Software Foundation, either version 3 of the License, or
+;    (at your option) any later version.
+;
+;    This program is distributed in the hope that it will be useful,
+;    but WITHOUT ANY WARRANTY; without even the implied warranty of
+;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;    GNU General Public License for more details.
+;
+;    You should have received a copy of the GNU General Public License
+;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;
+;    Copyright (c) 2010, JD Gascuel.
+;=============================================================================
+; RATIONAL
+;
+; We must enforce good data passing between the C and the ASM parts of code.
+; The previous design used two independant definitions of each variable,
+; one in C, one in ASM. If they did not match, no error was generated, and
+; anything can happend at runtime...
+;
+; The new design use LINKING to ensure the variables defined in C are at the
+; same address when used in ASM code. And it uses a unique declaration file
+; (with suitable macros) to make sure they have the same size in both language.
+;
+; HISTORY
+;  2011-01-20: [jDG] Creation.
+;
+; NOTE
+;
+; This file have to obey both ASM and C syntax. The only common directives
+; are #if/#ifdef/#endif and the #define, so they are eavily used to do the
+; trick.
+;
+; BUGS
+;=============================================================================
+#endif
+
+#ifdef __18CXX
+    //------------------------------------------------------------------------
+    // C-style declarations:
+#   define VAR_UCHAR(n)      unsigned char n
+#   define TAB_UCHAR(n,size) unsigned char n[size]
+#   define VAR_UINT(n)       unsigned  int n
+#   define TAB_UINT(n,size)  unsigned  int n[size]
+#else
+    ;-------------------------------------------------------------------------
+    ; ASM-style declarations:
+#define VAR_UCHAR(n)       n    res     1
+#define TAB_UCHAR(n,size)  n    res     size
+#define VAR_UINT(n)        n    res     2
+#define TAB_UINT(n,size)   n    res     2*size
+#endif
+
+#ifdef __18CXX
+    //---- BANK 2 DATA -------------------------------------------------------
+    // Gather all data C-code --> ASM-code
+#   pragma udata overlay bank2=0x200
+#else
+bank2   udata_ovr  0x200
+#endif
+
+VAR_UINT  (int_O_GF_step);
+VAR_UINT  (int_O_gtissue_limit);
+VAR_UINT  (int_O_gtissue_press);
+VAR_UINT  (int_O_limit_GF_low);
+VAR_UINT  (int_O_gtissue_press_at_GF_low);
+VAR_UINT  (int_O_calc_tissue_call_counter);
+
+VAR_UCHAR (char_O_GF_low_pointer);
+VAR_UCHAR (char_O_actual_pointer);
+
+VAR_UINT  (int_O_desaturation_time);       // 
+VAR_UCHAR (char_O_nullzeit);               // 
+VAR_UCHAR (char_O_deco_status);            // 
+VAR_UCHAR (char_O_ascenttime);             // 
+VAR_UCHAR (char_O_gradient_factor);        // 
+VAR_UCHAR (char_O_gtissue_no);             // 
+VAR_UCHAR (char_O_diluent);                // new in v.101
+VAR_UCHAR (char_O_CNS_fraction);           // new in v.101
+VAR_UCHAR (char_O_relative_gradient_GF);   // new in v.102
+
+TAB_UCHAR (char_O_array_decotime, 7);      // Old-school decompression table (ZHL-16)
+TAB_UCHAR (char_O_array_decodepth, 6);     // 
+
+TAB_UCHAR (char_O_deco_table, 0x20);        // New school decompression table (GF mode)
+TAB_UCHAR (char_O_tissue_saturation, 0x20); // Compartiment desaturation time, in min.
+
+VAR_UINT  (int_O_DBS_bitfield);
+VAR_UINT  (int_O_DBS2_bitfield);
+VAR_UINT  (int_O_DBG_pre_bitfield);
+VAR_UINT  (int_O_DBG_post_bitfield);
+VAR_UCHAR (char_O_NDL_at_20mtr);
+
+#ifdef __18CXX
+    //---- BANK 3 DATA -------------------------------------------------------
+    // Gather all data ASM-code --> C-code
+#   pragma udata overlay bank3=0x300
+#else
+    ; In ASM, put the same bank, in overlay mode, at the same address
+bank3   udata_ovr  0x300
+#endif
+
+VAR_UCHAR (char_I_step_is_1min);
+TAB_UCHAR (char_I_table_deco_done, 0x20);
+
+VAR_UINT  (int_I_pres_respiration);        // 
+VAR_UINT  (int_I_pres_surface);            // 
+VAR_UINT  (int_I_temp);                    // new in v101
+VAR_UCHAR (char_I_temp);                   // new in v101
+VAR_UCHAR (char_I_actual_ppO2);            // 
+VAR_UCHAR (char_I_deco_N2_ratio2);         // new in v.109
+VAR_UCHAR (char_I_deco_He_ratio2);         // new in v.109
+VAR_UCHAR (char_I_deco_N2_ratio3);         // new in v.109
+VAR_UCHAR (char_I_deco_He_ratio3);         // new in v.109
+VAR_UCHAR (char_I_deco_N2_ratio4);         // new in v.109
+VAR_UCHAR (char_I_deco_He_ratio4);         // new in v.109
+VAR_UCHAR (char_I_deco_N2_ratio5);         // new in v.109
+VAR_UCHAR (char_I_deco_He_ratio5);         // new in v.109
+VAR_UCHAR (char_I_N2_ratio);               //
+VAR_UCHAR (char_I_He_ratio);               //
+VAR_UCHAR (char_I_saturation_multiplier);  // for conservatism/safety values 1.0  no conservatism to 1.5  50% faster saturation
+VAR_UCHAR (char_I_desaturation_multiplier);// for conservatism/safety values 0.66  50% slower desaturation to 1.0  no conservatism// consveratism used in calc_tissue , calc_tissue_step_1_min  and sim_tissue_1min 
+VAR_UCHAR (char_I_GF_High_percentage);     // new in v.102
+VAR_UCHAR (char_I_GF_Low_percentage);      // new in v.102
+VAR_UCHAR (char_I_deco_distance);          // 
+VAR_UCHAR (char_I_const_ppO2);             // new in v.101
+VAR_UCHAR (char_I_deco_ppO2_change);       // new in v.101
+VAR_UCHAR (char_I_deco_ppO2);              // new in v.101
+VAR_UCHAR (char_I_deco_gas_change);        // new in v.101
+VAR_UCHAR (char_I_deco_N2_ratio);          // new in v.101
+VAR_UCHAR (char_I_deco_He_ratio);          // new in v.101
+VAR_UCHAR (char_I_depth_last_deco);        // new in v.101 unit: [m]
+VAR_UCHAR (char_I_deco_model);             // new in v.102	  1 = MultiGraF, sonst Std. mit  de-saturation_multiplier
+
+VAR_UCHAR (char_I_deco_gas_change2);       // new in v.109
+VAR_UCHAR (char_I_deco_gas_change3);       // new in v.109
+VAR_UCHAR (char_I_deco_gas_change4);       // new in v.109
+VAR_UCHAR (char_I_deco_gas_change5);       // new in v.109