changeset 124:4f9f477bb452

Rewrite display of decoplan: * Common stuff - fix clearing bottom of list, for fleecker-free updates. - fix "Wait..." topline_box while computing deco in planning - fix 'No Deco" std color and mark last page. - Allow stops up to 240' * ZHL-16c model: - 6 lines max (sim or dive) - Print exceed stops as "add: ddd'" * GF model - 6 lines in divemode, 8 in planning. - any suitable number of pages. - "more..." when not the last page displayed. - fix displaying special depth for last stop (CF#29). - fix 0-time stops: just skip display. - fix end of list when reached the deepest stop. - fix no need to buffer decoplan twice.
author JeanDo
date Sat, 01 Jan 2011 01:57:50 +0100
parents 6a94f96e9cea
children 2907b42c195b
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/pled_outputs.asm code_part1/OSTC_code_asm_part1/simulator.asm
diffstat 5 files changed, 357 insertions(+), 319 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Thu Dec 30 23:45:20 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Sat Jan 01 01:57:50 2011 +0100
@@ -89,11 +89,6 @@
 	win_invert
 	ENDC
 
-; the following is used by the C-code up to 0x0E0!!
-	CBLOCK	0x0E0				;Bank 0
-	gf_decolist_copy:.32
-	ENDC
-
 	CBLOCK	0x100				;Bank 1
 	wreg_temp					;variables used for context saving during ISR 
 	status_temp					
@@ -267,8 +262,6 @@
 	
 	nofly_time:2				; No Fly time in Minutes (Calculated after Dive)
 	
-	deco_status					; =0 if decompression calculation done
-
 	cf_checker_counter			; counts custom functions to check for warning symbol
 	
 	char_I_O2_ratio				; 02 ratio
@@ -295,12 +288,8 @@
 	
 	switch_timeout				; used for hold-down count function
 	
-	temp5						; used in PLED_MultiGF,...
-	temp6						; used in PLED_MultiGF,...
-	temp7						; used in PLED_MultiGF,...
-	temp8						; used in PLED_MultiGF,...
-	temp9						; used in PLED_MultiGF,...
-	temp10						; used in PLED_MultiGF,...
+	decoplan_page				; used in PLED_MultiGF,...
+	temp10						; used in customview
 
 	fatal_error_code			; holds error code value 
 
@@ -334,7 +323,7 @@
  char_O_actual_pointer;					// 0x24F
 	ENDC
 	CBLOCK	0x250				;Bank 2
- char_IO_deco_table:.32;				// 0x250
+ char_O_deco_table:.32;				// 0x250
 	ENDC
 	CBLOCK	0x270				;Bank 2
  char_I_table_deco_done:.32;			// 0x270
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Thu Dec 30 23:45:20 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Sat Jan 01 01:57:50 2011 +0100
@@ -433,11 +433,9 @@
 	movlb	b'00000001'						; rambank 1 selected
 	ostc_debug	'C'		; Sends debug-information to screen if debugmode active
 
-	movff	char_O_deco_status,deco_status		; 
-	tstfsz	deco_status							; deco_status=0 if decompression calculation done
-	return										; calculation not yet finished!
-
-	rcall	divemode_copy_decolist				;copy gf_decolist (0x250:.32) to gf_decolist_copy (0x0E0:.32)
+	movff	char_O_deco_status,WREG
+	tstfsz	WREG                        ; deco_status=0 if decompression calculation done
+	return                              ; calculation not yet finished!
 
 	movff	char_O_array_decodepth+0,wait_temp	; copy ceiling to temp register
 	tstfsz	wait_temp							; Ceiling<0m?
@@ -453,17 +451,7 @@
 	call	PLED_display_ndl				; display no deco limit
 	return
 
-divemode_copy_decolist:
-	;copy gf_decolist (0x250:.32) to gf_decolist_copy (0x0E0:.32)
-	lfsr	FSR0,0x250			; Source
-	lfsr	FSR1,0x0E0			; Target
-	movlw	d'24'				; Copy 24 stops
-	movwf	wait_temp			; Counter
-copy_gf_deco_list:
-	movff	POSTINC0,POSTINC1	; Copy Source to Target
-	decfsz	wait_temp,F			; All done?
-	bra		copy_gf_deco_list	; No, continue!
-	return
+;-----------------------------------------------------------------------------
 
 divemode_prepare_flags_for_deco:	
 	movff	amb_pressure+0,int_I_pres_respiration+0		; lo  and copy result to deco routine
--- a/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Thu Dec 30 23:45:20 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Sat Jan 01 01:57:50 2011 +0100
@@ -341,14 +341,14 @@
 	bsf		multi_gf_display			; Yes, display the multi-gf table screen
 	bcf		last_ceiling_gf_shown		; Clear flag
 
-	call	PLED_decoplan_gf_page1			; Display the new screen
+    clrf    decoplan_page               ; Starts on page 0
+	call	PLED_decoplan_gf			; Display the new screen
 	return
 	
 divemenu_see_decoplan1:	
-
-	movff	char_O_deco_status,deco_status		; 
-	tstfsz	deco_status							; deco_status=0 if decompression calculation done
-	return										; calculation not yet finished!
+    movff	char_O_deco_status,WREG
+    tstfsz	WREG                        ; deco_status=0 if decompression calculation done
+    return                              ; calculation not yet finished!
 	
 	call	PLED_decoplan				; display the Decoplan
 	return
@@ -362,7 +362,7 @@
 	bra		timeout_divemenu2			; quit menu!
 
 divemenu_see_decoplan2_nextgf:
-	incf	temp8,F
+	incf	decoplan_page,F
 	btfsc	last_ceiling_gf_shown		; last ceiling shown?
 	bra		divemenu_see_decoplan2_0	; All done, clear and return
 
@@ -588,7 +588,6 @@
 	btfss	menubit					; is the Dive mode menu displayed?
 	return							; No
 
-
 	btfsc	display_set_simulator	; Is the Simulator Mask active?
 	bra		timeout_divemenu6		; Yes, update Simulator mask
 	
@@ -598,8 +597,8 @@
 	btfsc	multi_gf_display		; display the multi-gf table screen?
 	bra		timeout_divemenu3		; Yes...
 
-	movff	char_O_deco_status,deco_status		; 
-	tstfsz	deco_status				; deco_status=0 if decompression calculation done
+	movff	char_O_deco_status,WREG
+	tstfsz	WREG                        ; deco_status=0 if decompression calculation done
 	bra		timeout_divemenu1		; No, skip updating the decoplan
 	
 	call	PLED_decoplan			; update the Decoplan
@@ -614,7 +613,7 @@
 ;	bra		timeout_divemenu2a		; No, normal OLED rebuild
 
 ; Restore some outputs
-	clrf	temp8					; Page 0-1 of deco list
+	clrf	decoplan_page           ; Page 0-1 of deco list
 	call	PLED_clear_divemode_menu; Clear dive mode menu
 
 	btfsc	FLAG_apnoe_mode				; Ignore in Apnoe mode
@@ -646,11 +645,11 @@
 	return
 	
 timeout_divemenu3:
-	movff	char_O_deco_status,deco_status	; 
-	tstfsz	deco_status						; deco_status=0 if decompression calculation done
+	movff	char_O_deco_status,WREG
+	tstfsz	WREG                        ; deco_status=0 if decompression calculation done
 	bra		timeout_divemenu1				; No, skip updating the decoplan
 timeout_divemenu3x:
-	call	PLED_decoplan_gf_page_current	; Re-Draw Current page of GF Decoplan
+	call	PLED_decoplan_gf            ; Re-Draw Current page of GF Decoplan
 	bra		timeout_divemenu1			; Check timeout
 	
 timeout_divemenu6:
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Thu Dec 30 23:45:20 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Sat Jan 01 01:57:50 2011 +0100
@@ -19,7 +19,11 @@
 ; routines for display outputs
 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
 ; written: 15/01/05
-; last updated: 06/06/08
+;
+; History:
+; 2008-06-06 [MH] last updated
+; 2010-12-31 [jDG] Multi-page display for GF decoplan
+;
 ; known bugs:
 ; ToDo:	More comments
 
@@ -431,12 +435,12 @@
 	return
 
 PLED_display_deko_mask:
-	rcall	PLED_clear_decoarea	
-; total deco time word
-	call		PLED_divemask_color	; Set Color for Divemode mask
-	DISPLAYTEXT	d'85'			; TTS
-	call	PLED_standard_color
-	return
+        rcall	PLED_clear_decoarea	
+        ; total deco time word
+        call		PLED_divemask_color	; Set Color for Divemode mask
+        DISPLAYTEXT	d'85'			; TTS
+        call	PLED_standard_color
+        return
 
 PLED_display_deko:
 	btfsc	menubit					; Divemode menu active?
@@ -1166,11 +1170,11 @@
 	movwf	wait_temp			; here: stores eeprom address for gas list
 	movlw	d'0'
 	movwf	waitms_temp			; here: stores row for gas list
-	clrf 	temp6				; here: SP counter
+	clrf 	decoplan_index		; here: SP counter
 
 PLED_pre_dive_screen3_loop:
 	incf	wait_temp,F			; EEPROM address
-	incf	temp6,F			; Increase SP
+	incf	decoplan_index,F	; Increase SP
 
 	movlw	d'25'
 	addwf	waitms_temp,F		; Increase row
@@ -1178,7 +1182,7 @@
 	movff	waitms_temp,win_top ; Set Row
 	
 	STRCPY  "SP"
-	movff	temp6,lo		; copy gas number
+	movff	decoplan_index,lo   ; copy gas number
 	output_8				; display gas number
 	STRCAT  ": "
 	movff	wait_temp, EEADR; SP #hi position
@@ -1189,7 +1193,7 @@
 	call	word_processor	
 
 	movlw	d'3'		; list all three SP
-	cpfseq	temp6		; All gases shown?
+	cpfseq	decoplan_index      ; All gases shown?
 	bra		PLED_pre_dive_screen3_loop	;no
 
 	read_int_eeprom 	d'33'			; Read byte (stored in EEDATA)
@@ -2112,236 +2116,301 @@
 	return
 
 PLED_divemode_simulator_mask:
-	DISPLAYTEXT	.254			; Close
-	DISPLAYTEXT	.250			; + 1m
-	DISPLAYTEXT	.251			; - 1m
-	DISPLAYTEXT	.252			; +10m
-	DISPLAYTEXT	.253			; -10m
-	return
+	    call    PLED_standard_color
+        DISPLAYTEXT	.254			; Close
+        DISPLAYTEXT	.250			; + 1m
+        DISPLAYTEXT	.251			; - 1m
+        DISPLAYTEXT	.252			; +10m
+        DISPLAYTEXT	.253			; -10m
+        return
 
 ;-----------------------------------------------------------------------------
-; Draw the bar graph used for deco stops (decoplan in simulator or dive).
-; Inputs: lo = minutes. range 1..many.
-PLED_decoplan_bargraph:
-    ; Common bargraph setup:
-	movf	hi,W                        ; hi+1 --> top (bank safe !)
-	incf    WREG
-	movff   WREG,win_top
-	movlw	d'18'+1                     ; 19 --> height (bank safe !)
-	movff   WREG,win_height
-	movlw	.122
-	movff	WREG,win_leftx2    			; column left (0-159)
-    
-    ; Draw used area (lo = minutes):
-	call    PLED_standard_color
-	movlw	d'16'                       ; Limit length (16min)
-	cpfslt	lo
-	movwf	lo					
-	movff	lo,win_width			    ; Bar width
-	tstfsz  lo                          ; Skip 0-size bar...
-	call	PLED_box
-
-    ; Clear unused area:
-	movlw	.0
-    movff   WREG,win_color1
-    movff   WREG,win_color2
-    movlw   .122                        ; (width+left-1)+1
-    addwf   lo,W
-    movff   WREG,win_leftx2             ; --> left
-    movf    lo,W
-    sublw   .16                         ; 16-left --> width
-    movff   WREG,win_width
-    tstfsz  WREG                        ; Skip 0-size bar.
-	goto	PLED_box
+; Draw a stop of the deco plan (simulator or dive).
+; Inputs: lo      = depth. Range 3m...93m
+;         hi      = minutes. range 1'..240'.
+;         win_top = line to draw on screen.
+; Trashed: hi, lo, win_height, win_leftx2, win_width, win_color*,
+;          WREG, PROD, TBLPTR TABLAT.
+
+PLED_decoplan_show_stop:
+        ;---- Print depth ----------------------------------------------------
+        WIN_LEFT .100
+	    call    PLED_standard_color
+	    lfsr	FSR2,letter
+	    bsf     leftbind
+	    output_8					    ; outputs into Postinc2!
+        STRCAT_PRINT "m "
+
+        ;---- Print duration -------------------------------------------------
+	    WIN_LEFT	.140
+	    lfsr	FSR2,letter
+	    
+	    movf    lo,W                    ; Swap hi & lo
+	    movff   hi,lo
+	    movwf   hi
+
+	    output_8					    ; Allow up to 240'
+        STRCAT_PRINT "'  "              ; 1 to 3 chars for depth.
+
+	    movf    lo,W                    ; Swap back hi & lo
+	    movff   hi,lo
+	    movwf   hi
+
+        ;---------------------------------------------------------------------
+        ; Draw the bar graph used for deco stops (decoplan in simulator or dive).
+        movff   win_top,WREG            ; Increment win_top (BANK SAFE)
+        incf    WREG
+        movff   WREG,win_top
+        movlw	d'18'+1                 ; 19 --> height (bank safe !)
+        movff   WREG,win_height
+        movlw	.122
+        movff	WREG,win_leftx2    		; column left (0-159)
+        
+        ; Draw used area (lo = minutes):
+        call    PLED_standard_color
+        movlw	d'16'                   ; Limit length (16min)
+        cpfslt	hi
+        movwf	hi
+        movff	hi,win_width			; Bar width
+        tstfsz  hi                      ; Skip 0-size bar...
+        call	PLED_box
+
+        ; Clear unused area:
+        movlw	.0
+        movff   WREG,win_color1
+        movff   WREG,win_color2
+        movlw   .122                    ; (width+left-1)+1
+        addwf   hi,W
+        movff   WREG,win_leftx2         ; --> left
+        movf    hi,W
+        sublw   .16                     ; 16-left --> width
+        movff   WREG,win_width
+        tstfsz  WREG                    ; Skip 0-size bar.
+        call    PLED_box
+        
+        ; Restore win_top
+        movff   win_top,WREG            ; decf win_top (BANK SAFE)
+        decf    WREG
+        movff   WREG,win_top
+        return
 
 ;-----------------------------------------------------------------------------
-PLED_decoplan_delete_gf:		        ; Delete unused rows (GF model)
-PLED_decoplan_delete:			        ; Delete unused rows (OC model)
-	movlw	.171
-PLED_decoplan_delete_common:
-	movff	hi,win_top                  ; row top (0-239)
-	subwf   hi,W
-	negf    WREG
-	movff   WREG,win_height
-	movlw	.100
-	movff	WREG,win_leftx2             ; column left (0-159)
-	movlw	.60	
-	movff	WREG,win_width              ; area width (right-left+1, 0-159)
-    
-    clrf    WREG                        ; BG color is black.
-    movff   WREG,win_color1
-    movff   WREG,win_color2
-
-	bsf		last_ceiling_gf_shown		; Set flag
-	goto	PLED_box
+; Clear unused area belw last stop
+; Inputs: win_top : last used area...
+PLED_decoplan_clear_bottom:
+        movff   win_top,WREG            ; Get back from bank0
+        btfsc   divemode                ; In dive mode ?
+        sublw   .170                    ; Yes: bottom row in divemode
+        btfss   divemode                ; In dive mode ?
+        sublw   .240                    ; No: bottom row in planning
+        movff   WREG,win_height
+
+        WIN_LEFT .82                    ; Full divemenu width
+        movlw   .160-.82+1
+        movff   WREG,win_width
+
+        clrf    WREG                    ; Fill with black
+        movff   WREG,win_color1
+        movff   WREG,win_color2
+        
+        goto	PLED_box
 
 ;-----------------------------------------------------------------------------
-PLED_decoplan_gf_page_current:
-	movlw	d'0'
-	cpfseq	temp8
-	bra		PLED_decoplan_gf_page2				; =1: Dispplay Page 2
-	bra		PLED_decoplan_gf_page1				; =0, Display Page 1
-
-PLED_decoplan_gf_page1:
-	ostc_debug	'n'		; Sends debug-information to screen if debugmode active
-
-	movff	char_O_array_decodepth+0,lo		; Get Depth
-	tstfsz	lo
-	bra		PLED_decoplan_gf_page1x
-	; No Deco, show "no Deco"
-	DISPLAYTEXT	d'239'						;"No Deco"
-	return
-
-PLED_decoplan_gf_page2:
-	; temp7 holds last displayed depth
-	; temp5 list entry
-	movff	temp5,temp9		; save
-	movff	temp7,temp10	; save
-	movlw	.231
-	movwf	temp6			; row
-PLED_decoplan_gf_page2y:
-	movlw	d'3'
-	addwf	temp7,F			; Add 3m for next stop
-	movlw	d'25'
-	addwf	temp6,F
-	incf	temp5,F
-	call	PLED_decoplan_show_stop_gf
-	movlw	d'15'			; the next 8 Stops...
-	cpfseq	temp5
-	bra		PLED_decoplan_gf_page2y
-	movff	temp9,temp5			; restore
-	movff	temp10,temp7		; restore
-	bsf		last_ceiling_gf_shown		; Set flag
-	return
-
-PLED_decoplan_gf_page1x:
-	clrf	temp8				; Page 0-3 of deco list
-	GETCUSTOM8	d'29'			; Last Deco in m
-	movwf	temp7				; Start with last stop
-	clrf	temp5
-	movlw	.231
-	movwf	temp6			; row
-
-	; Show last stop manually
-	movlw	d'25'
-	addwf	temp6,F
-	incf	temp5,F
-	call	PLED_decoplan_show_stop_gf
-	GETCUSTOM8	d'29'			; Last Deco in m
-	movwf	temp7				; Last deco
-	movlw	d'4'
-	cpfslt	temp7				; >=3m?
-	bra		PLED_decoplan_gf_page1x_next_6m
-
-	movlw	d'3'
-	movwf	temp7
-	bra		PLED_decoplan_gf_page1y
-
-PLED_decoplan_gf_page1x_next_6m:
-	movlw	d'6'
-	movwf	temp7
-	incf	temp5,F
-PLED_decoplan_gf_page1y:
-	movlw	d'3'
-	addwf	temp7,F			; Add 3m for next stop
-	movlw	d'25'
-	addwf	temp6,F
-	incf	temp5,F
-	call	PLED_decoplan_show_stop_gf
-	movlw	d'7'			; the next 7 Stops...
-	cpfseq	temp5
-	bra		PLED_decoplan_gf_page1y
-	return
-
-
-PLED_decoplan_show_stop_gf:
-	bsf		leftbind
-	WIN_LEFT	.100
-	call    PLED_standard_color
-	movff	temp6,win_top
-	movff	temp6,hi						; copy for PLED_decoplan_bargraph
-
-	movff	char_O_array_decodepth+0,WREG	; Ceiling
-	cpfslt	temp7							; Ceiling already displayed?
-	goto	PLED_decoplan_delete_gf			; Yes, quit display	and RETURN	
-	movff	temp7,lo						; Decodepth
-
-	lfsr	FSR2,letter		
-	output_99x								; outputs into Postinc2!
-	STRCAT_PRINT "m"
-
-	PUTC	' '
-	WIN_LEFT	.140
-	movff	temp6,win_top
-	lfsr	FSR1,0x0E0+1					; Gf_decolist_copy
-	movf	temp5,W							; number of entry
-	movff	PLUSW1,lo						; Stop length
-	incf	lo,F							; add one dummy minute
-	lfsr	FSR2,letter	
-	output_99x								; outputs into Postinc2!
-	STRCAT_PRINT "'"
-
-	rcall	PLED_decoplan_bargraph			; draws a box representing the decotime (stored in lo...) for this depth
-	return
-
-
-PLED_decoplan:				; display the Decoplan
-	ostc_debug	'n'		; Sends debug-information to screen if debugmode active
-
-	movff	char_O_array_decodepth+0,lo		; Get Depth
-	tstfsz	lo
-	bra		PLED_decoplan1
-	; No Deco, show "no Deco"
-	DISPLAYTEXT	d'239'						;"No Deco"
-	return
+; Display the decoplan (simulator or divemode) for GF model
+; Inputs: char_O_deco_table (array of stop times, in minutes)
+;         decoplan_page = page number. Displays 5 stop by page.
+;
+decoplan_index  equ apnoe_mins          ; within each page
+decoplan_gindex equ apnoe_secs          ; global index
+decoplan_last   equ apnoe_max_pressure  ; Depth of last stop (CF#29)
+decoplan_max    equ apnoe_max_pressure+1; Number of lines per page. 7 in planning, 5 in diving.
+
+PLED_decoplan_gf:
+        ostc_debug	'n'		; Sends debug-information to screen if debugmode active
+
+        WIN_INVERT 0
+
+        ;---- Is there deco stops ? ------------------------------------------
+    	lfsr	FSR1,char_O_deco_table
+    	movlw   .1
+    	movf    PLUSW1,W                ; char_O_deco_table[1] --> WREG
+        bnz		PLED_decoplan_gf_1
+        
+        ;---- No Deco --------------------------------------------------------
+        call    PLED_standard_color
+        DISPLAYTEXT	d'239'              ;"No Deco"
+        bsf     last_ceiling_gf_shown
+        return
+
+PLED_decoplan_gf_1:
+    	GETCUSTOM8	d'29'			    ; Last decostop depth, in m
+        movwf	decoplan_last		    ; --> decoplan_last
+
+        movlw   .8                      ; 8 lines/page in decoplan
+        btfsc   divemode
+        movlw   .6                      ; 6 lines/page in divemode.
+        movwf   decoplan_max
+
+        movlw   .1
+        movwf   decoplan_index          ; Start with index = 1
+        clrf	WREG
+        movff	WREG,win_top            ; and row = 0
+
+        ; Read stop parameters, indexed by decoplan_index and decoplan_page
+        movf    decoplan_page,W         ; decoplan_gindex = 6*decoplan_page + decoplan_index
+        mulwf   decoplan_max
+        movf    decoplan_index,W
+        addwf   PRODL,W
+        movwf   decoplan_gindex         ; --> decoplan_gindex
+        
+        bcf     last_ceiling_gf_shown   ; Not finished yet...
+
+PLED_decoplan_gf_2:
+        btfsc   decoplan_gindex,5       ; Reached table length (32) ?
+        bra     PLED_decoplan_gf_99     ; YES: finished...
+
+        ; Compute new depth
+        movf    decoplan_gindex,W       ; depth = 3 * (global index)
+        mullw   .3                      ; --> PROD
+        movf    decoplan_last,W         ; depth < decoplan_last (CF#29) ?
+        cpfslt  PRODL
+        movf    PRODL,W                 ; NO: take depth, else keep decoplan_last.
+        movwf   lo                      ; --> lo
+
+        ; Read deepest depth from other bank.
+        movff   char_O_array_decodepth,WREG
+        xorwf   lo,W                    ; This is last stop ?
+        btfsc   STATUS,Z
+        bsf     last_ceiling_gf_shown   ; YES: mark for latter...
+
+        ; Read stop duration
+        movf    decoplan_gindex,W       ; index
+    	movff	PLUSW1,hi               ; char_O_deco_table[index] --> hi
+    	movf    hi,W                    ; time = zero ?
+    	bz      PLED_decoplan_gf_4      ; Do not display it: continue.
+
+        ; Display the stop line
+    	call	PLED_decoplan_show_stop
+
+        ; Next
+        movff   win_top,WREG            ; row: += 24
+	    addlw	.24
+        movff   WREG,win_top
+	    incf	decoplan_index,F        ; local index += 1
+PLED_decoplan_gf_4:
+	    incf	decoplan_gindex,F       ; global index += 1
+
+        btfsc   last_ceiling_gf_shown   ; Last one done ?
+        bra     PLED_decoplan_gf_99     ; YES: finished...
+
+        ; Max number of lines/page reached ?
+    	incf    decoplan_max,W          ; index+1 == max+1 ?
+    	cpfseq	decoplan_index
+    	bra		PLED_decoplan_gf_2      ; NO: loop
+
+    	; Check if next stop if end-of-list ?
+    	movlw   .3                      ; Next stop is lo + 3m
+    	addwf   lo,W
+    	xorwf   decoplan_last,W         ; == last stop ?
+    	bz      PLED_decoplan_gf_99     ; End of list...
+
+        ; Display the message "more..."
+        rcall   PLED_decoplan_clear_bottom  ; Clear from next line
+
+    	WIN_LEFT .130 - 7*3
+    	call    PLED_standard_color
+    	STRCPY_PRINT "more..."
+        bcf		last_ceiling_gf_shown	; More page to display...
+    	return
+
+PLED_decoplan_gf_99:
+        bsf		last_ceiling_gf_shown   ; Nothing more in table to display.
+        rcall   PLED_decoplan_clear_bottom  ; Clear from next line
+        return
+
+;-----------------------------------------------------------------------------
+; Display the decoplan (simulator or divemode) for ZHL-16c model
+PLED_decoplan:
+        ostc_debug	'n'		; Sends debug-information to screen if debugmode active
+        
+        WIN_INVERT 0
+
+        ;---- Is there deco information --------------------------------------
+    	lfsr	FSR0,char_O_array_decodepth
+	    lfsr	FSR1,char_O_array_decotime
+
+    	movf    INDF0,W
+        bnz		PLED_decoplan1
+        
+        ;---- No Deco --------------------------------------------------------
+        call    PLED_standard_color
+        DISPLAYTEXT	d'239'              ;"No Deco"
+        bsf     last_ceiling_gf_shown
+        return
 
 PLED_decoplan1:
-	setf	temp5
-	movlw	.231
-	movwf	temp6			; row
+    	GETCUSTOM8	d'29'			    ; Last decostop depth, in m
+        movwf	decoplan_last		    ; --> decoplan_last
+
+        movlw   .6                      ; Max 6 lines in all modes.
+        movwf   decoplan_max
+        
+        clrf	decoplan_index          ; Starts with index = 0
+        clrf	WREG
+        movff	WREG,win_top            ; and row = 0
+
 PLED_decoplan2:
-	movlw	d'25'
-	addwf	temp6,F
-	incf	temp5,F
-	call	PLED_decoplan_show_stop
-	movlw	d'5'			; 6 Stops...
-	cpfseq	temp5
-	bra		PLED_decoplan2
-	return
-
-PLED_decoplan_show_stop:
-	bsf		leftbind
-	WIN_LEFT	.100
-	call    PLED_standard_color
-	movff	temp6,win_top
-	movff	temp6,hi						; copy for PLED_decoplan_bargraph
-
-	lfsr	FSR1,char_O_array_decodepth
-	movf	temp5,W							; number of entry
-	movff	PLUSW1,lo
-	movf	lo,w
-	btfsc	STATUS,Z						; =0
-	goto	PLED_decoplan_delete			; Yes, quit display		
-
-	lfsr	FSR2,letter		
-	output_8								; outputs into Postinc2!
-    STRCAT_PRINT "m "
-
-	WIN_LEFT	.140
-	movff	temp6,win_top
-
-	lfsr	FSR1,char_O_array_decotime;+0
-	movf	temp5,W							; number of entry
-	movff	PLUSW1,lo
-
-	lfsr	FSR2,letter	
-	output_99x								; outputs into Postinc2!
-    STRCAT_PRINT "'"
-
-	rcall	PLED_decoplan_bargraph			; draws a box representing the decotime (stored in lo...) for this depth
-	return
-
-
+        ; Read stop parameters, indexed by decoplan_index
+	    movf	decoplan_index,W
+	    movff	PLUSW0,lo               ; array_decodepth[index]
+	    movff	PLUSW1,hi               ; array_decotime[index]
+
+        ; 0 time == end-of-table.
+    	movf	hi,w
+    	bz      PLED_decoplan_0
+
+        call	PLED_decoplan_show_stop
+
+        movff   win_top,WREG            ; row += 24
+	    addlw	.24         
+        movff   WREG,win_top
+	    incf	decoplan_index,F        ; index += 1    
+
+        ; 6 Stops max...
+        movf    decoplan_max,W
+        cpfseq	decoplan_index
+        bra		PLED_decoplan2
+
+        ;---- Additional time in the decoplan ? ------------------------------
+        movf    decoplan_max,W          ; Read array_decotime[6]
+        movf    PLUSW1,W                ; set Z flag
+        movwf   lo                      ; and copy to lo
+        btfsc   STATUS,Z                ; Zero: nothing to add.
+        return
+        
+        WIN_LEFT .100
+        call    PLED_standard_color
+
+        STRCPY  "add:"
+        output_8
+        STRCAT_PRINT "'"
+        return
+
+PLED_decoplan_0:
+        ;---- Plan not finished to compute ? ---------------------------------
+	    decf	decoplan_index,W
+	    movf 	PLUSW0,W                ; array_decodepth[index-1]
+	    subwf   decoplan_last,W         ; == last stop depth ?
+	    bz      PLED_decoplan_99
+        
+        WIN_LEFT .100
+        call    PLED_standard_color
+        STRCPY_PRINT "..."
+
+PLED_decoplan_99:
+        return
+
+;-----------------------------------------------------------------------------
 PLED_gas_list:
 	ostc_debug	'm'		; Sends debug-information to screen if debugmode active
 
@@ -2414,11 +2483,11 @@
 	movwf	wait_temp			; here: stores eeprom address for gas list
 	movlw	d'231'
 	movwf	waitms_temp			; here: stores row for gas list
-	clrf 	temp5				; here: SP counter
+	clrf 	decoplan_index	    ; here: SP counter
 
 PLED_splist_loop:
 	incf	wait_temp,F			; EEPROM address
-	incf	temp5,F			; Increase SP
+	incf	decoplan_index,F	; Increase SP
 
 	movlw	d'25'
 	addwf	waitms_temp,F		; Increase row
@@ -2426,7 +2495,7 @@
 	WIN_LEFT	.100
 	
 	STRCPY  "SP"
-	movff	temp5,lo		; copy gas number
+	movff	decoplan_index,lo	; copy gas number
 	output_8				; display gas number
     PUTC    ':'
 	movff	wait_temp, EEADR; SP #hi position
@@ -2437,7 +2506,7 @@
 	call	word_processor	
 
 	movlw	d'3'		; list all three SP
-	cpfseq	temp5		; All gases shown?
+	cpfseq	decoplan_index          ; All gases shown?
 	bra		PLED_splist_loop	; No
 
 	bcf		leftbind
@@ -2982,11 +3051,11 @@
 	movwf	wait_temp			; here: stores eeprom address for gas list
 	movlw	d'10'
 	movwf	waitms_temp			; here: stores row for gas list
-	clrf 	temp6				; here: SP counter
+	clrf 	decoplan_index		; here: SP counter
 
 PLED_simdata_screen3_loop:
 	incf	wait_temp,F			; EEPROM address
-	incf	temp6,F			; Increase SP
+	incf	decoplan_index,F    ; Increase SP
 
 	movlw	d'25'
 	addwf	waitms_temp,F		; Increase row
@@ -2994,7 +3063,7 @@
 	movff	waitms_temp,win_top ; Set Row
 	
 	STRCPY  "SP"
-	movff	temp6,lo		; copy gas number
+	movff	decoplan_index,lo   ; copy gas number
 	output_8				; display gas number
 	STRCAT  ": "
 	movff	wait_temp, EEADR; SP #hi position
@@ -3005,7 +3074,7 @@
 	call	word_processor	
 
 	movlw	d'3'		; list all three SP
-	cpfseq	temp6		; All gases shown?
+	cpfseq	decoplan_index		; All gases shown?
 	bra		PLED_simdata_screen3_loop	;no
 
 	read_int_eeprom 	d'33'			; Read byte (stored in EEDATA)
--- a/code_part1/OSTC_code_asm_part1/simulator.asm	Thu Dec 30 23:45:20 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/simulator.asm	Sat Jan 01 01:57:50 2011 +0100
@@ -154,37 +154,29 @@
 	goto	diveloop						; Start Divemode
 
 simulator_show_decoplan:
-	call	PLED_ClearScreen
-	call	PLED_simdata_screen
-	call	divemode_copy_decolist				;copy gf_decolist (0x250:.32) to gf_decolist_copy (0x0E0:.32)
-	call	divemenu_see_decoplan
-
-	WIN_LEFT .0
-	WIN_TOP .160
-	call    PLED_standard_color
-
-	STRCPY  "TTS: "
-	movff   char_O_ascenttime,lo
- 	bcf		leftbind
-	output_8
-	STRCAT_PRINT    "' "
+        call	PLED_ClearScreen
+        call	PLED_simdata_screen
+        call	divemenu_see_decoplan
+        
+        ; Display TTS, if any...
+        movff   char_O_ascenttime,WREG
+        iorwf   WREG
+        bz      simulator_decoplan_notts
 
-;call	enable_rs232
-;	lfsr	FSR0,0x250
-;	movlw	0x20
-;	movwf	wait_temp
-;xy:						; Clear Deco list
-;	movff	POSTINC0,TXREG
-;	call	rs232_wait_tx
-;	decfsz	wait_temp,F
-;	bra		xy
-;	movff	char_O_array_decodepth+0,TXREG
-;
-		
-	
-	WIN_INVERT	.1	; Init new Wordprocessor	
-	DISPLAYTEXT	.188		; Sim. Results:
-	WIN_INVERT	.0	; Init new Wordprocessor	
+        WIN_LEFT .0
+        WIN_TOP .160
+        call    PLED_standard_color
+        
+        STRCPY  "TTS: "
+        movff   char_O_ascenttime,lo
+        bcf		leftbind
+        output_8
+        STRCAT_PRINT    "'"		
+simulator_decoplan_notts:
+
+        WIN_INVERT	.1	                ; Init new Wordprocessor	
+        DISPLAYTEXT	.188		        ; Sim. Results:
+        WIN_INVERT	.0                  ; Init new Wordprocessor	
 	
 simulator_show_decoplan1:
 	bcf		switch_left
@@ -224,11 +216,11 @@
 	bra		simulator_show_decoplan4	; Quit
 
 simulator_show_decoplan5_1:
-	incf	temp8,F
+	incf	decoplan_page,F
 	btfsc	last_ceiling_gf_shown		; last ceiling shown?
 	bra		simulator_show_decoplan5_0	; All done, clear and return
 
-	call	PLED_decoplan_gf_page_current	; Re-Draw Current page of GF Decoplan
+	call	PLED_decoplan_gf        	; Re-Draw Current page of GF Decoplan
 	bra		simulator_show_decoplan1	
 
 simulator_show_decoplan4:
@@ -269,6 +261,7 @@
 
 	call	simulator_save_tissue_data		; Stores 32 floats "pre_tissue" into bank3
 
+	call	PLED_topline_box
 	WIN_INVERT	.1
 	DISPLAYTEXT	.12							;" Wait.."
 	WIN_INVERT	.0
@@ -280,8 +273,8 @@
 	call	deco_calc_hauptroutine		    ; calc_tissue
 	movlb	b'00000001'						; rambank 1 selected
 
-	movff	char_O_deco_status,deco_status		; 
-	tstfsz	deco_status							; deco_status=0 if decompression calculation done
+	movff	char_O_deco_status,WREG
+	tstfsz	WREG                        ; deco_status=0 if decompression calculation done
 	bra		simulator_calc_deco_loop1			; Not finished
 
 	movlw	d'1'
@@ -342,8 +335,8 @@
 	call	deco_calc_hauptroutine		; calc_tissue
 	movlb	b'00000001'						; rambank 1 selected
 
-	movff	char_O_deco_status,deco_status		; 
-	tstfsz	deco_status							; deco_status=0 if decompression calculation done
+	movff	char_O_deco_status,WREG
+	tstfsz	WREG                        ; deco_status=0 if decompression calculation done
 	bra		simulator_calc_deco2				; Not finished
 	bra		simulator_calc_deco3				; finished!