changeset 316:48685a69735e

Merge with @5 escape TTS
author JeanDo
date Wed, 04 May 2011 10:46:16 +0200
parents 91371c7553f5 (current diff) cce563347c94 (diff)
children 1de9eee3837b
files
diffstat 12 files changed, 214 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/customview.asm	Mon May 02 16:14:07 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/customview.asm	Wed May 04 10:46:16 2011 +0200
@@ -75,18 +75,18 @@
 	bra		customview_1sec_graphs      ; Update the leading tissue
 	dcfsnz	WREG,F
 	bra		customview_1sec_ead_end		; Show END and EAD in divemode
+	dcfsnz	WREG,F
+	bra		customview_1sec_@5          ; Show TTS for extra time.
 
 	; Menupos3=0, do nothing
 	return
 
 customview_1sec_average:
-	call	PLED_total_average_show2	; Update the figures only
-	return
+	goto	PLED_total_average_show2	; Update the figures only
 	
 customview_1sec_stopwatch:
 	bsf		menu3_active                ; Set Flag
-	call	PLED_stopwatch_show2        ; Update figures only
-	return
+	goto	PLED_stopwatch_show2        ; Update figures only
 
 customview_1sec_marker:                 ; Do nothing extra
 	bsf		menu3_active                ; Set Flag
@@ -102,12 +102,13 @@
 
 	call	deco_calc_desaturation_time	; calculate desaturation time
 	movlb	b'00000001'						; select ram bank 1
-	call	PLED_tissue_saturation_graph
-	return
+	goto	PLED_tissue_saturation_graph
 
 customview_1sec_ead_end:
-	call	PLED_show_end_ead_divemode
-	return
+	goto	PLED_show_end_ead_divemode
+
+customview_1sec_@5:
+    goto    PLED_show_@5
 
 ;=============================================================================
 ; Do every-minute tasks for the custom view area
@@ -127,19 +128,20 @@
 	dcfsnz	WREG,F
 	bra		customview_minute_graphs	; Update the graphs
 	dcfsnz	WREG,F
-	bra		customview_minute_ead_end	; Show END and EAD in divemode
+	bra		customview_minute_ead_end   ; Show END and EAD in divemode
+	dcfsnz	WREG,F
+	bra		customview_minute_@5        ; Show TTS for extra time.
 
 	; Menupos3=0, do nothing
 	return
 
 customview_minute_clock:
-	call	PLED_diveclock2             ; Update the clock
-	return
+	goto	PLED_diveclock2             ; Update the clock
 
 customview_minute_lead_tiss:
-	call	PLED_show_leading_tissue_2  ; Update the leading tissue
-	return
+	goto	PLED_show_leading_tissue_2  ; Update the leading tissue
 
+customview_minute_@5:                   ; Do nothing extra
 customview_minute_ead_end:              ; Do nothing extra
 customview_minute_marker:               ; Do nothing extra
 customview_minute_stopwatch:            ; Do nothing extra
@@ -148,7 +150,7 @@
 	return
 
 ;=============================================================================
-; Yes, show next customview (and delete this flag)
+; Show next customview (and delete this flag)
 
 customview_toggle:
 	bcf		menu3_active	;=1: menu entry three in divemode menu is active		
@@ -158,10 +160,11 @@
 	bra		customview_toggle_exit			; Yes, ignore custom view in divemode completely
 
 	incf	menupos3,F			            ; Number of customview to show
-	movlw	d'7'							; Max number
+	movlw	d'8'							; Max number
 	cpfsgt	menupos3			            ; Max reached?
 	bra		customview_mask		            ; No, show
 	clrf	menupos3			            ; Reset to zero (Zero=no custom view)
+
 customview_mask:	
 	call	PLED_clear_customview_divemode
 	movff	menupos3,WREG                   ; Menupos3 holds number of customview function
@@ -179,6 +182,9 @@
 	bra		customview_init_graphs		    ; Show the graphs
 	dcfsnz	WREG,F
 	bra		customview_init_ead_end		    ; Show END and EAD in divemode
+	dcfsnz	WREG,F
+	bra		customview_init_@5              ; Show TTS for extra time.
+    bcf     tts_extra_time                  ; Else, CLEAR computation of @5 request.
 
 customview_init_nocustomview:
 	bra		customview_toggle_exit	
