changeset 290:4dbff2aa31ee

Hunting for refusing to ignore disabled gas in list... + Keep gaslist in order.
author JeanDo
date Fri, 22 Apr 2011 00:13:39 +0200
parents 6d8a2550c9ea
children 916df3161d52
files code_part1/OSTC_code_asm_part1/definitions.asm code_part1/OSTC_code_asm_part1/divemode.asm code_part1/OSTC_code_asm_part1/divemode_menu.asm code_part1/OSTC_code_asm_part1/menu_gassetup.asm code_part1/OSTC_code_asm_part1/pled_outputs.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
diffstat 8 files changed, 68 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Thu Apr 21 20:09:09 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Fri Apr 22 00:13:39 2011 +0200
@@ -331,7 +331,7 @@
 
 convert_value_temp      res 3   ; used in menu_battery_state_convert_date
 time_correction_value   res 1   ; Adds to Seconds on midnight
-sorted_gaslist_active	res 1	; Holds flags for active gases for the sorted list
+gaslist_active          res 1	; Holds flags for active gases
 desaturation_time_buffer res 2	; buffer for desat time
 
 ;=============================================================================
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Thu Apr 21 20:09:09 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Fri Apr 22 00:13:39 2011 +0200
@@ -333,27 +333,29 @@
 	btfss	dekostop_active
 	bra		reset_decompression_gases	; While in NDL, do not set deompression gas
 
-divemode_check_decogases:					; CALLed from Simulator
 ; Copy all gases to char_I_deco_N2_ratio and char_I_deco_He_ratio
+divemode_check_decogases:					; CALLed from Simulator, too
+
+	clrf    EEADRH,                     ; Make sure to select eeprom bank 0
 	read_int_eeprom		d'5'			; Read He ratio
-	movff	EEDATA,char_I_deco_He_ratio+4	; And copy into hold register
+	movff	EEDATA,char_I_deco_He_ratio+0	; And copy into hold register
 	read_int_eeprom		d'4'			; Read O2 ratio
-	movff	char_I_deco_He_ratio+4, wait_temp			; copy into bank1 register
+	movff	char_I_deco_He_ratio+0, 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+4; = N2!
+	movff	EEDATA, char_I_deco_N2_ratio+0; = N2!
 
 	read_int_eeprom		d'9'			; Read He ratio
-	movff	EEDATA,char_I_deco_He_ratio+3	; And copy into hold register
+	movff	EEDATA,char_I_deco_He_ratio+1	; And copy into hold register
 	read_int_eeprom		d'8'			; Read O2 ratio
-	movff	char_I_deco_He_ratio+3, wait_temp			; copy into bank1 register
+	movff	char_I_deco_He_ratio+1, 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+3; = N2!
+	movff	EEDATA, char_I_deco_N2_ratio+1; = N2!
 
 	read_int_eeprom		d'13'			; Read He ratio
 	movff	EEDATA,char_I_deco_He_ratio+2	; And copy into hold register
@@ -366,49 +368,53 @@
 	movff	EEDATA, char_I_deco_N2_ratio+2; = N2!
 
 	read_int_eeprom		d'17'			; Read He ratio
-	movff	EEDATA,char_I_deco_He_ratio+1	; And copy into hold register
+	movff	EEDATA,char_I_deco_He_ratio+3	; And copy into hold register
 	read_int_eeprom		d'16'			; Read O2 ratio
-	movff	char_I_deco_He_ratio+1, wait_temp			; copy into bank1 register
+	movff	char_I_deco_He_ratio+3, 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+1; = N2!
+	movff	EEDATA, char_I_deco_N2_ratio+3; = N2!
 
 	read_int_eeprom		d'21'			; Read He ratio
-	movff	EEDATA,char_I_deco_He_ratio+0; And copy into hold register
+	movff	EEDATA,char_I_deco_He_ratio+4; And copy into hold register
 	read_int_eeprom		d'20'			; Read O2 ratio
-	movff	char_I_deco_He_ratio+0, wait_temp			; copy into bank1 register
+	movff	char_I_deco_He_ratio+4, 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+0; = N2!
+	movff	EEDATA, char_I_deco_N2_ratio+4; = N2!
+
+; Copy depth of enabled gas into char_I_deco_gas_change
+; Note gaslist_active is inited in diveloop_boot, and edited by
+; the de-activation menu. So don't reread it from eeprom here.
 
 	read_int_eeprom		d'28'				; read gas_change_depth Gas1
