Mercurial > public > hwos_code
annotate src/options.asm @ 340:1c4ff889fcf0
changelog
author | heinrichsweikamp |
---|---|
date | Fri, 03 Jul 2015 15:46:56 +0200 |
parents | 653a3ab08062 |
children | a5fc007634c5 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File options.asm | |
4 ; | |
5 ; Manage all options data. | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-07-12 : [jDG] Creation. | |
11 ; | |
12 ; RATIONALS: | |
13 ; | |
14 ; Provides a centralized file with | |
15 | |
275 | 16 #include "hwos.inc" ; Mandatory header |
0 | 17 #include "strings.inc" |
18 #include "convert.inc" | |
19 #include "ghostwriter.inc" | |
20 #include "eeprom_rs232.inc" | |
21 #include "external_flash.inc" | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
22 #include "wait.inc" |
0 | 23 |
24 extern write_eeprom | |
25 extern read_eeprom | |
26 extern eeprom_serial_save,eeprom_opt_backup | |
143
be997abd1f73
seperate option table, place in address <0x10000
heinrichsweikamp
parents:
142
diff
changeset
|
27 extern option_table_begin,option_table_end |
0 | 28 |
29 global option_reset_all ; Reset all options to factory default. | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
30 global option_check_all ; Check all option and reset option if out of min/max boundary |
0 | 31 global option_reset ; Reset FSR0 option to factory default. |
32 global option_save_all ; Save options to EEPROM. | |
33 global option_restore_all ; Restore options from EEPROM. | |
34 global option_inc ; Increment FSR0 option. | |
35 global option_draw ; STRCAT FRS0 option. | |
36 | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
37 |
0 | 38 ;============================================================================= |
39 CBLOCK tmp+0x10 ; Reserve space for wordprocessor & convert | |
40 opt_type | |
41 opt_default | |
42 opt_inc ; Also default+1 (string), and enum low | |
43 opt_min ; also enum high | |
44 opt_max | |
45 opt_unit:2 ; Multi-lingual unit text. | |
46 opt_eeprom | |
47 opt_backup_tbl:3 | |
48 ; Reserved to tmp+0x1F... | |
49 ENDC | |
50 | |
51 gui CODE ; Appends to other GUI segment | |
52 ;============================================================================= | |
53 ; Reset all options to factory defauts. | |
54 ; | |
55 ; INPUT: none | |
56 ; OUTPUT: none | |
57 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2 | |
58 | |
59 option_reset_all: | |
60 clrf EEADRH | |
61 read_int_eeprom .2 | |
139 | 62 tstfsz EEDATA ; Total dives=0? |
63 bra option_reset_all2 ; No, skip resetting logbook | |
0 | 64 read_int_eeprom .3 |
139 | 65 tstfsz EEDATA ; Total dives=0? |
0 | 66 bra option_reset_all2 ; No, skip resetting logbook |
67 | |
68 clrf EEDATA | |
69 write_int_eeprom .4 | |
70 write_int_eeprom .5 | |
71 write_int_eeprom .6 | |
72 write_int_eeprom .2 ; Also, delete total dive counter | |
73 write_int_eeprom .3 | |
74 call ext_flash_erase_logbook ; And complete logbook (!) | |
75 | |
76 option_reset_all2: | |
77 clrf lo | |
78 clrf hi | |
79 call do_logoffset_common_write ; reset Logbook offset | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
80 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
81 ; Point to option table begin |
0 | 82 movlw LOW(option_table_begin) |
83 movwf FSR0L | |
84 movlw HIGH(option_table_begin) | |
85 movwf FSR0H | |
86 option_reset_all_1: | |
87 movf FSR0L,W ; Reached end of table ? | |
88 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) | |
89 btfsc STATUS,Z ; YES: done. | |
90 return | |
91 | |
92 rcall option_reset ; Reset one option. | |
93 bra option_reset_all_1 ; and loop. | |
94 | |
95 ;============================================================================= | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
96 ; Check all option and reset option if out of min/max boundary |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
97 ; |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
98 ; INPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
99 ; OUTPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
100 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
101 option_check_all: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
102 ; Point to option table begin |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
103 movlw LOW(option_table_begin) |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
104 movwf FSR0L |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
105 movlw HIGH(option_table_begin) |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
106 movwf FSR0H |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
107 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
108 option_check_all_1: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
109 movf FSR0L,W ; Reached end of table ? |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
110 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
111 btfsc STATUS,Z ; YES: done. |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
112 return |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
113 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
114 rcall option_check ; check one option. |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
115 bra option_check_all_1 ; and loop |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
116 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
117 ;============================================================================= |
0 | 118 ; Read option handle |
119 ; INPUT: FSR0 = option handle | |
120 ; OUTPUT: FSR1 = address of variable. | |
121 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1 | |
122 option_read: | |
123 movff FSR0L,TBLPTRL | |
124 movlw HIGH(option_table_begin); Get 8 high bits. | |
125 andlw 0xF0 ; Keep only the 4 highest ones. | |
126 iorwf FSR0H,W ; Cat with the known 4 lower ones. | |
127 movwf TBLPTRH ; And we have the high byte. | |
128 movlw UPPER(option_table_begin) | |
129 movwf TBLPTRU | |
130 | |
131 ; Read type, default and register from table | |
132 tblrd*+ | |
133 movff TABLAT,opt_type | |
134 tblrd*+ | |
135 movff TABLAT,opt_default | |
136 tblrd*+ | |
137 movff TABLAT,opt_inc | |
138 tblrd*+ | |
139 movff TABLAT,opt_min | |
140 tblrd*+ | |
141 movff TABLAT,opt_max | |
142 tblrd*+ | |
143 movff TABLAT,opt_eeprom | |
144 tblrd*+ | |
145 movff TABLAT,opt_unit+0 | |
146 tblrd*+ | |
147 movff TABLAT,opt_unit+1 | |
148 tblrd*+ | |
149 movff TABLAT,FSR1L | |
150 tblrd*+ | |
151 movff TABLAT,FSR1H | |
152 movff TBLPTRL,FSR0L ; Advance handle too, for reset_all | |
153 movff TBLPTRH,FSR0H | |
154 return | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
155 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
156 ;============================================================================= |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
157 ; Check one option and reset if it's out of it's min/max boundaries |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
158 ; INPUT: FSR0 = option handle |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
159 ; OUTPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
160 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2, lo |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
161 ; |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
162 option_check: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
163 ; Read type, default and register from table |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
164 rcall option_read |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
165 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
166 ; Switch on type |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
167 movf opt_type,W ; Type == STRING ? |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
168 xorlw 2 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
169 bz option_check_string ; String: Do not reset strings |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
170 |
110 | 171 movf opt_type,W ; Type == ENUM8 ? |
172 xorlw 1 | |
173 bz option_check_enum8 ; ENUM8: Check if lower then max. value only | |
174 | |
220
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
175 tstfsz opt_min ; opt_min=0? |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
176 bra option_check_both ; no |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
177 bra option_check_enum8 ; Check max only |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
178 |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
179 option_check_both: |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
180 decf opt_min,W |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
181 cpfsgt INDF1 ; bigger then opt_min-1? |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
182 bra option_check_reset ; No, reset option |
185
f515712d8cd6
BUGFIX: Check min and max values after PC configuration properly
heinrichsweikamp
parents:
143
diff
changeset
|
183 option_check_enum8: ; ENUM8: Check max only |
222 | 184 infsnz opt_max,W ; Max = 255? |
185 return ; Yes, igonore max. test | |
185
f515712d8cd6
BUGFIX: Check min and max values after PC configuration properly
heinrichsweikamp
parents:
143
diff
changeset
|
186 cpfslt INDF1 ; smaller then opt_max+1? |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
187 bra option_check_reset ; No, reset option |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
188 return ; in range, return |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
189 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
190 option_check_reset: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
191 movff opt_default,INDF1 ; reset option to default |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
192 return ; Done. |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
193 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
194 option_check_string: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
195 return |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
196 |
0 | 197 ;============================================================================= |
198 ; Reset an option to its default value. | |
199 ; INPUT: FSR0 = option handle | |
200 ; OUTPUT: none | |
201 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2 | |
202 ; | |
203 option_reset: | |
204 ; Read type, default and register from table | |
205 rcall option_read | |
206 | |
207 ; Switch on type | |
208 movf opt_type,W ; Type == STRING ? | |
209 xorlw 2 | |
210 bz opt_reset_string ; YES: special copy | |
211 | |
212 movff opt_default,INDF1 ; NO: just a 8bit indirect copy | |
213 return | |
214 | |
215 opt_reset_string: | |
216 movff FSR1L,FSR2L ; set string destination address. | |
217 movff FSR1H,FSR2H | |
218 | |
219 movff opt_default+0,FSR1L ; Get handle to multi-lingual text in FSR1 | |
220 movff opt_default+1,FSR1H | |
221 | |
222 movff TBLPTRL,opt_backup_tbl+0; TBLPTR trashed by text routine... | |
223 movff TBLPTRH,opt_backup_tbl+1 | |
224 movff TBLPTRU,opt_backup_tbl+2 | |
225 | |
226 call strcat_text ; Copy translated text to FSR2 | |
227 | |
228 movff opt_backup_tbl+0,TBLPTRL | |
229 movff opt_backup_tbl+1,TBLPTRH | |
230 movff opt_backup_tbl+2,TBLPTRU | |
231 | |
232 return | |
233 | |
234 ;============================================================================= | |
235 ; Save all options to EEPROM | |
236 option_save_all: | |
237 ;---- Save option serial into EEPROM to detect reset and new version | |
238 movlw LOW(eeprom_serial_save) | |
239 movwf EEADR | |
240 movlw HIGH(eeprom_serial_save) | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
241 movwf EEADRH |
0 | 242 movlw LOW(eeprom_opt_serial) |
243 movwf EEDATA | |
244 call write_eeprom | |
245 incf EEADR,F | |
246 movlw HIGH(eeprom_opt_serial) | |
247 movwf EEDATA | |
248 call write_eeprom | |
249 | |
250 ;---- Save all options | |
251 movlw LOW(option_table_begin) | |
252 movwf FSR0L | |
253 movlw HIGH(option_table_begin) | |
254 movwf FSR0H | |
255 | |
256 option_save_all_1: | |
257 movf FSR0L,W ; Reached end of table ? | |
258 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) | |
259 btfsc STATUS,Z ; YES: done. | |
260 return | |
261 | |
262 rcall option_save ; Save one option. | |
263 bra option_save_all_1 ; and loop. | |
264 | |
93
5e1ef9bf32ec
clear pressure sensor compensation upon update
heinrichsweikamp
parents:
92
diff
changeset
|
265 global option_save |
0 | 266 option_save: |
267 rcall option_read | |
268 incf opt_eeprom,W ; Should we save it ? | |
269 btfsc STATUS,Z ; eeprom address is FFh ? | |
270 return ; YES: nothing to do. | |
271 | |
272 movf opt_eeprom,W ; Compute backup address in EEPROM | |
273 addlw LOW(eeprom_opt_backup) ; Add offset | |
274 movwf EEADR | |
275 movlw HIGH(eeprom_opt_backup) | |
142 | 276 btfsc STATUS,C ; >256 |
277 addlw .1 ; Yes: +1 | |
0 | 278 movwf EEADRH |
279 | |
280 movf opt_type,W ; Option type is string ? | |
281 xorlw 2 | |
282 bz option_save_string | |
283 | |
284 ; One byte to save to eeprom | |
285 movff INDF1,EEDATA | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
286 btfss EEADRH,1 ; EEADR:EEADRH < 512? |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
287 call write_eeprom ; Yes, write |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
288 return |
0 | 289 |
290 option_save_string: | |
291 movff POSTINC1,EEDATA ; Write one byte | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
292 btfss EEADRH,1 ; EEADR:EEADRH < 512? |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
293 call write_eeprom ; Yes, write |
0 | 294 infsnz EEADR,F |
295 incf EEADRH,F | |
296 | |
297 decfsz opt_max ; Decrement string length | |
298 bra option_save_string ; And loop while not finished | |
299 | |
300 return | |
301 ;============================================================================= | |
302 | |
303 option_restore_all: | |
304 ;---- Read option serial from EEPROM | |
305 movlw LOW(eeprom_serial_save) | |
306 movwf EEADR | |
307 movlw HIGH(eeprom_serial_save) | |
308 movf EEADRH | |
309 call read_eeprom | |
310 movlw LOW(eeprom_opt_serial) | |
311 xorwf EEDATA,W | |
312 bnz option_restore_bad ; Auto reset if changed. | |
313 incf EEADR,F | |
314 call read_eeprom | |
315 movlw HIGH(eeprom_opt_serial) | |
316 xorwf EEDATA,W | |
317 bz option_restore_ok ; Auto reset if changed. | |
318 | |
319 option_restore_bad: | |
320 call option_reset_all ; Reset RAM contains | |
321 goto option_save_all ; Then save to EEPROM | |
322 | |
323 ;---- Proper restore | |
324 option_restore_ok: | |
325 movlw LOW(option_table_begin) | |
326 movwf FSR0L | |
327 movlw HIGH(option_table_begin) | |
328 movwf FSR0H | |
329 | |
330 option_restore_all_1: | |
331 movf FSR0L,W ; Reached end of table ? | |
332 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) | |
333 btfsc STATUS,Z ; YES: done. | |
334 return | |
335 | |
336 rcall option_restore ; Restore one option. | |
337 bra option_restore_all_1 ; and loop. | |
338 return | |
339 | |
340 option_restore: | |
341 rcall option_read | |
342 incf opt_eeprom,W ; Should we save it ? | |
343 btfsc STATUS,Z ; eeprom address is FFh ? | |
344 return ; YES: nothing to do. | |
345 | |
346 movf opt_eeprom,W ; Compute backup address in EEPROM | |
347 addlw LOW(eeprom_opt_backup) ; Add offset | |
348 movwf EEADR | |
349 movlw HIGH(eeprom_opt_backup) | |
142 | 350 btfsc STATUS,C ; >256 |
351 addlw .1 ; Yes: +1 | |
0 | 352 movwf EEADRH |
353 | |
354 movf opt_type,W ; Option type is string ? | |
355 xorlw 2 | |
356 bz option_restore_string | |
357 | |
358 ; Read one byte from eeprom | |
359 call read_eeprom | |
360 movff EEDATA, INDF1 ; And restore option register. | |
361 return | |
362 | |
363 option_restore_string: | |
364 call read_eeprom ; Read one byte, and | |
365 movff EEDATA,POSTINC1 ; restore it | |
366 infsnz EEADR,F | |
367 incf EEADRH,F | |
368 | |
369 decfsz opt_max ; Decrement string length | |
370 bra option_restore_string ; And loop while not finished | |
371 return | |
372 | |
373 ;============================================================================= | |
374 ; Increment an option, based on type, and boundary. | |
375 ; INPUT: FSR0 = option handle | |
376 ; OUTPUT: none | |
377 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1 | |
378 option_inc: | |
379 ; Read type, default and register from table | |
380 rcall option_read | |
381 | |
382 ; Switch on type | |
383 movf opt_type,W | |
384 bz option_inc_uint8 | |
385 dcfsnz WREG | |
386 bra option_inc_enum8 | |
387 dcfsnz WREG | |
388 bra option_inc_string | |
389 | |
390 option_inc_uint8: ; Defaults type too... | |
391 movf INDF1,W | |
392 addwf opt_inc,W | |
393 cpfslt opt_max | |
394 bra option_inc_1 | |
395 movf opt_min,W | |
396 option_inc_1: | |
397 movwf INDF1 | |
398 return | |
399 | |
400 option_inc_enum8: ; Always +1 | |
401 incf INDF1,W | |
402 cpfsgt opt_max | |
403 clrf WREG | |
404 movwf INDF1 | |
405 return | |
406 | |
407 option_inc_string: ; No edition yet... | |
408 return | |
409 | |
410 ;============================================================================= | |
411 ; Strcat option into FSR2 buffer. | |
412 option_draw: | |
413 ; Read type, default and register from table | |
414 rcall option_read | |
415 | |
416 ; Switch on type | |
417 movf opt_type,W | |
418 bz option_draw_uint8 | |
419 dcfsnz WREG | |
420 bra option_draw_enum8 | |
421 dcfsnz WREG | |
422 bra option_draw_string | |
423 return ; Unknown: return... | |
424 | |
425 option_draw_uint8: | |
426 movff INDF1,lo ; Draw value. | |
263 | 427 bsf leftbind |
0 | 428 output_8 |
263 | 429 bcf leftbind |
0 | 430 clrf INDF2 ; Make sure to close string... |
431 | |
432 movf opt_unit+0,W ; Is there a unit to append ? | |
433 iorwf opt_unit+1,W | |
434 rcall option_draw_unit | |
435 | |
436 movf opt_default,W ; Default value | |
437 cpfseq lo ; Current value | |
438 bra option_draw_uint8_2 ; Not default, add * | |
439 return ; Default, Done. | |
440 option_draw_uint8_2: | |
441 PUTC "*" | |
442 return ; Done. | |
443 | |
444 option_draw_unit: | |
445 movff opt_unit+0,FSR1L | |
446 movff opt_unit+1,FSR1H | |
447 goto strcat_text | |
448 | |
449 | |
450 | |
451 ;---- Draw an enumerated value (set of translated strings) | |
452 option_draw_enum8: | |
453 movf INDF1,W ; Get current value. | |
454 cpfsgt opt_max ; Bound value | |
455 clrf WREG | |
456 addwf WREG ; *= 2 | |
457 addwf opt_inc,W ; Base text + 2 * value | |
458 movwf FSR1L | |
459 movlw 0 | |
460 addwfc opt_min,W ; Propagate carry | |
461 movwf FSR1H ; Into FSR1 | |
462 | |
463 goto strcat_text | |
464 | |
465 option_draw_string: | |
466 movff POSTINC1,POSTINC2 | |
467 decfsz opt_max | |
468 bra option_draw_string | |
469 return | |
470 | |
471 END |