@@ -222,9 +228,31 @@
 	bra		    customview_toggle_exit	
 
 customview_init_ead_end:
+	btfsc		no_deco_customviews		; no-deco-mode-flag = 1
+	bra			customview_toggle		; Yes, use next Customview!
+
 	call		PLED_show_end_ead_divemode
 	bra		    customview_toggle_exit	
 
+customview_init_@5:
+ 	GETCUSTOM8	d'58'					; Extra time to simulate
+ 	iorwf       WREG,F                  ; Null ?
+ 	bz          customview_toggle       ; Yes: use next Customview !
+
+	btfsc		no_deco_customviews		; no-deco-mode-flag = 1
+	bra			customview_toggle		; Yes, use next Customview!
+
+    clrf        WREG                    ; Reset extra TTS
+    movff       WREG,int_O_extra_ascenttime+0
+    movff       WREG,int_O_extra_ascenttime+1
+    
+    movlw       1
+    movwf       apnoe_mins              ; Start compute after next cycle.
+    bsf         tts_extra_time
+    call        PLED_show_@5            ; Show (wait)
+
+	bra		    customview_toggle_exit	
+
 customview_init_graphs:					; Show tissue graph
  	GETCUSTOM8	d'52'					; Show Tissue Graph? (=1 in WREG)
 	decfsz		WREG,F					; WREG=1?	
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Mon May 02 16:14:07 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Wed May 04 10:46:16 2011 +0200
@@ -387,11 +387,11 @@
 #DEFINE win_flip_screen     win_flags,0 ; 180° rotation of the OLED screen.
 
 ; Flags
-#DEFINE	FLAG_scale			flag1,0	; Wordprocessor
-#DEFINE	FLAG_truncated		flag1,1	; Wordprocessor
+#DEFINE	tts_extra_time		flag1,0	; unused
+#DEFINE	FLAG_2      		flag1,1	; unused
 #DEFINE	pre_zero_flag		flag1,2	; leading zeros
 #DEFINE neg_flag			flag1,3	; e.g. Sub_16 (sub_c = sub_a - sub_b)
-#DEFINE	FLAG_row_prime		flag1,4	; Wordproceesor
+#DEFINE	FLAG_3      		flag1,4	; unused
 #DEFINE leading_zeros		flag1,5	; display leading zeros?
 #DEFINE	show_last3			flag1,6	; show only three figures
 #DEFINE	leftbind			flag1,7	; leftbinded output
@@ -427,7 +427,7 @@
 
 #DEfINE	eeprom_overflow		flag5,0	; EEPROM overflowed (>32KB)
 #DEFINE	eeprom_blockwrite	flag5,1	; EEPROM blockwrite active
-#DEFINE neg_flag_xdT		flag5,2	; xdT negative (2nd order temperature calculation)
+#DEFINE Flag_4      		flag5,2	; unused
 #DEFINE	low_battery_state	flag5,3	;=1 if battery low
 #DEFINE	DP_done				flag5,4	; valconv
 #DEFINE	DP_done2			flag5,5	; valconv
@@ -513,7 +513,7 @@
 #DEFINE	display_set_simulator	flag14,4	;=1: Show Divemode simulator menu
 #DEFINE	displaytext_high		flag14,5	;=1: Show/Use Texts 255-511 in Texttable
 #DEFINE	better_gas_available	flag14,6	;=1: A better gas is available and a gas change is advised in divemode
-#DEFINE	displaytext_invert		flag14,7	;=1: inverts word prozessor output
+#DEFINE	Flag_5          		flag14,7	;=1: unused
 
 #DEFINE	restore_deco_data		flag15,0	;=1: Restore Decodata after the dive from 0x380 buffer
 #DEFINE	uart_store_tissue_data	flag15,1	;=1: Store tissue data for next simualted dive!
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Mon May 02 16:14:07 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Wed May 04 10:46:16 2011 +0200
@@ -456,6 +456,11 @@
 	return
 
  	ostc_debug	'B'		; Sends debug-information to screen if debugmode active
