Mercurial > public > hwos_code
comparison src/options.asm @ 21:79b2084fd75a
Reset options to default if they are not within the allowed min/max values
author | heinrichsweikamp |
---|---|
date | Thu, 04 Jul 2013 09:51:33 +0200 |
parents | 4e3f133dfbf4 |
children | e01c39be267c |
comparison
equal
deleted
inserted
replaced
20:9b7dd3103545 | 21:79b2084fd75a |
---|---|
17 #include "strings.inc" | 17 #include "strings.inc" |
18 #include "convert.inc" | 18 #include "convert.inc" |
19 #include "ghostwriter.inc" | 19 #include "ghostwriter.inc" |
20 #include "eeprom_rs232.inc" | 20 #include "eeprom_rs232.inc" |
21 #include "external_flash.inc" | 21 #include "external_flash.inc" |
22 #include "wait.inc" | |
22 | 23 |
23 extern write_eeprom | 24 extern write_eeprom |
24 extern read_eeprom | 25 extern read_eeprom |
25 extern eeprom_serial_save,eeprom_opt_backup | 26 extern eeprom_serial_save,eeprom_opt_backup |
26 | 27 |
27 global option_reset_all ; Reset all options to factory default. | 28 global option_reset_all ; Reset all options to factory default. |
29 global option_check_all ; Check all option and reset option if out of min/max boundary | |
28 global option_reset ; Reset FSR0 option to factory default. | 30 global option_reset ; Reset FSR0 option to factory default. |
29 global option_save_all ; Save options to EEPROM. | 31 global option_save_all ; Save options to EEPROM. |
30 global option_restore_all ; Restore options from EEPROM. | 32 global option_restore_all ; Restore options from EEPROM. |
31 global option_inc ; Increment FSR0 option. | 33 global option_inc ; Increment FSR0 option. |
32 global option_draw ; STRCAT FRS0 option. | 34 global option_draw ; STRCAT FRS0 option. |
35 | |
33 | 36 |
34 ;============================================================================= | 37 ;============================================================================= |
35 CBLOCK tmp+0x10 ; Reserve space for wordprocessor & convert | 38 CBLOCK tmp+0x10 ; Reserve space for wordprocessor & convert |
36 opt_type | 39 opt_type |
37 opt_default | 40 opt_default |
74 | 77 |
75 option_reset_all2: | 78 option_reset_all2: |
76 clrf lo | 79 clrf lo |
77 clrf hi | 80 clrf hi |
78 call do_logoffset_common_write ; reset Logbook offset | 81 call do_logoffset_common_write ; reset Logbook offset |
82 | |
83 ; Point to option table begin | |
79 movlw LOW(option_table_begin) | 84 movlw LOW(option_table_begin) |
80 movwf FSR0L | 85 movwf FSR0L |
81 movlw HIGH(option_table_begin) | 86 movlw HIGH(option_table_begin) |
82 movwf FSR0H | 87 movwf FSR0H |
83 | |
84 option_reset_all_1: | 88 option_reset_all_1: |
85 movf FSR0L,W ; Reached end of table ? | 89 movf FSR0L,W ; Reached end of table ? |
86 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) | 90 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) |
87 btfsc STATUS,Z ; YES: done. | 91 btfsc STATUS,Z ; YES: done. |
88 return | 92 return |
89 | 93 |
90 rcall option_reset ; Reset one option. | 94 rcall option_reset ; Reset one option. |
91 bra option_reset_all_1 ; and loop. | 95 bra option_reset_all_1 ; and loop. |
96 | |
97 ;============================================================================= | |
98 ; Check all option and reset option if out of min/max boundary | |
99 ; | |
100 ; INPUT: none | |
101 ; OUTPUT: none | |
102 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2 | |
103 option_check_all: | |
104 ; Point to option table begin | |
105 movlw LOW(option_table_begin) | |
106 movwf FSR0L | |
107 movlw HIGH(option_table_begin) | |
108 movwf FSR0H | |
109 | |
110 option_check_all_1: | |
111 movf FSR0L,W ; Reached end of table ? | |
112 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) | |
113 btfsc STATUS,Z ; YES: done. | |
114 return | |
115 | |
116 rcall option_check ; check one option. | |
117 bra option_check_all_1 ; and loop | |
92 | 118 |
93 ;============================================================================= | 119 ;============================================================================= |
94 ; Read option handle | 120 ; Read option handle |
95 ; INPUT: FSR0 = option handle | 121 ; INPUT: FSR0 = option handle |
96 ; OUTPUT: FSR1 = address of variable. | 122 ; OUTPUT: FSR1 = address of variable. |
125 movff TABLAT,FSR1L | 151 movff TABLAT,FSR1L |
126 tblrd*+ | 152 tblrd*+ |
127 movff TABLAT,FSR1H | 153 movff TABLAT,FSR1H |
128 movff TBLPTRL,FSR0L ; Advance handle too, for reset_all | 154 movff TBLPTRL,FSR0L ; Advance handle too, for reset_all |
129 movff TBLPTRH,FSR0H | 155 movff TBLPTRH,FSR0H |
130 | 156 return |
131 return | 157 |
132 | 158 ;============================================================================= |
159 ; Check one option and reset if it's out of it's min/max boundaries | |
160 ; INPUT: FSR0 = option handle | |
161 ; OUTPUT: none | |
162 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2, lo | |
163 ; | |
164 option_check: | |
165 ; Read type, default and register from table | |
166 rcall option_read | |
167 | |
168 ; Switch on type | |
169 movf opt_type,W ; Type == STRING ? | |
170 xorlw 2 | |
171 bz option_check_string ; String: Do not reset strings | |
172 | |
173 movf opt_min,W | |
174 cpfsgt INDF1 ; bigger then opt_min? | |
175 bra option_check_reset ; No, reset option | |
176 movf INDF1,W | |
177 cpfsgt opt_max ; bigger then INDF1? | |
178 bra option_check_reset ; No, reset option | |
179 return ; in range, return | |
180 | |
181 option_check_reset: | |
182 movff opt_default,INDF1 ; reset option to default | |
183 return ; Done. | |
184 | |
185 option_check_string: | |
186 return | |
187 | |
133 ;============================================================================= | 188 ;============================================================================= |
134 ; Reset an option to its default value. | 189 ; Reset an option to its default value. |
135 ; INPUT: FSR0 = option handle | 190 ; INPUT: FSR0 = option handle |
136 ; OUTPUT: none | 191 ; OUTPUT: none |
137 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2 | 192 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2 |