changeset 250:4ef3bcbc7091

Fix minor CNS calc when ppO2 > 2.55
author JeanDo
date Tue, 29 Mar 2011 23:47:19 +0200 (2011-03-29)
parents 544cc5d47755
children f0cba9cff25c
files code_part1/OSTC_code_asm_part1/divemode.asm
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Tue Mar 29 22:59:58 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Tue Mar 29 23:47:19 2011 +0200
@@ -284,9 +284,12 @@
 	call		div16x16				; xC=(char_I_O2_ratio * p_amb/10)/100
 
 ; Copy ppO2 for CNS calculation
-	movff		xC+0, char_I_actual_ppO2	; copy last ppO2 to buffer register
-	btfsc		FLAG_const_ppO2_mode		; do in const_ppO2_mode
-	movff		char_I_const_ppO2, char_I_actual_ppO2	; copy last ppO2 to buffer register
+    tstfsz      xC+1                    ; Is ppO2 > 2.55bar ?
+    setf        xC+0                    ; yes: bound to 2.55... better than wrap around.
+
+    movff		xC+0, char_I_actual_ppO2	; copy last ppO2 to buffer register
+    btfsc		FLAG_const_ppO2_mode		; do in const_ppO2_mode
+    movff		char_I_const_ppO2, char_I_actual_ppO2	; copy last ppO2 to buffer register
 
 ; Calculate CNS	
 	call	deco_calc_CNS_fraction		; calculate CNS