diff code_part1/OSTC_code_asm_part1/menu.asm @ 576:ab2686087bce

faster font display, code cleaning
author heinrichsweikamp
date Sun, 22 Apr 2012 14:38:10 +0200
parents cbdcbbc91877
children fbd5e2b75a63
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/menu.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -34,18 +34,10 @@
 	movlw	d'1'
 	movwf	menupos
 menu2:
-
-	bcf		leftbind
 	call	PLED_ClearScreen
-	clrf	timeout_counter2
-	bcf		sleepmode
-	bcf		menubit2
-	bcf		menubit3
-	bsf		menubit
-	bsf		cursor
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 	call	PLED_menu_mask
 	call	PLED_menu_cursor
-	rcall	wait_switches
 
 menu_loop:
 	call	check_switches_menu
@@ -76,10 +68,10 @@
 	incf	menupos,F
 	movlw	d'6'
 	cpfsgt	menupos
-	bra		refresh_cursor
+	bra		refresh_cursor				; Returns
 	movlw	d'1'
 	movwf	menupos
-	bra		refresh_cursor
+	bra		refresh_cursor				; Returns
 check_switches_menu2:
 	btfsc	switch_left
 	bsf		menubit2					; Enter!
@@ -102,10 +94,8 @@
 
 refresh_cursor:
 	clrf	timeout_counter2
-	btfsc	cursor
 	call	PLED_menu_cursor
-	bcf		switch_right
-	bcf		switch_left
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 	return
 
 more_menu:
@@ -115,16 +105,9 @@
 	bcf		leftbind
 	call	PLED_ClearScreen
 more_menu3:
-	clrf	timeout_counter2
-	bcf		sleepmode
-	bcf		menubit2
-	bcf		menubit3
-	bsf		menubit
-	bsf		cursor
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 	call	PLED_more_menu_mask
 	call	PLED_menu_cursor
-	bcf		switch_left
-	bcf		switch_right
 more_menu_loop:
 	call	check_switches_menu
 
@@ -176,16 +159,9 @@
 	call	PLED_ClearScreen
 	call	PLED_setup_menu_mask
 setup_menu3a:
-	clrf	timeout_counter2
-	bcf		sleepmode
-	bcf		menubit2
-	bcf		menubit3
-	bsf		menubit
-	bsf		cursor
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 	call	show_decotype
 	call	PLED_menu_cursor
-	bcf		switch_left
-	bcf		switch_right
 
 setup_menu_loop:
 	call	check_switches_menu
@@ -314,19 +290,12 @@
 	call	PLED_ClearScreen
 	call	PLED_more_setup_menu_mask
 more_setup_menu3a:
-	clrf	timeout_counter2
-	bcf		sleepmode
-	bcf		menubit2
-	bcf		menubit3
-	bsf		menubit
-	bsf		cursor
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 	call	show_debugstate
 	call	show_dateformat
 	call	show_salinity_value
 	call	PLED_menu_cursor
 	call	toggle_brightness_show
-	bcf		switch_left
-	bcf		switch_right
 
 more_setup_menu_loop:
 	call	check_switches_menu
@@ -542,3 +511,14 @@
 	btfsc	divemode
 	goto	restart			; dive started!
 	return
+
+menu_pre_loop_common:		; Clear some menu flags and the timeout
+	clrf	timeout_counter2
+	bcf		leftbind
+	bcf		sleepmode
+	bcf		menubit2
+	bcf		menubit3
+	bsf		menubit
+	bcf		switch_left
+	bcf		switch_right
+	return