# HG changeset patch
# User heinrichsweikamp
# Date 1413019095 -7200
# Node ID ba084dfa4b3692f9b83973abc2ceb2a14209ad6e
# Parent  afcf56ae09e464b84f921ef01a37b9f27e0444cf
minor

diff -r afcf56ae09e4 -r ba084dfa4b36 code_part1/OSTC_code_asm_part1/divemode.asm
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Fri Oct 10 17:30:32 2014 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Sat Oct 11 11:18:15 2014 +0200
@@ -65,6 +65,8 @@
 	btfss	onesecupdate					; tasks any new second
 	bra		diveloop_loop3
 
+    bcf     onesecupdate					; one seconds update, clear flag here in case it's set again in ISR before all tasks are done.
+
 	btfsc	gauge_mode						; Only in gauge mode
 	bra		diveloop_loop1a					; One Second Tasks in Gauge mode
 	btfsc	FLAG_apnoe_mode					; Only in apnoe mode
@@ -168,8 +170,6 @@
 	btfsc	enter_error_sleep				; Enter Fatal Error Routine?
 	call	fatal_error_sleep				; Yes (In Sleepmode.asm!)
 
-	bcf		onesecupdate					; one seconds update done
-
 diveloop_loop3:
 	btfss	menubit							; Divemode menu active?
 	call	test_switches_divemode			; No, Check switches normal
@@ -1683,6 +1683,13 @@
 	goto	surfloop_no_display_init	; and return to surfaceloop
 
 end_dive_common_sim:
+    tstfsz  surface_interval+0              ; Was interval zero?
+    bra     end_dive_common_sim2            ; No
+    tstfsz  surface_interval+1              ; Was interval zero?
+    bra     end_dive_common_sim2            ; No
+    bra     end_dive_common                 ; Yes, done.
+
+end_dive_common_sim2:
     movf    divemins+0,W
     addwf   surface_interval+0,F
     movf    divemins+1,W