Mercurial > public > hwos_code
annotate src/options.asm @ 202:34b8de21146c
1.63beta release
author | heinrichsweikamp |
---|---|
date | Fri, 21 Nov 2014 11:10:07 +0100 |
parents | f515712d8cd6 |
children | effd7259f5a5 |
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 | |
16 #include "ostc3.inc" ; Mandatory header | |
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 | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
175 movf opt_min,W |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
176 cpfsgt INDF1 ; bigger then opt_min? |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
177 bra option_check_reset ; No, reset option |
185
f515712d8cd6
BUGFIX: Check min and max values after PC configuration properly
heinrichsweikamp
parents:
143
diff
changeset
|
178 option_check_enum8: ; ENUM8: Check max only |
f515712d8cd6
BUGFIX: Check min and max values after PC configuration properly
heinrichsweikamp
parents:
143
diff
changeset
|
179 incf opt_max,W |
f515712d8cd6
BUGFIX: Check min and max values after PC configuration properly
heinrichsweikamp
parents:
143
diff
changeset
|
180 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
|
181 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
|
182 return ; in range, return |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
183 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
184 option_check_reset: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
185 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
|
186 return ; Done. |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
187 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
188 option_check_string: |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
189 return |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
190 |
0 | 191 ;============================================================================= |
192 ; Reset an option to its default value. | |
193 ; INPUT: FSR0 = option handle | |
194 ; OUTPUT: none | |
195 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2 | |
196 ; | |
197 option_reset: | |
198 ; Read type, default and register from table | |
199 rcall option_read | |
200 | |
201 ; Switch on type | |
202 movf opt_type,W ; Type == STRING ? | |
203 xorlw 2 | |
204 bz opt_reset_string ; YES: special copy | |
205 | |
206 movff opt_default,INDF1 ; NO: just a 8bit indirect copy | |
207 return | |
208 | |
209 opt_reset_string: | |
210 movff FSR1L,FSR2L ; set string destination address. | |
211 movff FSR1H,FSR2H | |
212 | |
213 movff opt_default+0,FSR1L ; Get handle to multi-lingual text in FSR1 | |
214 movff opt_default+1,FSR1H | |
215 | |
216 movff TBLPTRL,opt_backup_tbl+0; TBLPTR trashed by text routine... | |
217 movff TBLPTRH,opt_backup_tbl+1 | |
218 movff TBLPTRU,opt_backup_tbl+2 | |
219 | |
220 call strcat_text ; Copy translated text to FSR2 | |
221 | |
222 movff opt_backup_tbl+0,TBLPTRL | |
223 movff opt_backup_tbl+1,TBLPTRH | |
224 movff opt_backup_tbl+2,TBLPTRU | |
225 | |
226 return | |
227 | |
228 ;============================================================================= | |
229 ; Save all options to EEPROM | |
230 option_save_all: | |
231 ;---- Save option serial into EEPROM to detect reset and new version | |
232 movlw LOW(eeprom_serial_save) | |
233 movwf EEADR | |
234 movlw HIGH(eeprom_serial_save) | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
235 movwf EEADRH |
0 | 236 movlw LOW(eeprom_opt_serial) |
237 movwf EEDATA | |
238 call write_eeprom | |
239 incf EEADR,F | |
240 movlw HIGH(eeprom_opt_serial) | |
241 movwf EEDATA | |
242 call write_eeprom | |
243 | |
244 ;---- Save all options | |
245 movlw LOW(option_table_begin) | |
246 movwf FSR0L | |
247 movlw HIGH(option_table_begin) | |
248 movwf FSR0H | |
249 | |
250 option_save_all_1: | |
251 movf FSR0L,W ; Reached end of table ? | |
252 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) | |
253 btfsc STATUS,Z ; YES: done. | |
254 return | |
255 | |
256 rcall option_save ; Save one option. | |
257 bra option_save_all_1 ; and loop. | |
258 | |
93
5e1ef9bf32ec
clear pressure sensor compensation upon update
heinrichsweikamp
parents:
92
diff
changeset
|
259 global option_save |
0 | 260 option_save: |
261 rcall option_read | |
262 incf opt_eeprom,W ; Should we save it ? | |
263 btfsc STATUS,Z ; eeprom address is FFh ? | |
264 return ; YES: nothing to do. | |
265 | |
266 movf opt_eeprom,W ; Compute backup address in EEPROM | |
267 addlw LOW(eeprom_opt_backup) ; Add offset | |
268 movwf EEADR | |
269 movlw HIGH(eeprom_opt_backup) | |
142 | 270 btfsc STATUS,C ; >256 |
271 addlw .1 ; Yes: +1 | |
0 | 272 movwf EEADRH |
273 | |
274 movf opt_type,W ; Option type is string ? | |
275 xorlw 2 | |
276 bz option_save_string | |
277 | |
278 ; One byte to save to eeprom | |
279 movff INDF1,EEDATA | |
133
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
280 btfss EEADRH,1 ; EEADR:EEADRH < 512? |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
281 call write_eeprom ; Yes, write |
939f1e83c4c2
BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents:
113
diff
changeset
|
282 return |
0 | 283 |
284 option_save_string: | |
285 movff POSTINC1,EEDATA ; Write one byte | |
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 |
0 | 288 infsnz EEADR,F |
289 incf EEADRH,F | |
290 | |
291 decfsz opt_max ; Decrement string length | |
292 bra option_save_string ; And loop while not finished | |
293 | |
294 return | |
295 ;============================================================================= | |
296 | |
297 option_restore_all: | |
298 ;---- Read option serial from EEPROM | |
299 movlw LOW(eeprom_serial_save) | |
300 movwf EEADR | |
301 movlw HIGH(eeprom_serial_save) | |
302 movf EEADRH | |
303 call read_eeprom | |
304 movlw LOW(eeprom_opt_serial) | |
305 xorwf EEDATA,W | |
306 bnz option_restore_bad ; Auto reset if changed. | |
307 incf EEADR,F | |
308 call read_eeprom | |
309 movlw HIGH(eeprom_opt_serial) | |
310 xorwf EEDATA,W | |
311 bz option_restore_ok ; Auto reset if changed. | |
312 | |
313 option_restore_bad: | |
314 call option_reset_all ; Reset RAM contains | |
315 goto option_save_all ; Then save to EEPROM | |
316 | |
317 ;---- Proper restore | |
318 option_restore_ok: | |
319 movlw LOW(option_table_begin) | |
320 movwf FSR0L | |
321 movlw HIGH(option_table_begin) | |
322 movwf FSR0H | |
323 | |
324 option_restore_all_1: | |
325 movf FSR0L,W ; Reached end of table ? | |
326 xorlw LOW(option_table_end) ; (8bit test -> 10 bytes x 128 options max) | |
327 btfsc STATUS,Z ; YES: done. | |
328 return | |
329 | |
330 rcall option_restore ; Restore one option. | |
331 bra option_restore_all_1 ; and loop. | |
332 return | |
333 | |
334 option_restore: | |
335 rcall option_read | |
336 incf opt_eeprom,W ; Should we save it ? | |
337 btfsc STATUS,Z ; eeprom address is FFh ? | |
338 return ; YES: nothing to do. | |
339 | |
340 movf opt_eeprom,W ; Compute backup address in EEPROM | |
341 addlw LOW(eeprom_opt_backup) ; Add offset | |
342 movwf EEADR | |
343 movlw HIGH(eeprom_opt_backup) | |
142 | 344 btfsc STATUS,C ; >256 |
345 addlw .1 ; Yes: +1 | |
0 | 346 movwf EEADRH |
347 | |
348 movf opt_type,W ; Option type is string ? | |
349 xorlw 2 | |
350 bz option_restore_string | |
351 | |
352 ; Read one byte from eeprom | |
353 call read_eeprom | |
354 movff EEDATA, INDF1 ; And restore option register. | |
355 return | |
356 | |
357 option_restore_string: | |
358 call read_eeprom ; Read one byte, and | |
359 movff EEDATA,POSTINC1 ; restore it | |
360 infsnz EEADR,F | |
361 incf EEADRH,F | |
362 | |
363 decfsz opt_max ; Decrement string length | |
364 bra option_restore_string ; And loop while not finished | |
365 return | |
366 | |
367 ;============================================================================= | |
368 ; Increment an option, based on type, and boundary. | |
369 ; INPUT: FSR0 = option handle | |
370 ; OUTPUT: none | |
371 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1 | |
372 option_inc: | |
373 ; Read type, default and register from table | |
374 rcall option_read | |
375 | |
376 ; Switch on type | |
377 movf opt_type,W | |
378 bz option_inc_uint8 | |
379 dcfsnz WREG | |
380 bra option_inc_enum8 | |
381 dcfsnz WREG | |
382 bra option_inc_string | |
383 | |
384 option_inc_uint8: ; Defaults type too... | |
385 movf INDF1,W | |
386 addwf opt_inc,W | |
387 cpfslt opt_max | |
388 bra option_inc_1 | |
389 movf opt_min,W | |
390 option_inc_1: | |
391 movwf INDF1 | |
392 return | |
393 | |
394 option_inc_enum8: ; Always +1 | |
395 incf INDF1,W | |
396 cpfsgt opt_max | |
397 clrf WREG | |
398 movwf INDF1 | |
399 return | |
400 | |
401 option_inc_string: ; No edition yet... | |
402 return | |
403 | |
404 ;============================================================================= | |
405 ; Strcat option into FSR2 buffer. | |
406 option_draw: | |
407 ; Read type, default and register from table | |
408 rcall option_read | |
409 | |
410 ; Switch on type | |
411 movf opt_type,W | |
412 bz option_draw_uint8 | |
413 dcfsnz WREG | |
414 bra option_draw_enum8 | |
415 dcfsnz WREG | |
416 bra option_draw_string | |
417 return ; Unknown: return... | |
418 | |
419 option_draw_uint8: | |
420 movff INDF1,lo ; Draw value. | |
421 output_8 | |
422 clrf INDF2 ; Make sure to close string... | |
423 | |
424 movf opt_unit+0,W ; Is there a unit to append ? | |
425 iorwf opt_unit+1,W | |
426 rcall option_draw_unit | |
427 | |
428 movf opt_default,W ; Default value | |
429 cpfseq lo ; Current value | |
430 bra option_draw_uint8_2 ; Not default, add * | |
431 return ; Default, Done. | |
432 option_draw_uint8_2: | |
433 PUTC "*" | |
434 return ; Done. | |
435 | |
436 option_draw_unit: | |
437 movff opt_unit+0,FSR1L | |
438 movff opt_unit+1,FSR1H | |
439 goto strcat_text | |
440 | |
441 | |
442 | |
443 ;---- Draw an enumerated value (set of translated strings) | |
444 option_draw_enum8: | |
445 movf INDF1,W ; Get current value. | |
446 cpfsgt opt_max ; Bound value | |
447 clrf WREG | |
448 addwf WREG ; *= 2 | |
449 addwf opt_inc,W ; Base text + 2 * value | |
450 movwf FSR1L | |
451 movlw 0 | |
452 addwfc opt_min,W ; Propagate carry | |
453 movwf FSR1H ; Into FSR1 | |
454 | |
455 goto strcat_text | |
456 | |
457 option_draw_string: | |
458 movff POSTINC1,POSTINC2 | |
459 decfsz opt_max | |
460 bra option_draw_string | |
461 return | |
462 | |
463 END |