+    ; Send nes state to screen, if debugmode active	
+	movff   char_O_deco_status,WREG ; Status before call
+	addlw   '0'                     ; Convert to ascii char
+	call    ostc_debug1             ; and send.
+
 	call	divemode_prepare_flags_for_deco
 	clrf	WREG
 	movff	WREG,char_I_step_is_1min    ; Force 2 second deco mode
@@ -497,21 +502,50 @@
 	call	word_processor
 
 calc_deko_divemode4:
+    movff   char_O_deco_status,WREG     ; Is a compute cycle finished ?
+    iorwf   WREG,F
+    btfss   STATUS,Z
+    return                              ; Return is status <> 0
 
+    ; Check if deco stops are necessary ?
 	movff	char_O_first_deco_depth,wait_temp	; copy ceiling to temp register
 	tstfsz	wait_temp							; Ceiling<0m?
 	bra		calc_deko_divemode3					; Yes!
 
-	btfsc	dekostop_active
-	call	PLED_display_ndl_mask			; Clear deco data, display nostop time
-	bcf		dekostop_active					; clear flag
+	btfsc	dekostop_active             ; Already in nodeco mode ?
+	call	PLED_display_ndl_mask       ; Clear deco data, display nostop time
+	bcf		dekostop_active             ; clear flag
 
-	clrf	decodata+0						; for profile memory
-	movff	char_O_nullzeit,decodata+1		; nostop time
+	clrf	decodata+0                  ; for profile memory
+	movff	char_O_nullzeit,decodata+1  ; nostop time
 	
-	call	PLED_display_ndl				; display no deco limit
+	call	PLED_display_ndl            ; display no deco limit
 	return
 
+calc_deko_divemode3:
+	btfss	dekostop_active             ; Already in deco mode ?
+	call	PLED_display_deko_mask      ; clear nostop time, display decodata
+	bsf		dekostop_active             ; Set flag
+
+	movff	char_O_first_deco_depth,decodata+0	; ceiling
+	movff	char_O_first_deco_time,decodata+1	; length of first stop in minues
+
+	call	PLED_display_deko           ; display decodata
+
+    ; Check if extra cycles are needed to compute @5 variant:
+    btfss   tts_extra_time              ; Is @5 displayed ?
+	return                              ; No: don't compute it.
+	
+	decfsz  apnoe_mins                  ; Reached count-down ?
+	return                              ; No: don't compute yet.
+	
+	movlw   .6
+	movff   WREG,char_O_deco_status     ; Stole next cycles for @5 variant.
+    
+    movlw   .2                          ; Restart countdown.
+    movwf   apnoe_mins
+    return
+    
 ;-----------------------------------------------------------------------------
 
 divemode_prepare_flags_for_deco:
@@ -529,16 +563,7 @@
 	movff   divemins+1,int_I_divemins+1
 	goto	restart_set_modes_and_flags			; Sets decomode (char_I_deco_model) and flags (again)
 
-calc_deko_divemode3:
-	btfss	dekostop_active
-	call	PLED_display_deko_mask              ; clear nostop time, display decodata
-	bsf		dekostop_active						; Set flag
-
-	movff	char_O_first_deco_depth,decodata+0	; ceiling
-	movff	char_O_first_deco_time,decodata+1	; length of first stop in minues
-
-	call	PLED_display_deko					; display decodata
-	return						
+;-----------------------------------------------------------------------------
 
 store_dive_data:						; CF20 seconds gone
 	bcf		store_sample				; update only any CF20 seconds
@@ -1685,8 +1710,9 @@
 	setf	last_diluent				; to be displayed after first calculation (range: 0 to 100 [%])
 	bcf		dekostop_active	
 	bcf		is_bailout					;=1: CC mode, but bailout active!		
-	bcf		better_gas_available	;=1: A better gas is available and a gas change is advised in divemode
-	
+	bcf		better_gas_available        ;=1: A better gas is available and a gas change is advised in divemode
+    bcf     tts_extra_time              ;=1: Compute TTS if extra time spent at current depth
+
 	call	get_free_EEPROM_location	; get last position in external EEPROM, may be up to 2 secs!
 
     btfss   simulatormode_active
