comparison src/options.asm @ 623:c40025d8e750

3.03 beta released
author heinrichsweikamp
date Mon, 03 Jun 2019 14:01:48 +0200
parents d866684249bd
children cd58f7fc86db
comparison
equal deleted inserted replaced
622:02d1386429a6 623:c40025d8e750
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File options.asm REFACTORED VERSION V2.99g 3 ; File options.asm next combined generation V3.03-1
4 ; 4 ;
5 ; Manage all options data. 5 ; Manage all options data.
6 ; 6 ;
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
8 ;============================================================================= 8 ;=============================================================================
22 22
23 extern write_eeprom 23 extern write_eeprom
24 extern read_eeprom 24 extern read_eeprom
25 extern eeprom_serial_save,eeprom_opt_backup 25 extern eeprom_serial_save,eeprom_opt_backup
26 extern option_table_begin,option_table_end 26 extern option_table_begin,option_table_end
27 extern convert_meter_to_feet
27 28
28 options CODE 29 options CODE
29 30
30 ;============================================================================= 31 ;=============================================================================
31 ; Reset all options to factory defaults 32 ; Reset all options to factory defaults
77 ; 78 ;
78 ; INPUT: none 79 ; INPUT: none
79 ; OUTPUT: none 80 ; OUTPUT: none
80 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2 81 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2
81 ; 82 ;
82 global option_check_all ; check all options and reset options if out of min/max boundary 83 global option_check_all ; check all option and reset option if out of min/max boundary
83 option_check_all: 84 option_check_all:
85 bcf option_repaired ; no option needed repair up to now
84 movlw LOW(option_table_begin) ; point to option table begin 86 movlw LOW(option_table_begin) ; point to option table begin
85 movwf FSR0L 87 movwf FSR0L
86 movlw HIGH(option_table_begin) 88 movlw HIGH(option_table_begin)
87 movwf FSR0H 89 movwf FSR0H
88
89 option_check_all_1: 90 option_check_all_1:
90 movlw LOW(option_table_end) ; get low byte of end of table address 91 movlw LOW(option_table_end) ; get low byte of end of table address
91 cpfseq FSR0L ; does it equal the current pointer position? 92 cpfseq FSR0L ; does it equal the current pointer position?
92 bra option_check_all_2 ; NO - more options to process 93 bra option_check_all_2 ; NO - more options to process
93 movlw HIGH(option_table_end) ; get high byte of end of table address 94 movlw HIGH(option_table_end) ; get high byte of end of table address
95 bra option_check_all_2 ; NO - more options to process 96 bra option_check_all_2 ; NO - more options to process
96 bra option_check_all_3 ; YES to both - end of option table reached 97 bra option_check_all_3 ; YES to both - end of option table reached
97 option_check_all_2: 98 option_check_all_2:
98 rcall option_check ; check one option... 99 rcall option_check ; check one option...
99 bra option_check_all_1 ; ... and loop 100 bra option_check_all_1 ; ... and loop
100
101 option_check_all_3: 101 option_check_all_3:
102 bsf FLAG_diluent_setup ; setup checking diluents 102 bsf is_diluent_menu ; setup checking diluents
103 call gaslist_cleanup_list ; check and correct multiple or none First diluent 103 call gaslist_cleanup_list ; check and correct multiple or none First diluent
104 bcf FLAG_diluent_setup ; setup checking gases 104 bcf is_diluent_menu ; setup checking gases
105 call gaslist_cleanup_list ; check and correct multiple or none First gas 105 call gaslist_cleanup_list ; check and correct multiple or none First gas
106 call option_cleanup_oCCRMode ; check and correct sensor mode 106 IFDEF _ccr_pscr
107 call option_cleanup_oCCRMode ; check and correct CCR / pSCR mode
108 ENDIF
107 call option_cleanup_GF ; check and correct GFlow <= GFhigh 109 call option_cleanup_GF ; check and correct GFlow <= GFhigh
108 return ; all done 110 return ; all done
111
112
109 113
110 ;============================================================================= 114 ;=============================================================================
111 ; Read option handle 115 ; Read option handle
112 ; INPUT: FSR0 = option handle 116 ; INPUT: FSR0 = option handle
113 ; OUTPUT: FSR1 = address of variable. 117 ; OUTPUT: FSR1 = address of variable.
114 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1 118 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
115 ; 119 ;
116 option_read: 120 option_read:
117 movff FSR0L,TBLPTRL 121 movff FSR0L,TBLPTRL ; set memory address of option data set, low byte
118 movlw HIGH(option_table_begin) ; get 8 high bits. 122 movlw HIGH(option_table_begin) ; get table begin address, high byte
119 andlw 0xF0 ; keep only the 4 highest ones 123 andlw 0xF0 ; keep only the upper nibble
120 iorwf FSR0H,W ; cat with the known 4 lower ones 124 iorwf FSR0H,W ; add the memory address of the option data set, high byte
121 movwf TBLPTRH ; we have the high byte 125 movwf TBLPTRH ; set the resulting memory address, high byte
122 movlw UPPER(option_table_begin) 126 movlw UPPER(option_table_begin) ; get table begin address, upper byte
123 movwf TBLPTRU 127 movwf TBLPTRU ; set memory address of option data set, upper byte
124 128
125 ; Read type, default and register from table 129 ; Read type, default and register from table
126 tblrd*+ 130 tblrd*+
127 movff TABLAT,opt_type 131 movff TABLAT,opt_type
128 tblrd*+ 132 tblrd*+
141 movff TABLAT,opt_unit+1 145 movff TABLAT,opt_unit+1
142 tblrd*+ 146 tblrd*+
143 movff TABLAT,FSR1L 147 movff TABLAT,FSR1L
144 tblrd*+ 148 tblrd*+
145 movff TABLAT,FSR1H 149 movff TABLAT,FSR1H
146 movff TBLPTRL,FSR0L ; advance handle, too, for reset_all 150 movff TBLPTRL,FSR0L ; advance handle to next option data set (used for reset_all)
147 movff TBLPTRH,FSR0H 151 movff TBLPTRH,FSR0H
148 return 152 return
149 153
150 ;============================================================================= 154 ;=============================================================================
151 ; Check one option and reset if it's out of it's min/max boundaries 155 ; Check one option and reset if it's out of it's min/max boundaries
157 ; Read type, default and register from table 161 ; Read type, default and register from table
158 rcall option_read 162 rcall option_read
159 163
160 ; Switch on type 164 ; Switch on type
161 movf opt_type,W ; get option type 165 movf opt_type,W ; get option type
162 xorlw 2 ; type == STRING ? 166 xorlw .2 ; type == STRING ?
163 bz option_check_string ; YES 167 bz option_check_string ; YES
164 movf opt_type,W ; get option type (again) 168 movf opt_type,W ; get option type (again)
165 xorlw 1 ; type == ENUM8 ? 169 xorlw .1 ; type == ENUM8 ?
166 bz option_check_enum8 ; YES - check if lower then max. value only 170 bz option_check_enum8 ; YES - check if lower then max. value only
167 ; NO to all - must be integer then 171 ; NO to all - must be integer then
168 tstfsz opt_min ; opt_min = 0 ? 172 tstfsz opt_min ; opt_min = 0 ?
169 bra option_check_both ; NO - check it 173 bra option_check_both ; NO - check it
170 bra option_check_enum8 ; check max only 174 bra option_check_enum8 ; check max only
171 175
172 option_check_both: 176 option_check_both:
173 decf opt_min,W ; check against minimum value 177 decf opt_min,W ; check against minimum value
174 cpfsgt INDF1 ; bigger then opt_min - 1 ? 178 cpfsgt INDF1 ; bigger than opt_min - 1 ?
175 bra option_check_reset ; NO - reset option 179 bra option_check_reset ; NO - reset option
176 option_check_enum8: ; check against maximum value 180 option_check_enum8: ; check against maximum value
177 infsnz opt_max,W ; max = 255? 181 infsnz opt_max,W ; max = 255?
178 return ; YES - ignore the max. test 182 return ; YES - ignore the max. test
179 cpfslt INDF1 ; NO - smaller then opt_max + 1 ? 183 cpfslt INDF1 ; NO - smaller then opt_max + 1 ?
180 bra option_check_reset ; NO - reset option 184 bra option_check_reset ; NO - reset option
181 return ; YES - in range, return 185 return ; YES - within range, return
182 186
183 option_check_reset: 187 option_check_reset:
184 movff opt_default,INDF1 ; reset option to default 188 movff opt_default,INDF1 ; reset option to default
189 bsf option_repaired ; flag that an option was repaired
185 return ; done 190 return ; done
186 191
187 option_check_string: 192 option_check_string:
188 return 193 return
189 194
268 addlw .1 ; YES - +1 273 addlw .1 ; YES - +1
269 movwf EEADRH 274 movwf EEADRH
270 movf opt_type,W ; get option type 275 movf opt_type,W ; get option type
271 xorlw 2 ; option type is string ? 276 xorlw 2 ; option type is string ?
272 bz option_save_string ; YES 277 bz option_save_string ; YES
273 movff INDF1,EEDATA ; one byte to be saved to EEPROM 278 movff INDF1,EEDATA ; NO - one byte to be saved to EEPROM
274 btfss EEADRH,1 ; EEADR:EEADRH < 512 ? 279 btfss EEADRH,1 ; - EEADR:EEADRH < 512 ?
275 call write_eeprom ; YES - write 280 call write_eeprom ; YES - write
276 return 281 return ; (NO) - done
277 option_save_string: 282 option_save_string:
278 movff POSTINC1,EEDATA ; write one byte 283 movff POSTINC1,EEDATA ; write one byte
279 btfss EEADRH,1 ; EEADR:EEADRH < 512 ? 284 btfss EEADRH,1 ; EEADR:EEADRH < 512 ?
280 call write_eeprom ; Yes - write 285 call write_eeprom ; YES - write
281 infsnz EEADR,F 286 infsnz EEADR,F ; (NO) - increment EEPROM address
282 incf EEADRH,F 287 incf EEADRH,F ; - ...
283 decfsz opt_max ; decrement string length 288 decfsz opt_max ; - decrement string length, done?
284 bra option_save_string ; loop while not finished 289 bra option_save_string ; NO - loop
285 return 290 return ; YES
286 291
287 ;============================================================================= 292 ;=============================================================================
288 293
289 global option_restore_all ; restore options from EEPROM 294 global option_restore_all ; restore options from EEPROM
290 option_restore_all: 295 option_restore_all:
438 incf INDF1,W 443 incf INDF1,W
439 cpfsgt opt_max 444 cpfsgt opt_max
440 clrf WREG 445 clrf WREG
441 movwf INDF1 446 movwf INDF1
442 option_inc_enum8_1: 447 option_inc_enum8_1:
448 IFDEF _ccr_pscr
443 ; Now some rather crude hack into this routine to unify CCR & pSCR mode setting 449 ; Now some rather crude hack into this routine to unify CCR & pSCR mode setting
444 movlw .25 ; EEPROM address of option oCCRMode 450 movlw .25 ; EEPROM address of option oCCRMode
445 cpfseq opt_eeprom ; editing oCCRMode right now? 451 cpfseq opt_eeprom ; editing oCCRMode right now?
446 bra option_inc_enum8_2 ; NO - check next option 452 bra option_inc_enum8_2 ; NO - check next option
453 IFDEF _external_sensor
447 btfsc analog_o2_input ; YES - does hosting OSTC have an analog interface? 454 btfsc analog_o2_input ; YES - does hosting OSTC have an analog interface?
448 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed 455 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed
449 btfsc optical_input ; does hosting OSTC have an optical interface? 456 btfsc optical_input ; does hosting OSTC have an optical interface?
450 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed 457 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed
458 ENDIF ; _external_sensor
451 movf INDF1,W ; NO to both - get mode (=0: fixed SP, =1: Sensor, =2: AutoSP) 459 movf INDF1,W ; NO to both - get mode (=0: fixed SP, =1: Sensor, =2: AutoSP)
452 xorlw .1 ; - in sensor mode? 460 xorlw .1 ; - in sensor mode?
453 bnz option_inc_enum8_1a ; NO - continue with next check 461 bnz option_inc_enum8_1a ; NO - continue with next check
454 incf INDF1,F ; YES - advance option value to AutoSP 462 incf INDF1,F ; YES - advance option value to AutoSP
455 option_inc_enum8_1a: 463 option_inc_enum8_1a:
457 xorlw .4 ; in pSCR mode? 465 xorlw .4 ; in pSCR mode?
458 bnz option_inc_enum8_1_exit ; NO - done 466 bnz option_inc_enum8_1_exit ; NO - done
459 bcf INDF1,1 ; YES - clear bit 1 because opt_ccr_mode may only be 0 or 1 (reverts AutoSP to calculated SP) 467 bcf INDF1,1 ; YES - clear bit 1 because opt_ccr_mode may only be 0 or 1 (reverts AutoSP to calculated SP)
460 option_inc_enum8_1_exit: 468 option_inc_enum8_1_exit:
461 return ; done 469 return ; done
470 ENDIF ; _ccr_pscr
462 option_inc_enum8_2: 471 option_inc_enum8_2:
463 ; (unused) 472 ; (unused)
464 option_inc_enum8_3: 473 option_inc_enum8_3:
465
466 IFDEF _rx_functions
467 global option_cleanup_oTrMode_CCR ; embedded clean-up entry-point
468 global option_cleanup_oTrMode_no_CCR ; embedded clean-up entry-point
469 ; Now some rather crude hack to correct opt_TR_mode in dependency of opt_dive_mode 474 ; Now some rather crude hack to correct opt_TR_mode in dependency of opt_dive_mode
470 movlw .8 ; EEPROM address of option opt_dive_mode 475 movlw .8 ; EEPROM address of option opt_dive_mode
471 cpfseq opt_eeprom ; editing opt_dive_mode right now? 476 cpfseq opt_eeprom ; editing opt_dive_mode right now?
472 bra option_inc_enum8_4 ; NO - check next option 477 bra option_inc_enum8_4 ; NO - check next option
473 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR 478 movf INDF1,W ; YES - get option value: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
474 decfsz WREG,W ; dive mode = 1 CCR? 479 xorlw .1 ; in CCR mode?
475 bra option_inc_enum8_3a ; NO - in any other mode 480 bnz option_inc_enum8_3a ; NO - in some other mode
481 IFNDEF _ccr_pscr
482 incf INDF1,f ; YES - no CCR mode compiled in, advance to gauge mode
483 bra option_inc_enum8_3_exit ; - done
484 ENDIF ; _ccr_pscr
485 IFDEF _rx_functions
486 global option_cleanup_oTrMode_CCR ; embedded clean-up entry-point
476 option_cleanup_oTrMode_CCR: ; entry point from cleanup during restart 487 option_cleanup_oTrMode_CCR: ; entry point from cleanup during restart
477 movff opt_TR_mode,WREG ; YES - get TR mode 488 movff opt_TR_mode,WREG ; get TR mode
478 xorlw .2 ; - mode = 2 (ind.double)? 489 xorlw .2 ; mode = 2 (ind.double)?
479 bnz option_inc_enum8_3_exit ; NO - done 490 bnz option_inc_enum8_3_exit ; NO - done
480 bra option_inc_enum8_3_reset ; YES - revert mode to 1 (on) 491 bra option_inc_enum8_3_reset ; YES - revert mode to 1 (on)
492 ENDIF ; _rx_functions
481 option_inc_enum8_3a: ; any mode other than CCR 493 option_inc_enum8_3a: ; any mode other than CCR
494 IFNDEF _ccr_pscr
495 movf INDF1,W ; get option value: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
496 xorlw .4 ; in pSCR mode?
497 bnz option_inc_enum8_3b ; NO - in some other mode
498 clrf INDF1 ; YES - no pSCR mode compiled in, advance to 0 "OC"
499 bra option_inc_enum8_3_exit ; - done
500 ENDIF ; _ccr_pscr
501 option_inc_enum8_3b:
502 global option_cleanup_oTrMode_no_CCR ; embedded clean-up entry-point
482 option_cleanup_oTrMode_no_CCR: ; entry point from cleanup during restart 503 option_cleanup_oTrMode_no_CCR: ; entry point from cleanup during restart
483 movff opt_TR_mode,WREG ; get TR mode 504 movff opt_TR_mode,WREG ; get TR mode
484 xorlw .3 ; mode = 3 (CCR Dil+O2)? 505 xorlw .3 ; mode = 3 (CCR Dil+O2)?
485 bnz option_inc_enum8_3_exit ; NO - done 506 bnz option_inc_enum8_3_exit ; NO - done
486 option_inc_enum8_3_reset: ; YES - revert to mode 1 (on) 507 option_inc_enum8_3_reset: ; YES - revert to mode 1 (on)
487 movlw .1 ; load coding of mode "on" 508 movlw .1 ; load coding of mode "on"
488 movff WREG,opt_TR_mode ; write to option 509 movff WREG,opt_TR_mode ; write to option
489 option_inc_enum8_3_exit: 510 option_inc_enum8_3_exit:
490 return ; done 511 return ; done
491 option_inc_enum8_4: 512 option_inc_enum8_4:
513 IFDEF _rx_functions
492 ; Now some rather crude hack to advance opt_TR_mode in dependency of opt_dive_mode 514 ; Now some rather crude hack to advance opt_TR_mode in dependency of opt_dive_mode
493 movlw .222 ; EEPROM address of option opt_TR_mode 515 movlw .222 ; EEPROM address of option opt_TR_mode
494 cpfseq opt_eeprom ; editing opt_TR_mode right now? 516 cpfseq opt_eeprom ; editing opt_TR_mode right now?
495 bra option_inc_enum8_5 ; NO - check next option 517 bra option_inc_enum8_5 ; NO - check next option
496 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR 518 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
506 xorlw .3 ; mode = 3 (CCR Dil+O2)? 528 xorlw .3 ; mode = 3 (CCR Dil+O2)?
507 bnz option_inc_enum8_4_exit ; NO - done 529 bnz option_inc_enum8_4_exit ; NO - done
508 clrf INDF1 ; YES - advance option value to 0 "off" 530 clrf INDF1 ; YES - advance option value to 0 "off"
509 option_inc_enum8_4_exit: 531 option_inc_enum8_4_exit:
510 return ; done 532 return ; done
511 ENDIF 533 ENDIF ; _rx_functions
512
513 option_inc_enum8_5: 534 option_inc_enum8_5:
514 return 535 return
515 536
516 537
517 option_inc_string: ; no editing available 538 option_inc_string: ; no editing available
518 return 539 return
519 540
520 541
542 IFDEF _ccr_pscr
521 global option_cleanup_oCCRMode 543 global option_cleanup_oCCRMode
522 global option_cleanup_oCCRMode_pSCR 544 global option_cleanup_oCCRMode_pSCR
523 global option_cleanup_oCCRMode_CCR 545 global option_cleanup_oCCRMode_CCR
524 option_cleanup_oCCRMode: ; in pSCR mode, revert AutoSP (2) to calculated SP (0), in pSCR and CCR revert Sensor to fixed SP if no sensor interface available 546 option_cleanup_oCCRMode: ; in pSCR mode, revert AutoSP (2) to calculated SP (0), in pSCR and CCR revert Sensor to fixed SP if no sensor interface available
525 banksel opt_dive_mode ; select options bank 547 movff opt_dive_mode,WREG ; get dive mode into WREG (0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR)
526 movf opt_dive_mode,W ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
527 xorlw .4 ; in pSCR mode? 548 xorlw .4 ; in pSCR mode?
528 bnz option_cleanup_oCCRMode_CCR ; NO - check if sensor is available on hosting OSTC 549 bnz option_cleanup_oCCRMode_CCR ; NO - check if sensor is available on hosting OSTC
529 option_cleanup_oCCRMode_pSCR: ; jump-in from start.asm if known to be in pSCR mode 550 option_cleanup_oCCRMode_pSCR: ; jump-in from start.asm if known to be in pSCR mode
530 banksel opt_ccr_mode ; select options bank 551 banksel opt_ccr_mode ; YES - select options bank
531 bcf opt_ccr_mode,1 ; YES - clear bit 1 because opt_ccr_mode may only be 0 or 1 (reverts AutoSP to calculated SP) 552 bcf opt_ccr_mode,1 ; - clear bit 1 because opt_ccr_mode may only be 0 or 1 (reverts AutoSP to calculated SP, keeps sensor)
553 banksel common ; - back to bank common
554 bsf option_repaired ; - flag that an option was repaired
532 option_cleanup_oCCRMode_CCR: ; continue from above & jump-in from start.asm if known to be in CCR mode 555 option_cleanup_oCCRMode_CCR: ; continue from above & jump-in from start.asm if known to be in CCR mode
533 banksel common ; flags are located in bank common 556 IFDEF _external_sensor
534 btfsc analog_o2_input ; does hosting OSTC have an analog interface? 557 btfsc analog_o2_input ; analog interface available?
535 bra option_cleanup_oCCRMode_exit ; YES - setting 'sensor' allowed 558 return ; YES - setting 'sensor' allowed
536 btfsc optical_input ; does hosting OSTC have an optical interface? 559 btfsc optical_input ; does hosting OSTC have an optical interface?
537 bra option_cleanup_oCCRMode_exit ; YES - setting 'sensor' allowed 560 return ; YES - setting 'sensor' allowed
538 banksel opt_ccr_mode ; NO to both - select options bank 561 ENDIF
539 movf opt_ccr_mode,W ; - get CCR mode 562 movff opt_ccr_mode,WREG ; NO to both - get CCR mode
540 xorlw .1 ; - CCR mode = sensor? 563 xorlw .1 ; - coding for sensor
541 bnz option_cleanup_oCCRMode_exit ; NO - ok 564 tstfsz WREG ; - CCR mode = sensor?
542 clrf opt_ccr_mode ; - YES - set CCR mode to fixed SP (0) 565 return ; NO - setting allowed
543 option_cleanup_oCCRMode_exit: 566 banksel opt_ccr_mode ; YES - setting not allowed, select options bank
544 banksel common ; back to bank common 567 clrf opt_ccr_mode ; - revert setting to 0 (fixed or calculated SP)
545 return ; done 568 banksel common ; - back to bank common
569 bsf option_repaired ; - flag that an option was repaired
570 return ; - done
571 ENDIF ; _ccr_pscr
572
546 573
547 option_cleanup_GF: 574 option_cleanup_GF:
548 ; cleanup normal GF 575 ; cleanup normal GF
549 movff opt_GF_high,WREG ; copy normal GF high to WREG 576 movff opt_GF_high,WREG ; copy normal GF high to WREG
550 movff opt_GF_low,lo ; copy normal GF low to lo 577 movff opt_GF_low,mpr ; copy normal GF low to mpr
551 cpfsgt lo ; GF low > GF high ? 578 cpfsgt mpr ; GF low > GF high ?
552 bra option_cleanup_GF_2 ; NO - option ok, check next option 579 bra option_cleanup_GF_2 ; NO - option ok, check next option
553 movwf lo ; YES - copy GF high to lo 580 movwf mpr ; YES - copy GF high to mpr
554 movlw .100 ; - load GF low limit of 100% into WREG 581 movlw .100 ; - load GF low limit of 100% into WREG
555 cpfsgt lo ; - lo > 100 ? 582 cpfsgt mpr ; - mpr > 100 ?
556 bra option_cleanup_GF_1 ; NO - correct GF low to GF high 583 bra option_cleanup_GF_1 ; NO - correct GF low to GF high
557 movwf lo ; YES - correct GF low to 100% 584 movwf mpr ; YES - correct GF low to 100%
558 option_cleanup_GF_1: 585 option_cleanup_GF_1:
559 movff lo,opt_GF_low ; store corrected GF low 586 movff mpr,opt_GF_low ; store corrected GF low
587 bsf option_repaired ; flag that an option was repaired
560 option_cleanup_GF_2: 588 option_cleanup_GF_2:
561 ; cleanup alternative GF 589 ; cleanup alternative GF
562 movff opt_aGF_high,WREG ; copy alternative GF high to WREG 590 movff opt_aGF_high,WREG ; copy alternative GF high to WREG
563 movff opt_aGF_low,lo ; copy alternative GF low to lo 591 movff opt_aGF_low,mpr ; copy alternative GF low to mpr
564 cpfsgt lo ; GF low > GF high ? 592 cpfsgt mpr ; GF low > GF high ?
565 bra option_cleanup_GF_4 ; NO - option ok, check next option 593 bra option_cleanup_GF_4 ; NO - option ok, check next option
566 movwf lo ; YES - copy GF high to lo 594 movwf mpr ; YES - copy GF high to mpr
567 movlw .100 ; - load GF low limit of 100% into WREG 595 movlw .100 ; - load GF low limit of 100% into WREG
568 cpfsgt lo ; - lo > 100 ? 596 cpfsgt mpr ; - mpr > 100 ?
569 bra option_cleanup_GF_3 ; NO - correct GF low to GF high 597 bra option_cleanup_GF_3 ; NO - correct GF low to GF high
570 movwf lo ; YES - correct GF low to 100% 598 movwf mpr ; YES - correct GF low to 100%
571 option_cleanup_GF_3: 599 option_cleanup_GF_3:
572 movff lo,opt_aGF_low ; store corrected GF low 600 movff mpr,opt_aGF_low ; store corrected GF low
601 bsf option_repaired ; flag that an option was repaired
573 option_cleanup_GF_4: 602 option_cleanup_GF_4:
574 return ; done 603 return ; done
575 604
576 605
577 ;============================================================================= 606 ;=============================================================================
582 ; Read type, default and register from table 611 ; Read type, default and register from table
583 rcall option_read 612 rcall option_read
584 613
585 ; Switch on type 614 ; Switch on type
586 movf opt_type,W 615 movf opt_type,W
587 bz option_draw_uint8 616 bz option_draw_uint8 ; type0 = INT8
588 dcfsnz WREG 617 dcfsnz WREG
589 bra option_draw_enum8 618 bra option_draw_enum8 ; type1 = ENUM
590 dcfsnz WREG 619 dcfsnz WREG
591 bra option_draw_string 620 bra option_draw_string ; type2 = string
621 dcfsnz WREG
622 bra option_draw_uint8_depth ; type3 = INT8 with automatic display in meters or feet
592 return ; unknown, return 623 return ; unknown, return
624
593 option_draw_string: 625 option_draw_string:
594 movff POSTINC1,POSTINC2 626 movff POSTINC1,POSTINC2
595 decfsz opt_max 627 decfsz opt_max
596 bra option_draw_string 628 bra option_draw_string
597 return 629 return
598 630
631 option_draw_uint8_depth:
632 TSTOSS opt_units ; using metric units (0=m, 1=ft)?
633 bra option_draw_uint8 ; YES - handle with standard output
634 movff INDF1,lo ; NO - imperial, get value to lo
635 call convert_meter_to_feet ; - convert value in lo from meter to feet
636 bsf leftbind ; - print with left alignment
637 output_16_3 ; - display only last three digits from a 16 bit value (0-999)
638 bcf leftbind ; - back to normal alignment
639 STRCAT_TEXT tFeets ; - print unit
640 bra option_draw_uint8_common ; - continue with common part
599 641
600 option_draw_uint8: 642 option_draw_uint8:
601 movff INDF1,lo ; draw value 643 movff INDF1,lo ; draw value
602 bsf leftbind 644 bsf leftbind
603 output_8 645 output_8
604 bcf leftbind 646 bcf leftbind
605 clrf INDF2 ; make sure to close string 647 clrf INDF2 ; make sure to close string
606 movf opt_unit+0,W ; is there a unit to append? 648 movf opt_unit+0,W ; is there a unit to append?
607 iorwf opt_unit+1,W 649 iorwf opt_unit+1,W
608 rcall option_draw_unit ; YES 650 rcall option_draw_unit ; YES
651 option_draw_uint8_common:
609 movf opt_default,W ; get default value 652 movf opt_default,W ; get default value
610 cpfseq lo ; compare with current value, equal? 653 cpfseq lo ; compare with current value, equal?
611 bra option_draw_uint8_2 ; NO - not default, add * 654 bra option_draw_uint8_2 ; NO - not default, add *
612 return ; YES - default, done 655 return ; YES - default, done
613 option_draw_uint8_2: 656 option_draw_uint8_2:
614 PUTC "*" ; print "*" 657 PUTC "*" ; print "*"
615 return ; done 658 return ; done
659
616 option_draw_unit: 660 option_draw_unit:
617 movff opt_unit+0,FSR1L 661 movff opt_unit+0,FSR1L
618 movff opt_unit+1,FSR1H 662 movff opt_unit+1,FSR1H
619 goto strcat_text 663 goto strcat_text
620 664
630 movlw .0 674 movlw .0
631 addwfc opt_min,W ; propagate carry... 675 addwfc opt_min,W ; propagate carry...
632 movwf FSR1H ; ...into FSR1 676 movwf FSR1H ; ...into FSR1
633 goto strcat_text 677 goto strcat_text
634 678
679 ;-----------------------------------------------------------------------------
635 680
636 END 681 END