annotate src/options.asm @ 605:5ce603c29750

gas color coding fixed
author heinrichsweikamp
date Sun, 25 Nov 2018 13:21:52 +0100
parents ca4556fb60b9
children d866684249bd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
3 ; File options.asm REFACTORED VERSION V2.99e
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Manage all options data.
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-07-12 : [jDG] Creation.
heinrichsweikamp
parents:
diff changeset
11 ;
heinrichsweikamp
parents:
diff changeset
12
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
13 #include "hwos.inc" ; mandatory header
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
14 #include "strings.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
15 #include "convert.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
16 #include "ghostwriter.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
17 #include "eeprom_rs232.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
18 #include "external_flash.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
19 #include "wait.inc"
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
20 #include "shared_definitions.h"
0
heinrichsweikamp
parents:
diff changeset
21
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
22 extern write_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
23 extern read_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
24 extern eeprom_serial_save,eeprom_opt_backup
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
25 extern option_table_begin,option_table_end
0
heinrichsweikamp
parents:
diff changeset
26
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
27 options CODE
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
28
0
heinrichsweikamp
parents:
diff changeset
29 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
30 ; Reset all options to factory defaults
0
heinrichsweikamp
parents:
diff changeset
31 ;
heinrichsweikamp
parents:
diff changeset
32 ; INPUT: none
heinrichsweikamp
parents:
diff changeset
33 ; OUTPUT: none
heinrichsweikamp
parents:
diff changeset
34 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
35 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
36 global option_reset_all ; reset all options to factory default
0
heinrichsweikamp
parents:
diff changeset
37 option_reset_all:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
38 clrf EEADRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
39 read_int_eeprom .2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
40 tstfsz EEDATA ; number of total dives = 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
41 bra option_reset_all2 ; NO - skip resetting logbook
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
42 read_int_eeprom .3
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
43 tstfsz EEDATA ; number of total dives = 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
44 bra option_reset_all2 ; NO - skip resetting logbook
0
heinrichsweikamp
parents:
diff changeset
45
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
46 clrf EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
47 write_int_eeprom .4
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
48 write_int_eeprom .5
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
49 write_int_eeprom .6
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
50 write_int_eeprom .2 ; delete total dive counter, too
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
51 write_int_eeprom .3
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
52 call ext_flash_erase_logbook ; complete logbook
0
heinrichsweikamp
parents:
diff changeset
53
heinrichsweikamp
parents:
diff changeset
54 option_reset_all2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
55 clrf lo
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
56 clrf hi
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
57 call do_logoffset_common_write ; reset logbook offset
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
58 movlw LOW(option_table_begin) ; point to option table begin
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
59 movwf FSR0L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
60 movlw HIGH(option_table_begin)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
61 movwf FSR0H
0
heinrichsweikamp
parents:
diff changeset
62 option_reset_all_1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
63 movlw LOW(option_table_end) ; get low byte of end of table address
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
64 cpfseq FSR0L ; does it equal the current pointer position?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
65 bra option_reset_all_2 ; NO - more options to process
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
66 movlw HIGH(option_table_end) ; get high byte of end of table address
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
67 cpfseq FSR0H ; does it equal the current pointer position?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
68 bra option_reset_all_2 ; NO - more options to process
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
69 return ; YES to both - end of option table reached, 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
70 option_reset_all_2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
71 rcall option_reset ; reset one option...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
72 bra option_reset_all_1 ; ... and loop
0
heinrichsweikamp
parents:
diff changeset
73
heinrichsweikamp
parents:
diff changeset
74 ;=============================================================================
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
75 ; 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
76 ;
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
77 ; INPUT: none
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
78 ; OUTPUT: none
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
79 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
80 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
81 global option_check_all ; check all option and reset option if out of min/max boundary
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
82 option_check_all:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
83 movlw LOW(option_table_begin) ; point to option table begin
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
84 movwf FSR0L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
85 movlw HIGH(option_table_begin)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
86 movwf FSR0H
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
87
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
88 option_check_all_1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
89 movlw LOW(option_table_end) ; get low byte of end of table address
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
90 cpfseq FSR0L ; does it equal the current pointer position?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
91 bra option_check_all_2 ; NO - more options to process
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
92 movlw HIGH(option_table_end) ; get high byte of end of table address
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
93 cpfseq FSR0H ; does it equal the current pointer position?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
94 bra option_check_all_2 ; NO - more options to process
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
95 return ; YES to both - end of option table reached, 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
96 option_check_all_2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
97 rcall option_check ; check one option...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
98 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
99
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
100 ;=============================================================================
0
heinrichsweikamp
parents:
diff changeset
101 ; Read option handle
heinrichsweikamp
parents:
diff changeset
102 ; INPUT: FSR0 = option handle
heinrichsweikamp
parents:
diff changeset
103 ; OUTPUT: FSR1 = address of variable.
heinrichsweikamp
parents:
diff changeset
104 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
105 ;
0
heinrichsweikamp
parents:
diff changeset
106 option_read:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
107 movff FSR0L,TBLPTRL
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
108 movlw HIGH(option_table_begin) ; get 8 high bits.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
109 andlw 0xF0 ; keep only the 4 highest ones
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
110 iorwf FSR0H,W ; cat with the known 4 lower ones
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
111 movwf TBLPTRH ; we have the high byte
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
112 movlw UPPER(option_table_begin)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
113 movwf TBLPTRU
0
heinrichsweikamp
parents:
diff changeset
114
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
115 ; Read type, default and register from table
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
116 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
117 movff TABLAT,opt_type
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
118 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
119 movff TABLAT,opt_default
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
120 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
121 movff TABLAT,opt_inc
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
122 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
123 movff TABLAT,opt_min
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
124 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
125 movff TABLAT,opt_max
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
126 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
127 movff TABLAT,opt_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
128 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
129 movff TABLAT,opt_unit+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
130 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
131 movff TABLAT,opt_unit+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
132 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
133 movff TABLAT,FSR1L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
134 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
135 movff TABLAT,FSR1H
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
136 movff TBLPTRL,FSR0L ; advance handle, too, for reset_all
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
137 movff TBLPTRH,FSR0H
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
138 return
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
139
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
140 ;=============================================================================
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
141 ; 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
142 ; INPUT: FSR0 = option handle
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
143 ; OUTPUT: none
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
144 ; 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
145 ;
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
146 option_check:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
147 ; Read type, default and register from table
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
148 rcall option_read
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
149
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
150 ; Switch on type
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
151 movf opt_type,W ; get option type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
152 xorlw 2 ; type == STRING ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
153 bz option_check_string ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
154 movf opt_type,W ; get option type (again)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
155 xorlw 1 ; type == ENUM8 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
156 bz option_check_enum8 ; YES - check if lower then max. value only
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
157 ; NO to all - must be integer then
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
158 tstfsz opt_min ; opt_min = 0 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
159 bra option_check_both ; NO - check it
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
160 bra option_check_enum8 ; check max only
220
effd7259f5a5 make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents: 185
diff changeset
161
effd7259f5a5 make button sensitivity configurable (cR hardware)
heinrichsweikamp
parents: 185
diff changeset
162 option_check_both:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
163 decf opt_min,W ; check against minimum value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
164 cpfsgt INDF1 ; bigger then opt_min - 1 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
165 bra option_check_reset ; NO - reset option
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
166 option_check_enum8: ; check against maximum value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
167 infsnz opt_max,W ; max = 255?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
168 return ; YES - ignore the max. test
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
169 cpfslt INDF1 ; NO - smaller then opt_max + 1 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
170 bra option_check_reset ; NO - reset option
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
171 return ; YES - in range, return
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
172
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
173 option_check_reset:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
174 movff opt_default,INDF1 ; reset option to default
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
175 return ; done
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
176
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
177 option_check_string:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
178 return
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
179
0
heinrichsweikamp
parents:
diff changeset
180 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
181 ; Reset an option to its default value
0
heinrichsweikamp
parents:
diff changeset
182 ; INPUT: FSR0 = option handle
heinrichsweikamp
parents:
diff changeset
183 ; OUTPUT: none
heinrichsweikamp
parents:
diff changeset
184 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2
heinrichsweikamp
parents:
diff changeset
185 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
186 global option_reset ; reset FSR0 option to factory default
0
heinrichsweikamp
parents:
diff changeset
187 option_reset:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
188 ; Read type, default and register from table
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
189 rcall option_read ; read option data
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
190 movf opt_type,W ; get option type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
191 xorlw 2 ; Type == STRING ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
192 bz opt_reset_string ; YES - special copy
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
193 movff opt_default,INDF1 ; NO - just a 8 bit indirect copy
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
194 return
0
heinrichsweikamp
parents:
diff changeset
195 opt_reset_string:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
196 movff FSR1L,FSR2L ; set string destination address
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
197 movff FSR1H,FSR2H ; ...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
198 movff opt_default+0,FSR1L ; get handle to multi-lingual text in FSR1
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
199 movff opt_default+1,FSR1H ; ...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
200 movff TBLPTRL,opt_backup_tbl+0 ; TBLPTR trashed by text routine...
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
201 movff TBLPTRH,opt_backup_tbl+1 ; ...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
202 movff TBLPTRU,opt_backup_tbl+2 ; ...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
203 call strcat_text ; copy translated text to FSR2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
204 movff opt_backup_tbl+0,TBLPTRL ; restore TBLPTR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
205 movff opt_backup_tbl+1,TBLPTRH ; ...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
206 movff opt_backup_tbl+2,TBLPTRU ; ...
0
heinrichsweikamp
parents:
diff changeset
207
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
208 return
0
heinrichsweikamp
parents:
diff changeset
209
heinrichsweikamp
parents:
diff changeset
210 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
211 ; Save all options to EEPROM
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
212 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
213 global option_save_all ; save options to EEPROM
0
heinrichsweikamp
parents:
diff changeset
214 option_save_all:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
215 ;---- Save option serial into EEPROM to detect reset and new version
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
216 movlw LOW(eeprom_serial_save)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
217 movwf EEADR
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
218 movlw HIGH(eeprom_serial_save)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
219 movwf EEADRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
220 movlw LOW(eeprom_opt_serial)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
221 movwf EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
222 call write_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
223 incf EEADR,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
224 movlw HIGH(eeprom_opt_serial)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
225 movwf EEDATA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
226 call write_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
227
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
228 ;---- Save all options
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
229 movlw LOW(option_table_begin)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
230 movwf FSR0L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
231 movlw HIGH(option_table_begin)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
232 movwf FSR0H
0
heinrichsweikamp
parents:
diff changeset
233
heinrichsweikamp
parents:
diff changeset
234 option_save_all_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
235 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
236 cpfseq FSR0L
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
237 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
238 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
239 cpfseq FSR0H
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
240 bra option_save_all_2 ; not yet done...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
241 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
242 option_save_all_2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
243 rcall option_save ; save one option...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
244 bra option_save_all_1 ; ...and loop
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
245
0
heinrichsweikamp
parents:
diff changeset
246
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
247 global option_save
0
heinrichsweikamp
parents:
diff changeset
248 option_save:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
249 rcall option_read
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
250 incf opt_eeprom,W ; should we save it ?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
251 btfsc STATUS,Z ; EEPROM address is FFh ?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
252 return ; YES - nothing to do
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
253 movf opt_eeprom,W ; compute backup address in EEPROM
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
254 addlw LOW(eeprom_opt_backup) ; add offset
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
255 movwf EEADR
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
256 movlw HIGH(eeprom_opt_backup)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
257 btfsc STATUS,C ; > 256 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
258 addlw .1 ; YES - +1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
259 movwf EEADRH
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
260 movf opt_type,W ; get option type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
261 xorlw 2 ; option type is string ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
262 bz option_save_string ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
263 movff INDF1,EEDATA ; one byte to be saved to EEPROM
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
264 btfss EEADRH,1 ; EEADR:EEADRH < 512 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
265 call write_eeprom ; YES - write
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
266 return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
267 option_save_string:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
268 movff POSTINC1,EEDATA ; write one byte
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
269 btfss EEADRH,1 ; EEADR:EEADRH < 512 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
270 call write_eeprom ; Yes - write
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
271 infsnz EEADR,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
272 incf EEADRH,F
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
273 decfsz opt_max ; decrement string length
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
274 bra option_save_string ; loop while not finished
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
275 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
276
0
heinrichsweikamp
parents:
diff changeset
277 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
278
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
279 global option_restore_all ; restore options from EEPROM
0
heinrichsweikamp
parents:
diff changeset
280 option_restore_all:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
281 ;---- Read option serial from EEPROM
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
282 movlw LOW(eeprom_serial_save)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
283 movwf EEADR
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
284 movlw HIGH(eeprom_serial_save)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
285 movf EEADRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
286 call read_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
287 movlw LOW(eeprom_opt_serial)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
288 xorwf EEDATA,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
289 bnz option_restore_bad ; auto reset if changed
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
290 incf EEADR,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
291 call read_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
292 movlw HIGH(eeprom_opt_serial)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
293 xorwf EEDATA,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
294 bz option_restore_ok ; auto reset if changed
0
heinrichsweikamp
parents:
diff changeset
295
heinrichsweikamp
parents:
diff changeset
296 option_restore_bad:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
297 call option_reset_all ; reset RAM contains
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
298 goto option_save_all ; then save to EEPROM
0
heinrichsweikamp
parents:
diff changeset
299
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
300 ;---- Proper restore
0
heinrichsweikamp
parents:
diff changeset
301 option_restore_ok:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
302 movlw LOW(option_table_begin)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
303 movwf FSR0L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
304 movlw HIGH(option_table_begin)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
305 movwf FSR0H
0
heinrichsweikamp
parents:
diff changeset
306
heinrichsweikamp
parents:
diff changeset
307 option_restore_all_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
308 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
309 cpfseq FSR0L
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
310 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
311 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
312 cpfseq FSR0H
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
313 bra option_restore_all_2 ; not yet done...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
314 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
315 option_restore_all_2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
316 rcall option_restore ; Restore one option
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
317 bra option_restore_all_1 ; and loop
0
heinrichsweikamp
parents:
diff changeset
318
heinrichsweikamp
parents:
diff changeset
319 option_restore:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
320 rcall option_read
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
321 incf opt_eeprom,W ; shall we save it ?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
322 btfsc STATUS,Z ; EEPROM address is FFh ?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
323 return ; YES - nothing to do.
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
324 movf opt_eeprom,W ; compute backup address in EEPROM
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
325 addlw LOW(eeprom_opt_backup) ; add offset
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
326 movwf EEADR
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
327 movlw HIGH(eeprom_opt_backup)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
328 btfsc STATUS,C ; > 256 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
329 addlw .1 ; YES - +1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
330 movwf EEADRH
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
331 movf opt_type,W ; get option type
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
332 xorlw 2 ; Option type is string?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
333 bz option_restore_string ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
334 call read_eeprom ; read one byte from EEPROM
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
335 movff EEDATA, INDF1 ; restore option register
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
336 return
0
heinrichsweikamp
parents:
diff changeset
337 option_restore_string:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
338 call read_eeprom ; read one byte, and...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
339 movff EEDATA,POSTINC1 ; ... restore it
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
340 infsnz EEADR,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
341 incf EEADRH,F
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
342 decfsz opt_max ; decrement string length
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
343 bra option_restore_string ; loop while not finished
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
344 return
0
heinrichsweikamp
parents:
diff changeset
345
heinrichsweikamp
parents:
diff changeset
346 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
347 ; Increment an option, based on type, and boundary
0
heinrichsweikamp
parents:
diff changeset
348 ; INPUT: FSR0 = option handle
heinrichsweikamp
parents:
diff changeset
349 ; OUTPUT: none
heinrichsweikamp
parents:
diff changeset
350 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
351 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
352 global option_inc ; increment FSR0 option
0
heinrichsweikamp
parents:
diff changeset
353 option_inc:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
354 ; read type, default and register from table
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
355 rcall option_read
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
356
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
357 ; switch on type
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
358 movf opt_type,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
359 bz option_inc_uint8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
360 dcfsnz WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
361 bra option_inc_enum8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
362 dcfsnz WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
363 bra option_inc_string
0
heinrichsweikamp
parents:
diff changeset
364
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
365 option_inc_uint8: ; default type too...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
366 movf INDF1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
367 addwf opt_inc,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
368 cpfslt opt_max
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
369 bra option_inc_uint8_0
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
370 movf opt_min,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
371 option_inc_uint8_0:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
372 movwf INDF1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
373 option_inc_uint8_1:
533
dfac393b2199 CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents: 418
diff changeset
374 ; Now some rather crude hack into this routine to make CCR Calibration more convenient:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
375 movlw .149 ; EEPROM address of option CalGasO2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
376 cpfseq opt_eeprom ; editing CalGasO2 right now?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
377 return ; NO - done (or bra option_inc_uint8_2)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
378 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
379 decfsz WREG,W ; - in CCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
380 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
381 movlw .26 ; YES -
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
382 cpfseq INDF1 ; - option value = 26 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
383 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
384 movlw .95 ; YES - advance it to 95
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
385 movwf INDF1 ; - store it
533
dfac393b2199 CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents: 418
diff changeset
386 return
0
heinrichsweikamp
parents:
diff changeset
387
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
388 option_inc_enum8: ; always +1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
389 incf INDF1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
390 cpfsgt opt_max
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
391 clrf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
392 movwf INDF1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
393 option_inc_enum8_1:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
394 ; Now some rather crude hack into this routine to unify CCR & pSCR mode setting
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
395 movlw .25 ; EEPROM address of option oCCRMode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
396 cpfseq opt_eeprom ; editing oCCRMode right now?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
397 bra option_inc_enum8_2 ; NO - check next option
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
398 btfsc analog_o2_input ; YES - does hosting OSTC have an analog interface?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
399 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
400 btfsc optical_input ; does hosting OSTC have an optical interface?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
401 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
402 movf INDF1,W ; NO to both - get mode (=0: fixed SP, =1: Sensor, =2: AutoSP)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
403 xorlw .1 ; - in sensor mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
404 bnz option_inc_enum8_1a ; NO - continue with next check
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
405 incf INDF1,F ; YES - advance option value to AutoSP
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
406 option_inc_enum8_1a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
407 movff opt_dive_mode,WREG ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
408 xorlw .4 ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
409 bnz option_inc_enum8_1_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
410 bcf INDF1,1 ; YES - clear bit 1 because opt_ccr_mode may only be 0 or 1 (reverts AutoSP to calculated SP)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
411 option_inc_enum8_1_exit:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
412 return ; done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
413 option_inc_enum8_2:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
414 ; (unused)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
415 option_inc_enum8_3:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
416
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
417 IFDEF _rx_functions
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
418 global option_cleanup_oTrMode_CCR ; embedded clean-up entry-point
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
419 global option_cleanup_oTrMode_no_CCR ; embedded clean-up entry-point
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
420 ; Now some rather crude hack to correct opt_TR_mode in dependency of opt_dive_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
421 movlw .8 ; EEPROM address of option opt_dive_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
422 cpfseq opt_eeprom ; editing opt_dive_mode right now?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
423 bra option_inc_enum8_4 ; NO - check next option
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
424 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
425 decfsz WREG,W ; dive mode = 1 CCR?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
426 bra option_inc_enum8_3a ; NO - in any other mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
427 option_cleanup_oTrMode_CCR: ; entry point from cleanup during restart
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
428 movff opt_TR_mode,WREG ; YES - get TR mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
429 xorlw .2 ; - mode = 2 (ind.double)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
430 bnz option_inc_enum8_3_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
431 bra option_inc_enum8_3_reset ; YES - revert mode to 1 (on)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
432 option_inc_enum8_3a: ; any mode other than CCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
433 option_cleanup_oTrMode_no_CCR: ; entry point from cleanup during restart
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
434 movff opt_TR_mode,WREG ; get TR mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
435 xorlw .3 ; mode = 3 (CCR Dil+O2)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
436 bnz option_inc_enum8_3_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
437 option_inc_enum8_3_reset: ; YES - revert to mode 1 (on)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
438 movlw .1 ; load coding of mode "on"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
439 movff WREG,opt_TR_mode ; write to option
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
440 option_inc_enum8_3_exit:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
441 return ; done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
442 option_inc_enum8_4:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
443 ; Now some rather crude hack to advance opt_TR_mode in dependency of opt_dive_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
444 movlw .222 ; EEPROM address of option opt_TR_mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
445 cpfseq opt_eeprom ; editing opt_TR_mode right now?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
446 bra option_inc_enum8_5 ; NO - check next option
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
447 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
448 decfsz WREG,W ; dive mode = 1 CCR?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
449 bra option_inc_enum8_4a ; NO - in any other mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
450 movf INDF1,W ; YES - get option value (TR mode)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
451 xorlw .2 ; - mode = 2 (ind.double)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
452 bnz option_inc_enum8_4_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
453 incf INDF1,F ; YES - advance option value to 3 (CCR Dil+O2)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
454 bra option_inc_enum8_4_exit ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
455 option_inc_enum8_4a: ; any mode other than CCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
456 movf INDF1,W ; get option value (TR mode)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
457 xorlw .3 ; mode = 3 (CCR Dil+O2)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
458 bnz option_inc_enum8_4_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
459 clrf INDF1 ; YES - advance option value to 0 "off"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
460 option_inc_enum8_4_exit:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
461 return ; done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
462 ENDIF
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
463
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
464 option_inc_enum8_5:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
465 return
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
466
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
467
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
468 option_inc_string: ; no editing available
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
469 return
0
heinrichsweikamp
parents:
diff changeset
470
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
471
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
472 global option_cleanup_oCCRMode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
473 global option_cleanup_oCCRMode_pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
474 global option_cleanup_oCCRMode_CCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
475 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
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
476 banksel opt_dive_mode ; select options bank
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
477 movf opt_dive_mode,W ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
478 xorlw .4 ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
479 bnz option_cleanup_oCCRMode_CCR ; NO - check if sensor is available on hosting OSTC
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
480 option_cleanup_oCCRMode_pSCR: ; jump-in from start.asm if known to be in pSCR mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
481 banksel opt_ccr_mode ; select options bank
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
482 bcf opt_ccr_mode,1 ; YES - clear bit 1 because opt_ccr_mode may only be 0 or 1 (reverts AutoSP to calculated SP)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
483 option_cleanup_oCCRMode_CCR: ; continue from above & jump-in from start.asm if known to be in CCR mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
484 banksel common ; flags are located in bank common
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
485 btfsc analog_o2_input ; does hosting OSTC have an analog interface?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
486 bra option_cleanup_oCCRMode_exit ; YES - setting 'sensor' allowed
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
487 btfsc optical_input ; does hosting OSTC have an optical interface?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
488 bra option_cleanup_oCCRMode_exit ; YES - setting 'sensor' allowed
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
489 banksel opt_ccr_mode ; NO to both - select options bank
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
490 movf opt_ccr_mode,W ; - get CCR mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
491 xorlw .1 ; - CCR mode = sensor?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
492 bnz option_cleanup_oCCRMode_exit ; NO - ok
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
493 clrf opt_ccr_mode ; - YES - set CCR mode to fixed SP (0)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
494 option_cleanup_oCCRMode_exit:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
495 banksel common ; back to bank common
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
496 return ; done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
497
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
498
0
heinrichsweikamp
parents:
diff changeset
499 ;=============================================================================
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
500 ; Strcat option into FSR2 buffer
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
501 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
502 global option_draw ; STRCAT FRS0 option
0
heinrichsweikamp
parents:
diff changeset
503 option_draw:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
504 ; Read type, default and register from table
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
505 rcall option_read
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
506
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
507 ; Switch on type
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
508 movf opt_type,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
509 bz option_draw_uint8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
510 dcfsnz WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
511 bra option_draw_enum8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
512 dcfsnz WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
513 bra option_draw_string
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
514 return ; unknown, return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
515 option_draw_string:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
516 movff POSTINC1,POSTINC2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
517 decfsz opt_max
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
518 bra option_draw_string
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
519 return
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
520
0
heinrichsweikamp
parents:
diff changeset
521
heinrichsweikamp
parents:
diff changeset
522 option_draw_uint8:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
523 movff INDF1,lo ; draw value
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
524 bsf leftbind
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
525 output_8
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
526 bcf leftbind
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
527 clrf INDF2 ; make sure to close string
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
528 movf opt_unit+0,W ; is there a unit to append?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
529 iorwf opt_unit+1,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
530 rcall option_draw_unit ; YES
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
531 movf opt_default,W ; get default value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
532 cpfseq lo ; compare with current value, equal?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
533 bra option_draw_uint8_2 ; NO - not default, add *
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
534 return ; YES - default, done
0
heinrichsweikamp
parents:
diff changeset
535 option_draw_uint8_2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
536 PUTC "*" ; print "*"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
537 return ; done
0
heinrichsweikamp
parents:
diff changeset
538 option_draw_unit:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
539 movff opt_unit+0,FSR1L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
540 movff opt_unit+1,FSR1H
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
541 goto strcat_text
0
heinrichsweikamp
parents:
diff changeset
542
heinrichsweikamp
parents:
diff changeset
543
heinrichsweikamp
parents:
diff changeset
544 ;---- Draw an enumerated value (set of translated strings)
heinrichsweikamp
parents:
diff changeset
545 option_draw_enum8:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
546 movf INDF1,W ; get current value
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
547 cpfsgt opt_max ; bound value
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
548 clrf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
549 addwf WREG ; *= 2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
550 addwf opt_inc,W ; base text + 2 * value
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
551 movwf FSR1L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
552 movlw .0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
553 addwfc opt_min,W ; propagate carry...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
554 movwf FSR1H ; ...into FSR1
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
555 goto strcat_text
0
heinrichsweikamp
parents:
diff changeset
556
heinrichsweikamp
parents:
diff changeset
557
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
558 END