Mercurial > public > hwos_code
annotate src/options.asm @ 595:1719de53e497
2.97 SP2 (999bar fix)
author | heinrichsweikamp |
---|---|
date | Mon, 25 Jun 2018 18:29:54 +0200 |
parents | b455b31ce022 |
children | ca4556fb60b9 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
582 | 3 ; File options.asm REFACTORED VERSION V2.97 |
0 | 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 | |
582 | 16 #include "hwos.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" | |
22 #include "wait.inc" | |
0 | 23 |
582 | 24 extern write_eeprom |
25 extern read_eeprom | |
26 extern eeprom_serial_save,eeprom_opt_backup | |
27 extern option_table_begin,option_table_end | |
0 | 28 |
582 | 29 global option_reset_all ; Reset all options to factory default. |
30 global option_check_all ; Check all option and reset option if out of min/max boundary | |
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. | |
0 | 36 |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
37 |
582 | 38 gui CODE ; Appends to other GUI segment |
39 | |
0 | 40 ;============================================================================= |
582 | 41 ; Reset all options to factory defaults. |
0 | 42 ; |
43 ; INPUT: none | |
44 ; OUTPUT: none | |
45 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2 | |
46 | |
47 option_reset_all: | |
582 | 48 clrf EEADRH |
49 read_int_eeprom .2 | |
50 tstfsz EEDATA ; Total dives=0? | |
51 bra option_reset_all2 ; No, skip resetting logbook | |
52 read_int_eeprom .3 | |
53 tstfsz EEDATA ; Total dives=0? | |
54 bra option_reset_all2 ; No, skip resetting logbook | |
0 | 55 |
582 | 56 clrf EEDATA |
57 write_int_eeprom .4 | |
58 write_int_eeprom .5 | |
59 write_int_eeprom .6 | |
60 write_int_eeprom .2 ; Also, delete total dive counter | |
61 write_int_eeprom .3 | |
62 call ext_flash_erase_logbook ; And complete logbook (!) | |
0 | 63 |
64 option_reset_all2: | |
582 | 65 clrf lo |
66 clrf hi | |
67 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
|
68 |
582 | 69 ; Point to option table begin |
70 movlw LOW(option_table_begin) | |
71 movwf FSR0L | |
72 movlw HIGH(option_table_begin) | |
73 movwf FSR0H | |
0 | 74 option_reset_all_1: |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
75 movlw LOW(option_table_end) |
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
76 cpfseq FSR0L |
582 | 77 bra option_reset_all_2 ; Not yet done... |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
78 movlw HIGH(option_table_end) |
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
79 cpfseq FSR0H |
582 | 80 bra option_reset_all_2 ; Not yet done... |
81 return ; All done. | |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
82 option_reset_all_2: |
582 | 83 rcall option_reset ; Reset one option. |
84 bra option_reset_all_1 ; and loop. | |
0 | 85 |
86 ;============================================================================= | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
87 ; 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
|
88 ; |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
89 ; INPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
90 ; OUTPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
91 ; 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
|
92 option_check_all: |
582 | 93 ; Point to option table begin |
94 movlw LOW(option_table_begin) | |
95 movwf FSR0L | |
96 movlw HIGH(option_table_begin) | |
97 movwf FSR0H | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
98 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
99 option_check_all_1: |
582 | 100 movlw LOW(option_table_end) |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
101 cpfseq FSR0L |
582 | 102 bra option_check_all_2 ; Not yet done... |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
103 movlw HIGH(option_table_end) |
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
104 cpfseq FSR0H |
582 | 105 bra option_check_all_2 ; Not yet done... |
106 return ; All done. | |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
107 option_check_all_2: |
582 | 108 rcall option_check ; check one option. |
109 bra option_check_all_1 ; and loop | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
110 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
111 ;============================================================================= |
0 | 112 ; Read option handle |
113 ; INPUT: FSR0 = option handle | |
114 ; OUTPUT: FSR1 = address of variable. | |
115 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1 | |
116 option_read: | |
582 | 117 movff FSR0L,TBLPTRL |
118 movlw HIGH(option_table_begin) ; Get 8 high bits. | |
119 andlw 0xF0 ; Keep only the 4 highest ones. | |
120 iorwf FSR0H,W ; Cat with the known 4 lower ones. | |
121 movwf TBLPTRH ; And we have the high byte. | |
122 movlw UPPER(option_table_begin) | |
123 movwf TBLPTRU | |
0 | 124 |
582 | 125 ; Read type, default and register from table |
126 tblrd*+ | |
127 movff TABLAT,opt_type | |
128 tblrd*+ | |
129 movff TABLAT,opt_default | |
130 tblrd*+ | |
131 movff TABLAT,opt_inc | |
132 tblrd*+ | |
133 movff TABLAT,opt_min | |
134 tblrd*+ | |
135 movff TABLAT,opt_max | |
136 tblrd*+ | |
137 movff TABLAT,opt_eeprom | |
138 tblrd*+ | |
139 movff TABLAT,opt_unit+0 | |
140 tblrd*+ | |
141 movff TABLAT,opt_unit+1 | |
142 tblrd*+ | |
143 movff TABLAT,FSR1L | |
144 tblrd*+ | |
145 movff TABLAT,FSR1H | |
146 movff TBLPTRL,FSR0L ; Advance handle too, for reset_all | |
147 movff TBLPTRH,FSR0H | |
148 return | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
149 |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
150 ;============================================================================= |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
151 ; 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
|
152 ; INPUT: FSR0 = option handle |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
153 ; OUTPUT: none |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
154 ; 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
|
155 ; |
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
156 option_check: |
582 | 157 ; Read type, default and register from table |
158 rcall option_read | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
159 |
582 | 160 ; Switch on type |
161 movf opt_type,W ; Type == STRING ? | |
162 xorlw 2 | |
163 bz option_check_string ; String: Do not reset strings | |
21
79b2084fd75a
Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents:
18
diff
changeset
|
164 |
582 | 165 movf opt_type,W ; Type == ENUM8 ? |
166 xorlw 1 | |
167 bz option_check_enum8 ; ENUM8: Check if lower then max. value only | |
110 | 168 |
582 | 169 tstfsz opt_min ; opt_min=0? |
170 bra option_check_both ; no | |
171 bra option_check_enum8 ; Check max only | |
220
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
172 |
effd7259f5a5
make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents:
185
diff
changeset
|
173 option_check_both: |
582 | 174 decf opt_min,W |
175 cpfsgt INDF1 ; bigger then opt_min-1? | |
176 bra option_check_reset ; No, reset option | |
177 option_check_enum8: ; ENUM8: Check max only | |
178 infsnz opt_max,W ; Max = 255? | |
179 return ; Yes, ignore max. test | |
180 cpfslt INDF1 ; smaller then opt_max+1? | |
181 bra option_check_reset ; No, reset option | |
182 return ; in range, return | |
21
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: |
582 | 185 movff opt_default,INDF1 ; reset option to default |
186 return ; Done. | |
21
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: |
582 | 189 return |
21
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: | |
582 | 198 ; Read type, default and register from table |
199 rcall option_read | |
0 | 200 |
582 | 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 | |
0 | 208 |
209 opt_reset_string: | |
582 | 210 movff FSR1L,FSR2L ; set string destination address. |
211 movff FSR1H,FSR2H | |
0 | 212 |
582 | 213 movff opt_default+0,FSR1L ; Get handle to multi-lingual text in FSR1 |
214 movff opt_default+1,FSR1H | |
0 | 215 |
582 | 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 | |
0 | 219 |
582 | 220 call strcat_text ; Copy translated text to FSR2 |
0 | 221 |
582 | 222 movff opt_backup_tbl+0,TBLPTRL |
223 movff opt_backup_tbl+1,TBLPTRH | |
224 movff opt_backup_tbl+2,TBLPTRU | |
0 | 225 |
582 | 226 return |
0 | 227 |
228 ;============================================================================= | |
229 ; Save all options to EEPROM | |
230 option_save_all: | |
582 | 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) | |
235 movwf EEADRH | |
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 | |
0 | 249 |
250 option_save_all_1: | |
582 | 251 movlw LOW(option_table_end) |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
252 cpfseq FSR0L |
582 | 253 bra option_save_all_2 ; Not yet done... |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
254 movlw HIGH(option_table_end) |
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
255 cpfseq FSR0H |
582 | 256 bra option_save_all_2 ; Not yet done... |
257 return ; All done. | |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
258 option_save_all_2: |
582 | 259 rcall option_save ; Save one option. |
260 bra option_save_all_1 ; and loop. | |
0 | 261 |
582 | 262 global option_save |
0 | 263 option_save: |
582 | 264 rcall option_read |
265 incf opt_eeprom,W ; Should we save it ? | |
266 btfsc STATUS,Z ; EEPROM address is FFh ? | |
267 return ; YES: nothing to do. | |
0 | 268 |
582 | 269 movf opt_eeprom,W ; Compute backup address in EEPROM |
270 addlw LOW(eeprom_opt_backup) ; Add offset | |
271 movwf EEADR | |
272 movlw HIGH(eeprom_opt_backup) | |
273 btfsc STATUS,C ; >256 | |
274 addlw .1 ; Yes: +1 | |
275 movwf EEADRH | |
0 | 276 |
582 | 277 movf opt_type,W ; Option type is string ? |
278 xorlw 2 | |
279 bz option_save_string | |
0 | 280 |
582 | 281 ; One byte to save to EEPROM |
282 movff INDF1,EEDATA | |
283 btfss EEADRH,1 ; EEADR:EEADRH < 512? | |
284 call write_eeprom ; Yes, write | |
285 return | |
286 | |
0 | 287 option_save_string: |
582 | 288 movff POSTINC1,EEDATA ; Write one byte |
289 btfss EEADRH,1 ; EEADR:EEADRH < 512? | |
290 call write_eeprom ; Yes, write | |
291 infsnz EEADR,F | |
292 incf EEADRH,F | |
0 | 293 |
582 | 294 decfsz opt_max ; Decrement string length |
295 bra option_save_string ; And loop while not finished | |
296 | |
297 return | |
0 | 298 ;============================================================================= |
299 | |
300 option_restore_all: | |
582 | 301 ;---- Read option serial from EEPROM |
302 movlw LOW(eeprom_serial_save) | |
303 movwf EEADR | |
304 movlw HIGH(eeprom_serial_save) | |
305 movf EEADRH | |
306 call read_eeprom | |
307 movlw LOW(eeprom_opt_serial) | |
308 xorwf EEDATA,W | |
309 bnz option_restore_bad ; Auto reset if changed. | |
310 incf EEADR,F | |
311 call read_eeprom | |
312 movlw HIGH(eeprom_opt_serial) | |
313 xorwf EEDATA,W | |
314 bz option_restore_ok ; Auto reset if changed. | |
0 | 315 |
316 option_restore_bad: | |
582 | 317 call option_reset_all ; Reset RAM contains |
318 goto option_save_all ; Then save to EEPROM | |
0 | 319 |
582 | 320 ;---- Proper restore |
0 | 321 option_restore_ok: |
582 | 322 movlw LOW(option_table_begin) |
323 movwf FSR0L | |
324 movlw HIGH(option_table_begin) | |
325 movwf FSR0H | |
0 | 326 |
327 option_restore_all_1: | |
582 | 328 movlw LOW(option_table_end) |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
329 cpfseq FSR0L |
582 | 330 bra option_restore_all_2 ; Not yet done... |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
331 movlw HIGH(option_table_end) |
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
332 cpfseq FSR0H |
582 | 333 bra option_restore_all_2 ; Not yet done... |
334 return ; All done. | |
562
8b7ea27ea1fa
seperate desat and sat multipliers for GF and Non-GF modes. Set to 100/100 as default in GF mode
heinrichsweikamp
parents:
560
diff
changeset
|
335 option_restore_all_2: |
582 | 336 rcall option_restore ; Restore one option. |
337 bra option_restore_all_1 ; and loop. | |
0 | 338 |
339 option_restore: | |
582 | 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. | |
0 | 344 |
582 | 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) | |
349 btfsc STATUS,C ; >256 | |
350 addlw .1 ; Yes: +1 | |
351 movwf EEADRH | |
0 | 352 |
582 | 353 movf opt_type,W ; Option type is string ? |
354 xorlw 2 | |
355 bz option_restore_string | |
0 | 356 |
582 | 357 ; Read one byte from EEPROM |
358 call read_eeprom | |
359 movff EEDATA, INDF1 ; And restore option register. | |
360 return | |
0 | 361 |
362 option_restore_string: | |
582 | 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 | |
0 | 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: | |
582 | 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 | |
0 | 388 |
582 | 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 | |
0 | 395 option_inc_1: |
582 | 396 movwf INDF1 |
397 | |
560 | 398 ; Now some rather crude hack into this routine to unify CCR & pSCR mode setting: |
582 | 399 movlw .25 ; EEPROM address of option oCCRMode |
400 cpfseq opt_eeprom ; skip next line if we deal with this option right now | |
401 bra option_inc_2 | |
402 btfsc FLAG_pscr_mode ; skip next line if we are not in PSCR mode | |
403 bcf opt_ccr_mode,1 ; in pSCR mode, opt_ccr_mode may only be 0 or 1 | |
560 | 404 |
405 option_inc_2: | |
533
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
406 ; Now some rather crude hack into this routine to make CCR Calibration more convenient: |
582 | 407 movlw .149 ; EEPROM address of option CalGasO2 |
408 cpfseq opt_eeprom ; skip next line if we deal with this option right now | |
533
dfac393b2199
CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents:
418
diff
changeset
|
409 return |
0 | 410 |
582 | 411 btfsc FLAG_pscr_mode ; skip next line if we are not in PSCR mode |
412 return | |
413 movlw .26 | |
414 cpfseq INDF1 ; skip next line if current option value is = 26 | |
415 return | |
416 movlw .95 ; current option value =26, advance it to 95 | |
417 movwf INDF1 | |
418 return | |
419 | |
0 | 420 |
582 | 421 option_inc_enum8: ; Always +1 |
422 incf INDF1,W | |
423 cpfsgt opt_max | |
424 clrf WREG | |
425 movwf INDF1 | |
426 return | |
427 | |
428 | |
429 option_inc_string: ; No editing yet... | |
430 return | |
0 | 431 |
432 ;============================================================================= | |
433 ; Strcat option into FSR2 buffer. | |
434 option_draw: | |
582 | 435 ; Read type, default and register from table |
436 rcall option_read | |
437 | |
438 ; Switch on type | |
439 movf opt_type,W | |
440 bz option_draw_uint8 | |
441 dcfsnz WREG | |
442 bra option_draw_enum8 | |
443 dcfsnz WREG | |
444 bra option_draw_string | |
445 return ; Unknown: return... | |
0 | 446 |
447 option_draw_uint8: | |
582 | 448 movff INDF1,lo ; Draw value. |
449 bsf leftbind | |
450 output_8 | |
451 bcf leftbind | |
452 clrf INDF2 ; Make sure to close string... | |
0 | 453 |
582 | 454 movf opt_unit+0,W ; Is there a unit to append ? |
455 iorwf opt_unit+1,W | |
456 rcall option_draw_unit | |
0 | 457 |
582 | 458 movf opt_default,W ; Default value |
459 cpfseq lo ; Current value | |
460 bra option_draw_uint8_2 ; Not default, add * | |
461 return ; Default, Done. | |
0 | 462 option_draw_uint8_2: |
582 | 463 PUTC "*" |
464 return ; Done. | |
0 | 465 |
466 option_draw_unit: | |
582 | 467 movff opt_unit+0,FSR1L |
468 movff opt_unit+1,FSR1H | |
469 goto strcat_text | |
0 | 470 |
471 | |
472 ;---- Draw an enumerated value (set of translated strings) | |
473 option_draw_enum8: | |
582 | 474 movf INDF1,W ; Get current value. |
475 cpfsgt opt_max ; Bound value | |
476 clrf WREG | |
477 addwf WREG ; *= 2 | |
478 addwf opt_inc,W ; Base text + 2 * value | |
479 movwf FSR1L | |
480 movlw .0 | |
481 addwfc opt_min,W ; Propagate carry | |
482 movwf FSR1H ; Into FSR1 | |
483 goto strcat_text | |
0 | 484 |
485 option_draw_string: | |
582 | 486 movff POSTINC1,POSTINC2 |
487 decfsz opt_max | |
488 bra option_draw_string | |
489 return | |
0 | 490 |
582 | 491 END |