--- a/code_part1/OSTC_code_asm_part1/english_text.asm	Mon May 02 16:14:07 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/english_text.asm	Wed May 04 10:46:16 2011 +0200
@@ -243,15 +243,15 @@
     TCODE    .40,   .35,     "Show Lead.Tiss."           ;175 Show Lead.Tiss.
     TCODE    .40,   .35,     "ShallowStop 1st"           ;176 Shallow stop 1st  (Reverse order of deco plans)
     TCODE    .40,   .35,     "Gas switch[min]"           ;177 Gas switch[min]   (Additional delay in decoplan for gas switches).
-    TCODE    .40,   .35,     "BottomGas[l/mn]"           ;178 BottomGas[l/mn]   (Bottom gas usage, for volume estimation).
-    TCODE    .40,   .35,     "AscentGas[l/mn]"           ;179 AscentGas[l/mn]   (Ascent+Deco gas usage)
-    TCODE    .40,   .35,     "not used       "           ;180 not used
+    TCODE    .40,   .35,     "BottomGas[/min]"           ;178 BottomGas[/min]   (Bottom gas usage, for volume estimation).
+    TCODE    .40,   .35,     "AscentGas[/min]"           ;179 AscentGas[/min]   (Ascent+Deco gas usage)
+    TCODE    .40,   .35,     "Escape TTS[min]"           ;180 Escape TTS[min]   (@5 variant: compute TTS for extra time at current depth)
     TCODE    .40,   .35,     "not used       "           ;181 not used
     TCODE    .40,   .35,     "not used       "           ;182 not used
     TCODE    .40,   .35,     "not used       "           ;183 not used
     TCODE    .40,   .35,     "not used       "           ;184 not used
     TCODE    .40,   .35,     "not used       "           ;185 not used
-; End of function descriptor I
+; End of function descriptor II
 ;
     TCODE    .13,   .2,      "Custom Functions II"       ;186 Custom Functions II
     TCODE    .20,   .95,     "Show License"              ;187 Show License
@@ -385,7 +385,10 @@
     TCODE    .0,    .0,      "EAD:"                      ;299 EAD:                  (equivalent air depth of a gas).
 	TCODE	 .100,	.125,	 "Active?"					 ;300 Active?               (Enable/Disable Gas underwater)
 	TCODE    .0,    .2,      "OCR Gas Usage:"            ;301 OCR Gas Usage:        (Planned gas consumtion by tank).
+; 115k Bootloader support:
 	TCODE	 .45,	.100,	 "Bootloader"				 ;302 Bootloader
 	TCODE	 .40,	.130,	 "Please wait!"				 ;303 Please wait!
 	TCODE	 .50,	.130,	 "Aborted!"					 ;304 Aborted
+;@5 variant
+    TCODE    .0,    .0,      "Escape TTS"                ;305 Escape TTS            (=10 chars. Title for @5 customview).
 ;=============================================================================
--- a/code_part1/OSTC_code_asm_part1/french_text.asm	Mon May 02 16:14:07 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/french_text.asm	Wed May 04 10:46:16 2011 +0200
@@ -244,15 +244,15 @@
     TCODE    .40,   .35,     "Aff.Tiss.Direct"           ;175 Show Lead.Tiss.
     TCODE    .40,   .35,     "Ordre paliers  "           ;176 Shallow stop 1st   (Reverse order of deco plans)
     TCODE    .40,   .35,     "Chang. gaz[min]"           ;177 Gas switch[min]   (Additional delay in decoplan for gas switches).
-    TCODE    .40,   .35,     "ConsoFond[l/mn]"           ;178 BottomGas[l/mn]   (Bottom gas usage, for volume estimation).
-    TCODE    .40,   .35,     "ConsoDeco[l/mn]"           ;179 AscentGas[l/mn]   (Ascent+Deco gas usage)
-    TCODE    .40,   .35,     "not used       "           ;180 not used
+    TCODE    .40,   .35,     "ConsoFond[/min]"           ;178 BottomGas[/min]   (Bottom gas usage, for volume estimation).
+    TCODE    .40,   .35,     "ConsoDeco[/min]"           ;179 AscentGas[/min]   (Ascent+Deco gas usage)
+    TCODE    .40,   .35,     "DTR Réchap[min]"           ;180 Escape TTS[min]   (@5 variant: compute TTS for extra time at current depth)
     TCODE    .40,   .35,     "not used       "           ;181 not used
     TCODE    .40,   .35,     "not used       "           ;182 not used
     TCODE    .40,   .35,     "not used       "           ;183 not used
     TCODE    .40,   .35,     "not used       "           ;184 not used
     TCODE    .40,   .35,     "not used       "           ;185 not used
