changeset 278:17aab4ca0547

BUGFIX CCR decoplan fails (bug bb42). Make decoplaning faster (just update tissue during bottomtime). Animate ascent depth during decoplaning.
author JeanDo
date Tue, 19 Apr 2011 02:26:41 +0200
parents 46d1012d096a
children 8514588eb6a2
files code_part1/OSTC_code_asm_part1/definitions.asm code_part1/OSTC_code_asm_part1/simulator.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/shared_definitions.h
diffstat 5 files changed, 38 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Mon Apr 18 10:23:22 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Tue Apr 19 02:26:41 2011 +0200
@@ -341,6 +341,7 @@
     extern deco_calc_CNS_fraction
     extern deco_calc_desaturation_time
     extern deco_calc_hauptroutine
+    extern deco_calc_tissue
     extern deco_calc_percentage
     extern deco_calc_wo_deco_step_1_min
     extern deco_clear_CNS_fraction
--- a/code_part1/OSTC_code_asm_part1/simulator.asm	Mon Apr 18 10:23:22 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/simulator.asm	Tue Apr 19 02:26:41 2011 +0200
@@ -376,48 +376,49 @@
 	call	divemode_check_decogases    ; Checks for decogases and sets the gases
 	call	divemode_prepare_flags_for_deco
 
+    ; First minute is special: init everything.
 	movlw	d'3'                        ; Begin of deco cycle (reset table).
 	movff	WREG,char_O_deco_status     ; Reset Deco module.
 
-	movlw	d'0'
-	movff	WREG,char_I_step_is_1min    ; 2 second deco mode for descent.
+	movlw	d'1'
+	movff	WREG,char_I_step_is_1min    ; 1 minute mode.
 
-simulator_calc_deco_loop1:
-	call	deco_calc_hauptroutine      ; calc_tissue
+	call	deco_calc_hauptroutine      ; Reset table + sim one minute for descent.
 	movlb	b'00000001'                 ; rambank 1 selected
 
-	movff	char_O_deco_status,WREG
-	tstfsz	WREG                        ; deco_status=0 if decompression calculation done
-	bra		simulator_calc_deco_loop1   ; Not finished
+    decf    logbook_temp1,F             ; One minute done.
 
-	movlw	d'1'
-	movff	WREG,char_I_step_is_1min    ; 1 minute mode for bottom time.
-
+    ; Loop for bottom time duration
 simulator_calc_deco_loop2:
-	call	PLED_simulator_data
+	call	PLED_simulator_data         ; Update display of bottom time.
 
-	call	deco_calc_hauptroutine		; calc_tissue
+	call	deco_calc_tissue		    ; JUST calc tissue (faster).
 	movlb	b'00000001'                 ; rambank 1 selected
 	ostc_debug	'C'	                    ; Sends debug-information to screen if debugmode active
 
-	decfsz	logbook_temp1,F             ; Decrement bottom time.
-	bra     simulator_calc_deco_loop2
+    decfsz  logbook_temp1,F             ; Decrement bottom time,
+	bra     simulator_calc_deco_loop2   ; and loop while not finished.
 
+    ; No the bottom time is finish, restart a full ascent simulation,
 	movlw	d'0'
-	movff	WREG,char_I_step_is_1min    ; 2 second deco mode
+	movff	WREG,char_I_step_is_1min    ; Back to 2 second deco mode
 
 	clrf	timeout_counter2			; timeout used as maxloop here
+	movff   char_I_bottom_depth,char_O_deco_last_stop
+
 simulator_calc_deco2:
-
 	call	deco_calc_hauptroutine		; calc_tissue
 	movlb	b'00000001'                 ; rambank 1 selected
 
+    movff   char_O_deco_last_stop,logbook_temp2
+    call    PLED_simulator_data         ; Animate ascent simu.
+
 	dcfsnz	timeout_counter2,F			; Abort loop (max. 256 tries)?
 	bra		simulator_calc_deco3		; Yes...
 
 	movff	char_O_deco_status,WREG
-	tstfsz	WREG                        ; deco_status=0 if decompression calculation done
-	bra		simulator_calc_deco2        ; Not finished
+	iorwf	WREG                        ; deco_status=0 if decompression calculation done
+	bnz		simulator_calc_deco2        ; Not finished
 
 simulator_calc_deco3:
     ; Finished
@@ -433,7 +434,8 @@
 
 	movlw	d'5'                            ; Pre-Set Cursor to "Show Decoplan"
 	movwf	menupos
-	movff	char_I_bottom_time,logbook_temp1; restore bottom time.
+	movff	char_I_bottom_time,logbook_temp1    ; Restore bottom time,
+	movff   char_I_bottom_depth,logbook_temp2   ; and depth.
 	bra     menu_simulator1                 ; Done.
 
 simulator_save_tissue_data:
--- a/code_part1/OSTC_code_c_part2/p2_deco.c	Mon Apr 18 10:23:22 2011 +0200
+++ b/code_part1/OSTC_code_c_part2/p2_deco.c	Tue Apr 19 02:26:41 2011 +0200
@@ -925,6 +925,16 @@
 }
 
 //////////////////////////////////////////////////////////////////////////////
+// Called every 1 min during decoplanning.
+// Update tissues for 1 min.
+//
+void deco_calc_tissue(void)
+{
+    RESET_C_STACK
+    calc_hauptroutine_update_tissues();
+}    
+
+//////////////////////////////////////////////////////////////////////////////
 
 void deco_calc_wo_deco_step_1_min(void)
 {
@@ -1240,7 +1250,7 @@
     	copy_deco_table();
     	int_O_ascenttime = 0;       // Reset DTR.
     	char_O_nullzeit = 0;        // Reset bottom time.
-      	char_O_deco_status = 0;     // Calc bottom-time/nullzeit next iteration.
+        char_O_deco_status = 0;     // Calc bottom-time/nullzeit next iteration.
 
         // Values that should be reset just once for the full real dive.
         // This is used to record the lowest stop for the whole dive,
@@ -1457,6 +1467,7 @@
     		        copy_deco_table();
         	        calc_ascenttime();
     		        char_O_deco_status = 0; // calc nullzeit next time.
+                    char_O_deco_last_stop = 0;  // Surface reached.
     		        return;
                 }
             }
@@ -1473,6 +1484,7 @@
 
 	// Surface not reached, need more stops...
     char_O_deco_status = 1; // calc more stops next time.
+    char_O_deco_last_stop = temp_depth_limit;   // Reached depth.
 }
 
 //////////////////////////////////////////////////////////////////////////////
Binary file code_part1/OSTC_code_c_part2/p2_deco.o has changed
--- a/code_part1/OSTC_code_c_part2/shared_definitions.h	Mon Apr 18 10:23:22 2011 +0200
+++ b/code_part1/OSTC_code_c_part2/shared_definitions.h	Tue Apr 19 02:26:41 2011 +0200
@@ -80,7 +80,8 @@
 VAR_UINT  (int_O_ascenttime);              // TTS (in minutes)
 
 VAR_UCHAR (char_O_nullzeit);               // 
-VAR_UCHAR (char_O_deco_status);            // 
+VAR_UCHAR (char_O_deco_status);            // Deko state-machine state.
+VAR_UCHAR (char_O_deco_last_stop);         // Depth reached during deko planning.
 VAR_UCHAR (char_O_gradient_factor);        // 
 VAR_UCHAR (char_O_gtissue_no);             // 
 VAR_UCHAR (char_O_diluent);                // new in v.101
@@ -160,4 +161,4 @@
 
 /// Set WREG color.
 extern void PLED_set_color(void);
-#endif
\ No newline at end of file
+#endif