-	btfss	sorted_gaslist_active,0			; Apply depth?
+	btfss	gaslist_active,0                ; Apply depth?
 	clrf	EEDATA							; No, clear!
-	movff	EEDATA,char_I_deco_gas_change+4	; Yes!
+	movff	EEDATA,char_I_deco_gas_change+0	; Yes!
 
 	read_int_eeprom		d'29'				; read gas_change_depth Gas2
-	btfss	sorted_gaslist_active,1			; Apply depth?
+	btfss	gaslist_active,1    			; Apply depth?
 	clrf	EEDATA							; No, clear!
-	movff	EEDATA,char_I_deco_gas_change+3	; Yes!
+	movff	EEDATA,char_I_deco_gas_change+1	; Yes!
 
 	read_int_eeprom		d'30'				; read gas_change_depth Gas3
-	btfss	sorted_gaslist_active,2			; Apply depth?
+	btfss	gaslist_active,2    			; Apply depth?
 	clrf	EEDATA							; No, clear!
 	movff	EEDATA,char_I_deco_gas_change+2	; Yes!
 
 	read_int_eeprom		d'31'				; read gas_change_depth Gas4
-	btfss	sorted_gaslist_active,3			; Apply depth?
+	btfss	gaslist_active,3    			; Apply depth?
 	clrf	EEDATA							; No, clear!
-	movff	EEDATA,char_I_deco_gas_change+1	; Yes!
+	movff	EEDATA,char_I_deco_gas_change+3	; Yes!
 
 	read_int_eeprom		d'32'				; read gas_change_depth Gas5
-	btfss	sorted_gaslist_active,4			; Apply depth?
+	btfss	gaslist_active,4    			; Apply depth?
 	clrf	EEDATA							; No, clear!
-	movff	EEDATA,char_I_deco_gas_change+0	; Yes!
+	movff	EEDATA,char_I_deco_gas_change+4	; Yes!
 
 ; Debugger
 ;	call	enable_rs232	
@@ -447,12 +453,12 @@
 
 reset_decompression_gases:				; reset the deco gas while in NDL
 	ostc_debug	'F'		; Sends debug-information to screen if debugmode active
-  	clrf	lo
-	movff	lo,char_I_deco_gas_change+4
-	movff	lo,char_I_deco_gas_change+3
-	movff	lo,char_I_deco_gas_change+2
-	movff	lo,char_I_deco_gas_change+1
- 	movff	lo,char_I_deco_gas_change+0 ; clear 
+  	lfsr    FSR2,char_I_deco_gas_change
+  	clrf    POSTINC2                    ; Clear Gas1
+  	clrf    POSTINC2
+  	clrf    POSTINC2
+  	clrf    POSTINC2
+  	clrf    POSTINC2                    ; Clear Gas5
 	return
 
 calc_deko_divemode2:
@@ -933,7 +939,11 @@
 check_ppO2_3:
 	return		; done
 
-
+;=============================================================================
+; Compare all enabled gas in list, to see if a better one is available.
+;
+; Output: better_gas_available
+;
 check_gas_change:					; Checks if a better gas should be selected (by user)
 	bcf		better_gas_available	;=1: A better gas is available and a gas change is advised in divemode
 	
@@ -945,7 +955,7 @@
 	call	div16x16				; compute depth in full m -> result in xC+0
 
 check_gas_change1:					; check gas1 
-	btfss	sorted_gaslist_active,0				; check active flag
+	btfss	gaslist_active,0		; check active flag
 	bra		check_gas_change2		; skip inactive gases!
 	movlw	d'1'
 	cpfseq	active_gas				; is this gas currently selected?
@@ -965,7 +975,7 @@
 	bsf		better_gas_available	;=1: A better gas is available and a gas change is advised in divemode
 
 check_gas_change2:					; check gas2
-	btfss	sorted_gaslist_active,1 ; check active flag
+	btfss	gaslist_active,1        ; check active flag
 	bra		check_gas_change3		; skip inactive gases!
 	movlw	d'2'
 	cpfseq	active_gas				; is this gas currently selected?
@@ -985,7 +995,7 @@
 	bsf		better_gas_available	;=1: A better gas is available and a gas change is advised in divemode
 
 check_gas_change3:					; check gas3