-; End of function descriptor I
+; End of function descriptor II
 ;
     TCODE    .13,   .2,      "Config Fonctions II"       ;186 Custom Functions II
     TCODE    .20,   .95,     "Voir la licence"           ;187 Show License
@@ -386,7 +386,10 @@
     TCODE    .0,    .0,      "PEA:"                      ;299 EAD:                  (equivalent air depth of a gas).
 	TCODE	 .100,	.125,	 "Active?"					 ;300 Active?               (Enable/Disable Gas underwater)
 	TCODE    .0,    .2,      "OCR Gas Usage:"            ;301 OCR Gas Usage:        (Planned gas consumtion by tank).
+; 115k Bootloader support:
 	TCODE	 .45,	.100,	 "Bootloader"				 ;302 Bootloader
 	TCODE	 .40,	.130,	 "Please wait!"				 ;303 Please wait!
 	TCODE	 .50,	.130,	 "Aborted!"					 ;304 Aborted
+;@5 variant
+    TCODE    .0,    .0,      "DTR Réchap"                ;305 TTS in ...            (=10 chars. Title for @5 customview).
 ;=============================================================================
--- a/code_part1/OSTC_code_asm_part1/german_text.asm	Mon May 02 16:14:07 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/german_text.asm	Wed May 04 10:46:16 2011 +0200
@@ -244,15 +244,15 @@
     TCODE    .40,   .35,     "Leitgewebe anz "           ;175 Show Lead.Tiss.
     TCODE    .40,   .35,     "Flach.StoppOben"           ;176 Shallow stop 1st  (Reverse order of deco plans)
     TCODE    .40,   .35,     "Gaswechsel[min]"           ;177 Gas switch[min]   (Additional delay in decoplan for gas switches).
-    TCODE    .40,   .35,     "BottomGas[l/mn]"           ;178 BottomGas[l/mn]   (Bottom gas usage, for volume estimation).
-    TCODE    .40,   .35,     "Sonst.Gas[l/mn]"           ;179 AscentGas[l/mn]   (Ascent+Deco gas usage)
-    TCODE    .40,   .35,     "nicht verwendet"           ;180 not used
+    TCODE    .40,   .35,     "BottomGas[/min]"           ;178 BottomGas[/min]   (Bottom gas usage, for volume estimation).
+    TCODE    .40,   .35,     "Sonst.Gas[/min]"           ;179 AscentGas[/min]   (Ascent+Deco gas usage)
+    TCODE    .40,   .35,     "TTS @ Zeit[min]"           ;180 Escape TTS[min]   (@5 variant: compute TTS for extra time at current depth)
     TCODE    .40,   .35,     "nicht verwendet"           ;181 not used
     TCODE    .40,   .35,     "nicht verwendet"           ;182 not used
     TCODE    .40,   .35,     "nicht verwendet"           ;183 not used
     TCODE    .40,   .35,     "nicht verwendet"           ;184 not used
     TCODE    .40,   .35,     "nicht verwendet"           ;185 not used
-; End of function descriptor I
+; End of function descriptor II
 ;
     TCODE    .13,   .2,      "Custom Funktionen II"      ;186 Custom Functions II
     TCODE    .20,   .95,     "Lizenz anzeigen "          ;187 Show License
@@ -386,7 +386,10 @@
     TCODE    .0,    .0,      "EAD:"                      ;299 EAD:                  (equivalent air depth of a gas).
     TCODE  .100,  .125,	     "Aktiv?"			 		 ;300 Active?               (Enable/Disable Gas underwater)
     TCODE    .0,    .2,      "OCR Gasverbrauch:"         ;301 OCR Gas Usage:        (Planned gas consumtion by tank).
+; 115k Bootloader support:
 	TCODE	 .45,	.100,	 "Bootloader"				 ;302 Bootloader
 	TCODE	 .35,	.130,	 "Bitte Warten!"			 ;303 Please wait!
 	TCODE	 .40,	.130,	 "Abgebrochen!"				 ;304 Aborted
