diff code_part1/OSTC_code_asm_part1/divemode.asm @ 39:1705b3f7e5b3

1.62 beta rc2
author heinrichsweikamp
date Tue, 01 Jun 2010 12:23:17 +0200
parents 8ece4837a642
children 92001c045088
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Mon May 31 19:14:09 2010 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Tue Jun 01 12:23:17 2010 +0200
@@ -322,73 +322,94 @@
 divemode_check_decogases:					; CALLed from Simulator
 ; Copy active gases to char_I_deco_N2_ratio and char_I_deco_He_ratio
 
-	clrf	hi						; # of gas (0-4)
-	; Gas0 is Start gas, do not copy
+	setf	hi						; # of gas (0-4)
 	
 	lfsr	FSR1, char_I_deco_He_ratio5		; most shallow decogas
 divemode_check_decogases2:
-	incf	hi,F						; increase
+	incf	hi,F						; increase (First time: hi=0)
 	rcall	copy_decogas_info
-	movlw	d'4'
-	cpfseq	hi							; 4 Gases copied?
+	movlw	d'3'
+	cpfseq	hi							; Gases 0-3 copied?
 	bra		divemode_check_decogases2	; No, Continue
 
+	read_int_eeprom		d'23'			; Read He ratio
+	movff	EEDATA,char_I_deco_He_ratio	; And copy into hold register
+
+	read_int_eeprom		d'22'			; Read O2 ratio
+	movff	char_I_deco_He_ratio, wait_temp			; copy into bank1 register
+	bsf		STATUS,C					; 
+	movlw	d'100'						; 100%
+	subfwb	wait_temp,W					; minus He
+	subfwb	EEDATA,F					; minus O2
+	movff	EEDATA, char_I_deco_N2_ratio; = N2!
+
 ; Now, set change depth. Inactive gases get depth=0!
 
 	read_int_eeprom		d'27'		; read flag register
 	movff	EEDATA,hi				; temp
 	
+	read_int_eeprom		d'28'		; read gas_change_depth Gas1
+	movlw	d'0'
+	btfsc	hi,0					; Skip if clear -> Skip if inactive
+	movf	EEDATA,W
+	movff	WREG,char_I_deco_gas_change5
+
 	read_int_eeprom		d'29'		; read gas_change_depth Gas2
 	movlw	d'0'
 	btfsc	hi,1					; Skip if clear -> Skip if inactive
 	movf	EEDATA,W
-	movff	WREG,char_I_deco_gas_change5
+	movff	WREG,char_I_deco_gas_change4
 
 	read_int_eeprom		d'30'		; read gas_change_depth Gas3
 	movlw	d'0'
 	btfsc	hi,2					; Skip if clear -> Skip if inactive
 	movf	EEDATA,W
-	movff	WREG,char_I_deco_gas_change4
+	movff	WREG,char_I_deco_gas_change3
 
 	read_int_eeprom		d'31'		; read gas_change_depth Gas4
 	movlw	d'0'
 	btfsc	hi,3					; Skip if clear -> Skip if inactive
 	movf	EEDATA,W
-	movff	WREG,char_I_deco_gas_change3
+	movff	WREG,char_I_deco_gas_change2
 
 	read_int_eeprom		d'32'		; read gas_change_depth Gas5
 	movlw	d'0'
 	btfsc	hi,4					; Skip if clear -> Skip if inactive
 	movf	EEDATA,W
-	movff	WREG,char_I_deco_gas_change2
+	movff	WREG,char_I_deco_gas_change
 
 ; Debugger
-call	enable_rs232	
-	movff	char_I_deco_He_ratio5,TXREG
-	call	rs232_wait_tx				; wait for UART
-	movff	char_I_deco_N2_ratio5,TXREG
-	call	rs232_wait_tx				; wait for UART
-	movff	char_I_deco_He_ratio4,TXREG
-	call	rs232_wait_tx				; wait for UART
-	movff	char_I_deco_N2_ratio4,TXREG
-	call	rs232_wait_tx				; wait for UART
-	movff	char_I_deco_He_ratio3,TXREG
-	call	rs232_wait_tx				; wait for UART
-	movff	char_I_deco_N2_ratio3,TXREG
-	call	rs232_wait_tx				; wait for UART
-	movff	char_I_deco_He_ratio2,TXREG
-	call	rs232_wait_tx				; wait for UART
-	movff	char_I_deco_N2_ratio2,TXREG
-	call	rs232_wait_tx				; wait for UART
-	movff	char_I_deco_gas_change5,TXREG
-	call	rs232_wait_tx				; wait for UART
-	movff	char_I_deco_gas_change4,TXREG
-	call	rs232_wait_tx				; wait for UART
-	movff	char_I_deco_gas_change3,TXREG
-	call	rs232_wait_tx				; wait for UART
-	movff	char_I_deco_gas_change2,TXREG
-	call	rs232_wait_tx				; wait for UART
-
+;call	enable_rs232	
+;	movff	char_I_deco_He_ratio5,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_N2_ratio5,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_He_ratio4,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_N2_ratio4,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_He_ratio3,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_N2_ratio3,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_He_ratio2,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_N2_ratio2,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_He_ratio,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_N2_ratio,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_gas_change5,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_gas_change4,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_gas_change3,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_gas_change2,TXREG
+;	call	rs232_wait_tx				; wait for UART
+;	movff	char_I_deco_gas_change,TXREG
+;	call	rs232_wait_tx				; wait for UART
 	return
 
 copy_decogas_info:
@@ -422,7 +443,7 @@
 	movff	lo,char_I_deco_gas_change4
 	movff	lo,char_I_deco_gas_change3
 	movff	lo,char_I_deco_gas_change2
-; 	movff	lo, char_I_deco_gas_change	; clear 
+ 	movff	lo, char_I_deco_gas_change	; clear 
 ;	movff	lo, char_I_deco_N2_ratio	; clear
 ;	movff	lo, char_I_deco_He_ratio	; clear
 ;call	PLED_gaschange_DEBUG