-	btfss	sorted_gaslist_active,2 ; check active flag
+	btfss	gaslist_active,2        ; check active flag
 	bra		check_gas_change4		; skip inactive gases!
 	movlw	d'3'
 	cpfseq	active_gas				; is this gas currently selected?
@@ -1005,7 +1015,7 @@
 	bsf		better_gas_available	;=1: A better gas is available and a gas change is advised in divemode
 
 check_gas_change4:					; check gas4
-	btfss	sorted_gaslist_active,3 ; check active flag
+	btfss	gaslist_active,3        ; check active flag
 	bra		check_gas_change5		; skip inactive gases!
 	movlw	d'4'
 	cpfseq	active_gas				; is this gas currently selected?
@@ -1025,7 +1035,7 @@
 	bsf		better_gas_available	;=1: A better gas is available and a gas change is advised in divemode
 
 check_gas_change5:					; check gas5
-	btfss	sorted_gaslist_active,4 ; check active flag
+	btfss	gaslist_active,4        ; check active flag
 	bra		check_gas_change6		; skip inactive gases!
 	movlw	d'5'
 	cpfseq	active_gas				; is this gas currently selected?
@@ -1048,6 +1058,8 @@
 	call	PLED_active_gas_divemode; Display gas, if required (and with "*" if irequired...)
 	return
 
+;=============================================================================
+
 calculate_noflytime:
 	; calculate nofly time
 	movff	int_O_desaturation_time+0,xA+0
@@ -1641,6 +1653,9 @@
 	bcf		reset_average_depth			; Clear flag
 	return
 
+;=============================================================================
+; Setup everything to enter divemode.
+;
 diveloop_boot:	
 	ostc_debug	'Q'		; Sends debug-information to screen if debugmode active
 	clrf	max_pressure+0				; clear some variables
@@ -1649,6 +1664,7 @@
 	clrf	avr_rel_pressure+0
 	clrf	avr_rel_pressure+1
 
+	clrf    EEADRH                      ; Make sure to select eeprom bank 0
 	call	PLED_brightness_low
 	read_int_eeprom	d'90'				; Brightness offset? (Dim>0, Normal = 0)
 	movlw	d'0'
@@ -1768,7 +1784,7 @@
 	subfwb	EEDATA,F					; minus O2
 	movff	EEDATA, char_I_N2_ratio		; = N2!
 
-; Configure sorted_gaslist_active flag register
+; Configure gaslist_active flag register
 	read_int_eeprom	d'27'
-	movff	EEDATA, sorted_gaslist_active
+	movff	EEDATA, gaslist_active
 	return
--- a/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Thu Apr 21 20:09:09 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Fri Apr 22 00:13:39 2011 +0200
@@ -266,35 +266,35 @@
 	bra		timeout_divemenu2			; quit underwater menu!
 
 divemenu_de_activate2_g1:
-	btg		sorted_gaslist_active,0		; Toggle flag
+	btg		gaslist_active,0    		; Toggle flag
 	movlw	d'2'
 	movwf	menupos						; reset cursor
 	call	PLED_de_activelist			; show (de)active gaslist
 	return
 
 divemenu_de_activate2_g2:
-	btg		sorted_gaslist_active,1		; Toggle flag
+	btg		gaslist_active,1    		; Toggle flag
 	movlw	d'3'
 	movwf	menupos						; reset cursor
 	call	PLED_de_activelist			; show (de)active gaslist
 	return
 
 divemenu_de_activate2_g3:
-	btg		sorted_gaslist_active,2		; Toggle flag
+	btg		gaslist_active,2    		; Toggle flag
 	movlw	d'4'
 	movwf	menupos						; reset cursor
 	call	PLED_de_activelist			; show (de)active gaslist
 	return
 
 divemenu_de_activate2_g4:
-	btg		sorted_gaslist_active,3		; Toggle flag
+	btg		gaslist_active,3    		; Toggle flag
 	movlw	d'5'
 	movwf	menupos						; reset cursor
 	call	PLED_de_activelist			; show (de)active gaslist
 	return
 
 divemenu_de_activate2_g5:
-	btg		sorted_gaslist_active,4		; Toggle flag
+	btg		gaslist_active,4    		; Toggle flag
 	movlw	d'6'
 	movwf	menupos						; reset cursor
 	call	PLED_de_activelist			; show (de)active gaslist