+;@5 variant
+    TCODE    .0,    .0,      "TTS @+Min."                ;305 Escape TTS            (=10 chars. Title for @5 customview).
 ;=============================================================================
--- a/code_part1/OSTC_code_asm_part1/menu_reset.asm	Mon May 02 16:14:07 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_reset.asm	Wed May 04 10:46:16 2011 +0200
@@ -175,7 +175,7 @@
 	CF_DEFAULT    CF_DECI,      d'200', d'5',   0       ; CF56 Bottom gas usage (l/min or bar/min)
 
 	CF_DEFAULT    CF_DECI,      d'200', d'5',   0       ; CF57 Ascent/deco gas usage (l/min or bar/min)
-	CF_DEFAULT    CF_INT15,     0,      0,      0 		; UNUSED
+	CF_DEFAULT    CF_INT8,      d'0',   d'0',   d'10'   ; CF58 TTS for extra time at current depth [min]
 	CF_DEFAULT    CF_INT15,     0,      0,      0 		; UNUSED
 	CF_DEFAULT    CF_INT15,     0,      0,      0 		; UNUSED
 	CF_DEFAULT    CF_INT15,     0,      0,      0 		; UNUSED
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Mon May 02 16:14:07 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Wed May 04 10:46:16 2011 +0200
@@ -3121,6 +3121,48 @@
 	return
 
 ;=============================================================================
+; Display TTS after extra time at the same depth.
+;
+PLED_show_@5:
+	call		PLED_divemask_color     ; Set Color for Divemode mask
+
+	WIN_FONT    FT_SMALL
+    WIN_LEFT    .160-.70                ; 10 chars aligned right.
+    WIN_TOP     .170
+    lfsr        FSR2,letter
+    OUTPUTTEXTH .305                    ; "TTS in ..."
+    call        word_processor
+
+    WIN_LEFT	.97
+    WIN_TOP     .194
+    STRCPY      "@"
+	GETCUSTOM8  d'58'
+	movwf       lo
+	bsf         leftbind
+	output_8
+	bcf         leftbind
+	STRCAT_PRINT "':"
+    
+	WIN_LEFT    .97+7*5                ; "@10':" is 5 chars long
+	call        PLED_standard_color 
+	
+	lfsr        FSR2,letter
+	movff       int_O_extra_ascenttime+0,lo
+    movff       int_O_extra_ascenttime+1,hi
+    movf        lo,W
+	iorwf       hi,W
+	bz          PLED_show_@5_wait
+	bsf         leftbind
+	output_16
+	bcf         leftbind
+	STRCAT_PRINT "'  "                  ; From "999'" to "1'  " we need 2 trailing spaces
+	return
+
+PLED_show_@5_wait:
+    STRCPY_PRINT "xx' "
+    return
+
+;=============================================================================
 
 PLED_show_leading_tissue:
 	call		PLED_divemask_color	; Set Color for Divemode mask
--- a/code_part1/OSTC_code_asm_part1/spanish_text.asm	Mon May 02 16:14:07 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/spanish_text.asm	Wed May 04 10:46:16 2011 +0200
@@ -243,15 +243,15 @@
     TCODE    .40,   .35,     "Mostr. TejContr"           ;175 Show Lead.Tiss.
     TCODE    .40,   .35,     "PriParadaSuperf"           ;176 Shallow stop 1st  (Reverse order of deco plans)
     TCODE    .40,   .35,     "Conmu. gas[min]"           ;177 Gas switch[min]   (Additional delay in decoplan for gas switches).
-    TCODE    .40,   .35,     "Gas Fondo[l/mn]"           ;178 BottomGas[l/mn]   (Bottom gas usage, for volume estimation).
-    TCODE    .40,   .35,     "GasAscens[l/mn]"           ;179 AscentGas[l/mn]   (Ascent+Deco gas usage)
-    TCODE    .40,   .35,     "sin uso        "           ;180 not used
+    TCODE    .40,   .35,     "Gas Fondo[/min]"           ;178 BottomGas[/min]   (Bottom gas usage, for volume estimation).
+    TCODE    .40,   .35,     "GasAscens[/min]"           ;179 AscentGas[/min]   (Ascent+Deco gas usage)
+    TCODE    .40,   .35,     "EscaparTTS[min]"           ;180 Escape TTS[min]   (@5 variant: compute TTS for extra time at current depth)
     TCODE    .40,   .35,     "sin uno        "           ;181 not used
     TCODE    .40,   .35,     "sin uso        "           ;182 not used
     TCODE    .40,   .35,     "sin uso        "           ;183 not used
     TCODE    .40,   .35,     "sin uso        "           ;184 not used
     TCODE    .40,   .35,     "sin uso        "           ;185 not used
