diff code_part1/OSTC_code_asm_part1/simulator.asm @ 225:2dc4a7340510

BUGFIX Gas usage for unsorted gas list. + Fix detection of saturation (6553.5 l). + Better handling of unsorted gas list.
author JeanDo
date Thu, 03 Mar 2011 15:52:16 +0100
parents 49c90c5d9603
children 85ea09d3b9d8
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/simulator.asm	Thu Mar 03 15:16:23 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/simulator.asm	Thu Mar 03 15:52:16 2011 +0100
@@ -240,9 +240,35 @@
     bra     simulator_show_decoplan4
 	bcf		display_see_deco			; clear flag
    
+   ; Re-read gas change depth, from the unsorted list.
+    movlw   .27                         ; Active flags.
+    movwf   EEADR
+    clrf    EEADRH
+    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
     movlb   1
 
+    ; Display results
     call    PLED_clear_divemode_menu    ; Clear right part.
 
 	movlw	d'10'
@@ -266,7 +292,7 @@
     bz      simulator_show_decoplan5_1  ; Skip printing.
 
     movf    lo,W                        ; == 65535 (saturated ?)
-    iorwf   hi,W
+    andwf   hi,W
     incf    WREG
     bnz     simulator_show_decoplan5_2
     call    PLED_warnings_color