--- a/code_part1/OSTC_code_asm_part1/menu_gassetup.asm	Thu Apr 21 20:09:09 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_gassetup.asm	Fri Apr 22 00:13:39 2011 +0200
@@ -1035,7 +1035,7 @@
     bsf     EEDATA,4
     
     ; Copy result to register:
-    movff   EEDATA,sorted_gaslist_active
+    movff   EEDATA,gaslist_active
     
     ; And write to EEPROM too, to survive next reboot:
 	write_int_eeprom    d'27'
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Thu Apr 21 20:09:09 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Fri Apr 22 00:13:39 2011 +0200
@@ -2534,10 +2534,10 @@
 ;-----------------------------------------------------------------------------
 ; Toggle gas activity flag during dive.
 ; 
-; Input: sorted_gaslist_active
+; Input: gaslist_active
 ;        Gaslist from eeprom[2...]
 ;
-; Output: sorted_gaslist_active
+; Output: gaslist_active
 ;
 ; Note: Gas with a zero depth cannot be used in deco simulation, hence
 ;       should not be displayed as selected here...
@@ -2589,7 +2589,7 @@
 	bz      PLED_de_activelist_grey ; should be displayed inactive.
 	
 ; Check if gas needs to be greyed-out (inactive)	
-	movff	sorted_gaslist_active,EEDATA	; Get flag register
+	movff	gaslist_active,EEDATA	; Get flag register
 	movff	hi,lo			; copy gas number
 PLED_de_activelist_loop1:
 	rrcf	EEDATA			; roll flags into carry
@@ -2652,7 +2652,7 @@
 	call	read_eeprom		; get byte (stored in EEDATA)
 	PLED_color_code		warn_gas_in_gaslist		; Color-code output	(%O2 in "EEDATA")
 ; Check if gas needs to be greyed-out (inactive)
-	movff	sorted_gaslist_active, EEDATA		; Work with sorted list
+	movff	gaslist_active, EEDATA		; Work with sorted list
 ;	read_int_eeprom		d'27'	; read flag register
 	movff	hi,lo			; copy gas number
 PLED_gas_list_loop1:
--- a/code_part1/OSTC_code_asm_part1/simulator.asm	Thu Apr 21 20:09:09 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/simulator.asm	Fri Apr 22 00:13:39 2011 +0200
@@ -243,34 +243,10 @@
     btfsc   FLAG_const_ppO2_mode        ; In CCR mode ?
     bra     simulator_show_decoplan4    ; YES: finished.
 
-    ; Re-read gas change depth, from the unsorted list.
-    movlw   .33                         ; First gas.
-    movwf   EEADR
+    ; Make sure to pass first gas
     clrf    EEADRH
-    call    read_eeprom
+    read_int_eeprom .33                 ; First gas.
     movff   EEDATA,char_I_first_gas
-    
-    movlw   .27                         ; Active flags.
-    movwf   EEADR
-    call    read_eeprom
-    movff   EEDATA,waitms_temp          ; Save activity flags.
-    incf    EEADR,F                     ; 28 == Gas#1's change depth.
-
-    lfsr    FSR2,char_I_deco_gas_change
-    movlw   5
-    movwf   wait_temp
-
-simulator_show_decoplan5_4:
-    call    read_eeprom
-    incf    EEADR,F
-    
-    rrcf    waitms_temp                 ; Roll acticity to cary.
-    btfss   STATUS,C
-    clrf    EEDATA                      ; If not active, set depth=0
-
-    movff   EEDATA,POSTINC2             ; Write that in depth array.
-    decfsz  wait_temp
-    bra     simulator_show_decoplan5_4
 
     ; Compute gas consumption for each tank.
     call    deco_gas_volumes
--- a/code_part1/OSTC_code_c_part2/p2_deco.c	Thu Apr 21 20:09:09 2011 +0200
+++ b/code_part1/OSTC_code_c_part2/p2_deco.c	Fri Apr 22 00:13:39 2011 +0200
@@ -971,8 +971,9 @@
         if( N2 == char_I_deco_N2_ratio[j] 
          && He == char_I_deco_He_ratio[j] 
         )                                 
-        {                                 
-            temp_depth_limit = sim_gas_last_depth = char_I_deco_gas_change[j];
+        {
+            if( char_I_deco_gas_change[j] )
+                temp_depth_limit = sim_gas_last_depth = char_I_deco_gas_change[j];
             sim_gas_last_used  = j+1;
             break;
         }
Binary file code_part1/OSTC_code_c_part2/p2_deco.o has changed