-; End of function descriptor I
+; End of function descriptor II
 ;
     TCODE    .13,   .2,      "Func.Personaliz. II"       ;186 Custom Functions II
     TCODE    .20,   .95,     "Ver Licencia"              ;187 Show License
@@ -385,7 +385,10 @@
     TCODE    .0,    .0,      "EAD:"                      ;299 EAD:                  (equivalent air depth of a gas).
 	TCODE	 .100,	.125,	 "¿Activar?"				 ;300 Active?               (Enable/Disable Gas underwater)
 	TCODE    .0,    .2,      "Uso Gas OCR:"              ;301 OCR Gas Usage:        (Planned gas consumtion by tank).
+; 115k Bootloader support:
 	TCODE	 .45,	.100,	 "Bootloader"				 ;302 Bootloader
 	TCODE	 .40,	.130,	 "Please wait!"				 ;303 Please wait!
 	TCODE	 .50,	.130,	 "Aborted!"					 ;304 Aborted
+;@5 variant
+    TCODE    .0,    .0,      "EscaparTTS"                ;305 Escape TTS            (=10 chars. Title for @5 customview).
 ;=============================================================================
--- a/code_part1/OSTC_code_c_part2/p2_deco.c	Mon May 02 16:14:07 2011 +0200
+++ b/code_part1/OSTC_code_c_part2/p2_deco.c	Wed May 04 10:46:16 2011 +0200
@@ -76,6 +76,7 @@
 // 2011/04/15: [jDG] Store low_depth in 32bits (w/o rounding), for a better stability.
 // 2011/04/25: [jDG] Added 1mn mode for CNS calculation, to allow it for decoplanning.
 // 2011/04/27: [jDG] Fixed char_O_gradient_factor calculation when model uses gradient-factor.
+// 2011/05/02: [jDG] Added @+5min variant.
 //
 // TODO:
 //  + Allow to abort MD2 calculation (have to restart next time).
@@ -126,6 +127,8 @@
 static void restore_sim_pres_tissue(void);
 static void sim_tissue(PARAMETER unsigned char period);
 static void sim_limit(PARAMETER float GF_current);
+static void sim_extra_time(void);
+
 static void calc_gradient_factor(void);
 static void calc_wo_deco_step_1_min(void);
 
@@ -1224,6 +1227,10 @@
 // | +------< not finished
 // +--------< finish
 //
+// Added steps 6,5 for @+5 calculation:
+//      6 = ascent to first stop (same as 2), except continue to 7
+//      7 = same as 1, except loop to 7.
+//
 static void calc_hauptroutine(void)
 {
 	static unsigned char backup_gas_used  = 0;
@@ -1268,12 +1275,14 @@
         break;
 
     case 0: //---- bottom time -----------------------------------------------
+    default:
     	calc_nullzeit();
     	check_ndl();
    	    char_O_deco_status = 2; // calc ascent next time.
     	break;
 
     case 2: //---- Simulate ascent to first stop -----------------------------
+    case 6: // @+5min variation
         // Check proposed gas at begin of ascent simulation
         sim_dive_mins = int_I_divemins;         // Init current time.
 
@@ -1286,15 +1295,17 @@
 
     	sim_ascent_to_first_stop();
 
-        char_O_deco_status = 1;     // Calc stops next time (deco or gas switch).
+        // Calc stops next time (deco or gas switch).
+        char_O_deco_status = 1 | ( char_O_deco_status & 4 );
     	break;
 
     case 1: //---- Simulate stops --------------------------------------------
+    case 5: // @+5 variation.
     	calc_hauptroutine_calc_deco();
 
         // If simulation is finished, restore the GF low reference, so that
         // next ascent simulation is done from the current depth:
-    	if( char_O_deco_status == 0 )
+    	if( (char_O_deco_status & 3) == 0 )
     	{
             sim_gas_last_used  = backup_gas_used;
             sim_gas_last_depth = backup_gas_depth;
@@ -1494,9 +1505,11 @@
                 if( temp_deco <= pres_surface )
                 {
 Surface:
-    		        copy_deco_table();
-        	        calc_ascenttime();
-    		        char_O_deco_status = 0; // calc nullzeit next time.
+                    if( char_O_deco_status == 1 )  // Don't in @+5min variant.
+                        copy_deco_table();      
+
+                    calc_ascenttime();
+                    char_O_deco_status = 0;     // calc nullzeit next time.
                     char_O_deco_last_stop = 0;  // Surface reached.
     		        return;
                 }
@@ -1513,7 +1526,6 @@
 	}
 
 	// 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.
 }
 
