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