@@ -1524,6 +1536,8 @@
 //       there is no need to break on more that 16 iterations
 //       (or we are already in deep shit).
 //
+// if char_O_deco_status indicate @+5 variant, add extra time at current depth,
+// before ascent.
 void sim_ascent_to_first_stop(void)
 {
     update_startvalues();
@@ -1531,6 +1545,10 @@
 
    	temp_deco = pres_respiration;       // Starts from current real depth.
 
+    // Are we doing the special @+5min variation ?
+    if(char_O_deco_status & 4)
+        sim_extra_time();
+
     // Do we have a gas switch going on ?
     if( sim_gas_delay > sim_dive_mins )
         return;
@@ -1574,6 +1592,19 @@
 }
 
 //////////////////////////////////////////////////////////////////////////////
+// Simulation extra time at the current depth.
+//
+// This routine is used for @+5min feature.
+void sim_extra_time(void)
+{
+    overlay unsigned char extra = read_custom_function(58);
+    do {
+        sim_dive_mins++;                // Advance simulated time by 1 minute.
+		sim_tissue(1);                  // and update tissues for 1 min.
+    } while( --extra != 0 );
+}
+
+//////////////////////////////////////////////////////////////////////////////
 // calc_tissue
 //
 // optimized in v.101
@@ -1713,20 +1744,30 @@
 //////////////////////////////////////////////////////////////////////////////
 // calc_ascenttime
 //
+// Summup ascent from bottom to surface, at 1 bar/min, 1min for last 3 meters,
+// and all stops.
+//
+// Result in int_O_ascenttime, or int_O_extra_ascenttime if in @+5min variant.
 static void calc_ascenttime(void)
 {
-    if (pres_respiration > pres_surface)
+    if( pres_respiration > pres_surface )
     {
         overlay unsigned char x;
+        overlay unsigned short sum;
 
         // + 0.7 to count 1 minute ascent time from 3 metre to surface
         overlay float ascent = pres_respiration - pres_surface + 0.7; 
         if (ascent < 0.0)
             ascent = 0.0;
-        int_O_ascenttime = (unsigned short)(ascent + 0.99);
+        sum = (unsigned short)(ascent + 0.99);
 
         for(x=0; x<32 && internal_deco_depth[x]; x++)
-            int_O_ascenttime += (unsigned short)internal_deco_time[x];
+            sum += (unsigned short)internal_deco_time[x];
+
+        if( char_O_deco_status == 1 )
+            int_O_ascenttime = sum;
+        else
+            int_O_extra_ascenttime = sum;
     }
     else
         int_O_ascenttime = 0;
Binary file code_part1/OSTC_code_c_part2/p2_deco.o has changed
--- a/code_part1/OSTC_code_c_part2/shared_definitions.h	Mon May 02 16:14:07 2011 +0200
+++ b/code_part1/OSTC_code_c_part2/shared_definitions.h	Wed May 04 10:46:16 2011 +0200
@@ -78,6 +78,7 @@
 VAR_UINT  (int_O_gtissue_press);
 VAR_UINT  (int_O_desaturation_time);       // 
 VAR_UINT  (int_O_ascenttime);              // TTS (in minutes)
+VAR_UINT  (int_O_extra_ascenttime);        // TTS for @+5min variant (in minutes)
 
 VAR_UCHAR (char_O_nullzeit);               // 
 VAR_UCHAR (char_O_deco_status);            // Deko state-machine state.