Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/menu_custom.asm @ 784:46ef1e1388f1
Merge
author | heinrichsweikamp |
---|---|
date | Mon, 23 Jun 2014 17:29:59 +0200 |
parents | 91ae251d379f |
children | a652b0ff4dcf |
rev | line source |
---|---|
0 | 1 ; OSTC - diving computer code |
2 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
3 | |
4 ; This program is free software: you can redistribute it and/or modify | |
5 ; it under the terms of the GNU General Public License as published by | |
6 ; the Free Software Foundation, either version 3 of the License, or | |
7 ; (at your option) any later version. | |
8 | |
9 ; This program is distributed in the hope that it will be useful, | |
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ; GNU General Public License for more details. | |
13 | |
14 ; You should have received a copy of the GNU General Public License | |
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | |
17 | |
18 ; Menu "Custom Functions", Custom Functions checker (Displays permanent warning if critical custom functions are altered) | |
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
20 ; written: 051030 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
21 ; last updated: 120421 |
0 | 22 ; known bugs: |
23 ; ToDo: | |
24 | |
25 ;First Bank of Custom Functions: | |
26 ; The custom functions are stored in the internal EEPROM after 0x80 | |
27 ; any custom function occupies 4 byte: | |
28 ; 2 byte (low:high) store the default value, reset from menu "reset" | |
29 ; if bit16=1 then the custrom function is 15bit value, if not it's a 8bit value | |
30 ; 2 byte (low:high) store the actual value | |
31 ; defaults for custom functions are in menu "reset" | |
32 ; get values with GETCUSTOM8 .x with x=0...32 for 8 Bit values (stored in WREG) | |
33 ; or with GETCUSTOM15 .x with x=0...32 for 15 Bit values (stored in lo and hi) | |
34 | |
35 ;Second Bank of Custom Functions: | |
36 ; The custom functions are stored in the internal EEPROM after 0x180 | |
37 ; any custom function occupies 4 byte: | |
38 ; 2 byte (low:high) store the default value, reset from menu "reset" | |
39 ; if bit16=1 then the custrom function is 15bit value, if not it's a 8bit value | |
40 ; 2 byte (low:high) store the actual value | |
41 ; defaults for custom functions are in menu "reset" | |
42 ; get values with GETCUSTOM8 .x with x=0...32 for 8 Bit values (stored in WREG) | |
43 ; or with GETCUSTOM15 .x with x=0...32 for 15 Bit values (stored in lo and hi) | |
44 | |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
45 ;Third Bank of Custom Functions: |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
46 ; The custom functions are stored in the internal EEPROM after 0x280 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
47 ; any custom function occupies 4 byte: |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
48 ; 2 byte (low:high) store the default value, reset from menu "reset" |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
49 ; if bit16=1 then the custrom function is 15bit value, if not it's a 8bit value |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
50 ; 2 byte (low:high) store the actual value |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
51 ; defaults for custom functions are in menu "reset" |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
52 ; get values with GETCUSTOM8 .x with x=0...32 for 8 Bit values (stored in WREG) |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
53 ; or with GETCUSTOM15 .x with x=0...32 for 15 Bit values (stored in lo and hi) |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
54 |
79 | 55 ; [jDG] 2010-11-30 More fancy displsy of the various CF types |
56 ; data types. When we do have a 8bit data (bit16=0), the high byte serves to | |
97 | 57 ; define the display format. Also stores min/max bounds into the PROM table. |
58 ; And provides surfacemode checking of all parameters. | |
79 | 59 |
478
fd8266b511cc
New SAC (CF56/CF57) in 5..50 l/min range (no more decimal).
JeanDo
parents:
445
diff
changeset
|
60 CF_INT8 EQU 0 ; Default display, 8 or 15 bits values. |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
61 CF_PERCENT EQU 1 ; Displays 110% |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
62 CF_DECI EQU 2 ; Displays 1.6 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
63 CF_CENTI EQU 3 ; Displays 1.50 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
64 CF_MILI EQU 4 ; Displays 1.015 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
65 CF_BOOL EQU 5 ; Displays ON/OFF |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
66 CF_SEC EQU 6 ; Displays 4:00 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
67 CF_COLOR EQU 7 ; Display 240 plus a color watch (inverse video space) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
68 ; |
355 | 69 CF_TYPES EQU 0x0F |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
70 CF_MAX_BIT EQU 6 ; Default is the highest safe value. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
71 CF_MAX EQU (1<<CF_MAX_BIT) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
72 CF_MIN_BIT EQU 5 ; Default is the lowest safe value. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
73 CF_MIN EQU (1<<CF_MIN_BIT) |
355 | 74 CF_NEG_BIT EQU 4 ; Allow negativ values. |
75 CF_NEG EQU (1<<CF_NEG_BIT) | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
76 ; |
79 | 77 CF_INT15 EQU 0x80; Default display. Flag for 15bit, typeless values. |
0 | 78 |
360 | 79 ;============================================================================= |
80 ; Overlay our tmp data in ACCESS0 bank | |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
81 CBLOCK tmp ; Into safe (from C library) area. |
360 | 82 cf32_x4 ; CF# modulus 32, time 4. |
83 cf_type ; Type of the edited CF | |
84 cf_default:2 | |
85 cf_value:2 | |
86 cf_min | |
87 cf_max | |
88 cf_step ; Value ad add/substract: 1, 10, 100 | |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
89 cf_page_number ; CF page number (0: 0-31, 1: 32-63) |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
90 cf_title_text ; # of text for title |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
91 cf_descriptor_text ; # of descriptor text offset |
360 | 92 ENDC |
93 | |
94 ;============================================================================= | |
95 | |
0 | 96 GETCUSTOM8 macro custom8 |
97 movlw custom8 | |
98 call getcustom8_1 | |
99 endm | |
100 | |
101 getcustom8_1: | |
102 ; # number of requested custom function in wreg | |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
103 movwf customfunction_temp1 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
104 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
105 clrf EEADRH |
0 | 106 movlw d'31' |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
107 cpfsgt customfunction_temp1 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
108 bra getcustom8_3 ; bank 0 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
109 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
110 movlw d'1' |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
111 movwf EEADRH ; bank 1 |
0 | 112 movlw d'32' |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
113 subwf customfunction_temp1,F |
587
1b021a280e15
NEW CF64: Configures color for inactive gases
heinrichsweikamp
parents:
576
diff
changeset
|
114 movlw d'31' |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
115 cpfsgt customfunction_temp1 |
587
1b021a280e15
NEW CF64: Configures color for inactive gases
heinrichsweikamp
parents:
576
diff
changeset
|
116 bra getcustom8_3 |
0 | 117 |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
118 movlw d'2' |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
119 movwf EEADRH ; bank 2 |
587
1b021a280e15
NEW CF64: Configures color for inactive gases
heinrichsweikamp
parents:
576
diff
changeset
|
120 movlw d'32' |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
121 subwf customfunction_temp1,F |
0 | 122 getcustom8_3: |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
123 movf customfunction_temp1,W |
0 | 124 mullw d'4' |
125 movf PRODL,W ; x4 for adress | |
126 addlw d'130' | |
127 movwf EEADR ; +130 for LOW Byte of value | |
128 call read_eeprom ; Lowbyte | |
129 movf EEDATA,W ; copied into wreg | |
130 clrf EEADRH | |
131 return ; return | |
132 | |
167 | 133 GETCUSTOM15 macro number |
134 movlw number | |
135 call getcustom15 | |
0 | 136 endm |
137 | |
167 | 138 global getcustom15 |
139 getcustom15: | |
0 | 140 ; # number of requested custom function in wreg |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
141 movwf customfunction_temp1 |
0 | 142 |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
143 clrf EEADRH |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
144 movlw d'31' |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
145 cpfsgt customfunction_temp1 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
146 bra getcustom15_3 ; bank 0 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
147 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
148 movlw d'1' |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
149 movwf EEADRH ; bank 1 |
0 | 150 movlw d'32' |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
151 subwf customfunction_temp1,F |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
152 movlw d'63' |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
153 cpfsgt customfunction_temp1 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
154 bra getcustom15_3 ; bank 1 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
155 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
156 movlw d'2' |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
157 movwf EEADRH ; bank 2 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
158 movlw d'64' |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
159 subwf customfunction_temp1,F |
0 | 160 getcustom15_3: |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
161 movf customfunction_temp1,W |
0 | 162 mullw d'4' |
163 movf PRODL,W ; x4 for adress | |
164 addlw d'130' | |
165 movwf EEADR ; +130 for LOW Byte of value | |
166 call read_eeprom ; Lowbyte | |
167 movff EEDATA,lo | |
168 incf EEADR,F | |
169 call read_eeprom ; Highbyte | |
170 movff EEDATA,hi | |
171 clrf EEADRH | |
172 return ; return | |
173 | |
574 | 174 menu_custom_functions_page3: |
175 movlw .2 | |
176 movff WREG,cf_page_number ; CF page number (0: 0-31, 1: 32-63) | |
177 movlw .225 | |
178 movff WREG,cf_title_text ; # of text for title | |
179 movlw .193 | |
180 movff WREG,cf_descriptor_text ; # of descriptor text offset | |
181 bra menu_custom_functions0 | |
182 | |
0 | 183 menu_custom_functions_page2: |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
184 movlw .1 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
185 movff WREG,cf_page_number ; CF page number (0: 0-31, 1: 32-63) |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
186 movlw .186 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
187 movff WREG,cf_title_text ; # of text for title |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
188 movlw .154 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
189 movff WREG,cf_descriptor_text ; # of descriptor text offset |
0 | 190 bra menu_custom_functions0 |
191 | |
192 menu_custom_functions: | |
574 | 193 movlw .0 |
194 movff WREG,cf_page_number ; CF page number (0: 0-31, 1: 32-63) | |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
195 movlw .27 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
196 movff WREG,cf_title_text ; # of text for title |
574 | 197 movlw .36 |
198 movff WREG,cf_descriptor_text ; # of descriptor text offset | |
0 | 199 |
200 menu_custom_functions0: | |
201 bsf leftbind | |
681 | 202 call DISP_ClearScreen |
0 | 203 movlw d'1' |
204 movwf menupos | |
205 | |
206 bcf menubit4 | |
207 bcf sleepmode | |
208 clrf decodata+0 ; here: # of CustomFunction | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
209 clrf cf32_x4 ; here: # of CustomFunction*4 |
0 | 210 bcf first_FA ; here: =1: -, =0: + |
360 | 211 movlw 1 ; Stepsize: 1, 10, or 100. |
212 movwf cf_step | |
0 | 213 |
717 | 214 call DISP_divemask_color |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
215 movff cf_title_text,WREG ; Title text in low bank |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
216 call displaytext_1_low |
0 | 217 |
218 menu_custom_functions1: | |
681 | 219 call DISP_standard_color ; Trash EEADRH... |
29 | 220 |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
221 movff cf_page_number,EEADRH ; CF page number (0: 0-31, 1: 32-63) |
7 | 222 |
0 | 223 clrf timeout_counter2 |
224 bcf menubit2 | |
225 bcf menubit3 | |
226 WIN_LEFT .20 | |
227 WIN_TOP .35 | |
228 lfsr FSR2,letter | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
229 movff decodata+0,lo ; decodata == CF number % 32 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
230 |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
231 movff cf_page_number,WREG ; CF page number (0: 0-31, 1: 32-63) |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
232 mullw .32 ; CF page number * 32 -> PRODL:PRODH |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
233 movf PRODL,W |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
234 addwf lo,F ; Add offset for display in CF menu |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
235 |
0 | 236 output_99x |
123 | 237 STRCAT_PRINT ": " |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
238 movff cf_descriptor_text,WREG ; start of custom function descriptors |
0 | 239 addwf decodata+0,W ; add # of current custom function, place result in wreg |
174 | 240 call displaytext_1_low ; shows descriptor |
0 | 241 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
242 ; Read default, type and min/max from reset table. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
243 rcall cf_read_default |
0 | 244 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
245 movf cf_type,W ; Is it a ON/OFF flag ? |
79 | 246 xorlw CF_BOOL |
247 bnz menu_custom_functions10a ; Not a binary CF selected | |
0 | 248 |
249 menu_custom_functions10c: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
250 ; Erase unused lines when editing boolean... |
79 | 251 WIN_LEFT .20 |
252 WIN_TOP .65 | |
253 lfsr FSR2,letter ; Make a string of 8 spaces | |
84 | 254 call cf_fill_line |
79 | 255 call word_processor ; Clear +/- line |
256 | |
257 WIN_TOP .95 | |
258 call word_processor ; Clear 1/10 line | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
259 |
0 | 260 bra menu_custom_functions10b |
261 | |
262 menu_custom_functions10a: | |
263 WIN_LEFT .20 | |
264 WIN_TOP .65 | |
123 | 265 STRCPY "+/-: " |
0 | 266 movlw '+' |
267 btfsc first_FA | |
268 movlw '-' | |
269 movwf POSTINC2 | |
270 call word_processor | |
271 | |
272 WIN_TOP .95 | |
445 | 273 STRCPY TXT_STEP5 |
360 | 274 clrf hi |
275 movff cf_step,lo | |
276 call display_formated ; Typed display, w/o fill line. | |
277 STRCAT_PRINT " " ; 2 spaces for "0.01"->"1" | |
0 | 278 |
79 | 279 menu_custom_functions10b: |
0 | 280 WIN_LEFT .20 |
281 WIN_TOP .125 | |
282 lfsr FSR2,letter | |
360 | 283 OUTPUTTEXT d'89' ; "Default:" |
0 | 284 |
360 | 285 movff cf_default+0,lo |
286 movff cf_default+1,hi | |
287 call display_customfunction ; Typed display. | |
0 | 288 |
289 WIN_LEFT .20 | |
290 WIN_TOP .155 | |
291 lfsr FSR2,letter | |
360 | 292 OUTPUTTEXT d'97' ; "Current:" |
0 | 293 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
294 movf cf32_x4,W |
0 | 295 addlw 0x82 |
296 movwf EEADR | |
297 call read_eeprom ; Lowbyte | |
360 | 298 movff EEDATA,cf_value+0 |
79 | 299 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
300 movf cf32_x4,W |
0 | 301 addlw 0x83 |
302 movwf EEADR | |
303 call read_eeprom ; Highbyte | |
360 | 304 movff EEDATA,cf_value+1 |
79 | 305 |
681 | 306 call DISP_standard_color ; Changed by color swatches, but trash EEADRH... |
360 | 307 movff cf_value+0,lo |
308 movff cf_value+1,hi | |
79 | 309 call display_customfunction |
0 | 310 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
311 ; End of mask: min/max and the exit line... |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
312 rcall display_minmax |
0 | 313 DISPLAYTEXT .11 ; Exit |
314 | |
315 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
681 | 316 call DISP_menu_cursor |
0 | 317 |
318 customfunctions_loop: | |
337 | 319 call check_switches_logbook |
0 | 320 |
337 | 321 btfsc menubit3 |
322 bra customfunctions2 ; Move cursor or generate next page | |
0 | 323 |
337 | 324 btfsc menubit2 |
325 bra do_customfunction ; call subfunction | |
0 | 326 |
327 btfsc divemode | |
337 | 328 goto restart ; dive started during cf menu |
0 | 329 |
330 btfsc onesecupdate | |
331 call timeout_surfmode | |
332 | |
333 btfsc onesecupdate | |
334 call set_dive_modes | |
335 | |
337 | 336 bcf onesecupdate ; end of 1sek. tasks |
335 | 337 |
0 | 338 btfsc sleepmode |
337 | 339 bra exit_customfunctions |
0 | 340 |
337 | 341 bra customfunctions_loop |
0 | 342 |
343 customfunctions2: | |
344 incf menupos,F | |
90 | 345 movf cf_type,W ; Are we editing a boolean value ? |
346 xorlw CF_BOOL | |
347 bnz customfunctions2a ; NO : don't skip lines 2/3. | |
84 | 348 |
349 movlw d'4' ; Just after increment, | |
350 cpfsgt menupos ; Is current position < 4 ? | |
351 movwf menupos ; NO: skip set to 4. | |
352 | |
353 customfunctions2a: | |
0 | 354 movlw d'7' |
355 cpfseq menupos ; =7? | |
356 bra customfunctions3 ; No | |
357 movlw d'1' | |
358 movwf menupos | |
359 | |
360 customfunctions3: | |
361 clrf timeout_counter2 | |
681 | 362 call DISP_menu_cursor |
0 | 363 |
364 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
365 | |
366 bcf menubit3 ; clear flag | |
367 bra customfunctions_loop | |
368 | |
79 | 369 ;----------------------------------------------------------------------------- |
94 | 370 ; Read default value, type, and constraints |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
371 ; |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
372 ; Input: cf32_x4 |
360 | 373 ; Output: cf_default, cf_type, cf_min, cf_max. |
94 | 374 ; Trashes: TBLPTR |
375 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
376 cf_read_default: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
377 movlw LOW(cf_default_table0) ; Get 24bit PROM pointer. SKIP |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
378 movwf TBLPTRL |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
379 movlw HIGH(cf_default_table0) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
380 movwf TBLPTRH |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
381 movlw UPPER(cf_default_table0) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
382 movwf TBLPTRU |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
383 |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
384 movff cf_page_number,WREG ; CF page number (0: 0-31, 1: 32-63) |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
385 mullw 0x80 ; CF page number * 0x80 -> PRODL:PRODH |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
386 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
387 movf PRODL,W |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
388 addwf cf32_x4,W ; Add 4 x (CF index modulus 32) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
389 addwf TBLPTRL,F ; And to a 8+16 add into TBLPTR |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
390 movf PRODH,W |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
391 addwfc TBLPTRH,F ; Propagate to 16bit (but not 24bits). |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
392 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
393 tblrd*+ |
360 | 394 movff TABLAT,cf_default+0 ; Low byte |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
395 tblrd*+ |
360 | 396 movff TABLAT,cf_default+1 ; High byte |
397 btfss cf_default+1,7 ; 15bit ? | |
398 clrf cf_default+1 ; NO: clear extra type flags | |
399 bcf cf_default+1,7 ; clear 15bit flag | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
400 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
401 movff TABLAT,cf_type ; type (high byte) --> cf_type |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
402 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
403 tblrd*+ |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
404 movff TABLAT,cf_min ; Then get optional min/max |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
405 tblrd*+ |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
406 movff TABLAT,cf_max |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
407 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
408 return |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
409 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
410 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
411 ; Display a 8/15bit value, plus optional min and max bound. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
412 ; Input : hi:lo = data to display. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
413 ; cf_type = the type. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
414 ; cf_min, cf_max : the optional min/max. |
79 | 415 ; FSR2 = current string pointer. |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
416 ; Trash : hi:lo (when displaying min/max) |
79 | 417 |
418 display_customfunction: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
419 movff EEADRH, FSR1H ; Backup... |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
420 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
421 rcall display_formated |
123 | 422 incf WREG ; Color swatch drawn ? |
423 bz display_customfunction_1 ; YES: skip line fill... | |
424 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
425 rcall cf_fill_line |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
426 call word_processor |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
427 |
123 | 428 display_customfunction_1: |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
429 movff FSR1H, EEADRH |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
430 return |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
431 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
432 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
433 ; Display optional min/max values. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
434 ; Inputs: cf_value, cf_min, cf_max (and cf_type to display min/max). |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
435 ; Trashed: hi:lo while display min and max values. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
436 display_minmax: |
99 | 437 ; Min/max unsupported for 15bit values yet... |
79 | 438 movff EEADRH, FSR1H ; Backup... |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
439 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
440 ; Display min line |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
441 WIN_TOP .65 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
442 WIN_LEFT .100 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
443 lfsr FSR2, letter |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
444 |
100 | 445 btfsc cf_type,7 ; A 15bit value ? |
446 bra cf_no_min ; Don't display, hence clear line... | |
447 | |
355 | 448 btfss cf_type,CF_MIN_BIT ; A min value exists ? |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
449 bra cf_no_min |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
450 |
355 | 451 btfss cf_type,CF_NEG_BIT |
452 bra cf_min_unsigned | |
453 | |
454 ; Uses 16bit sub for checking signed min value. | |
455 movff cf_value,sub_a+0 ; A <- value | |
456 clrf sub_a+1 | |
457 btfsc cf_value,7 ; extend sign if value < 0 | |
458 setf sub_a+1 | |
459 | |
460 movff cf_min,sub_b+0 ; B <- min (with signed extend) | |
461 setf sub_b+1 ; min have to be negativ. | |
462 call sub16 ; Compute (A-B) | |
463 | |
464 btfss neg_flag ; Result < 0 ? | |
465 bra cf_min_passed ; NO | |
466 bra cf_min_failed ; YES | |
467 | |
468 cf_min_unsigned: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
469 movf cf_min,W ; Retrieve current 8b value |
355 | 470 subwf cf_value,W ; Compute (value-min) |
471 bc cf_min_passed ; Ok if CARRY, ie. min >= lo | |
472 | |
473 cf_min_failed: | |
681 | 474 call DISP_warnings_color |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
475 WIN_INVERT 1 |
355 | 476 |
477 cf_min_passed: | |
123 | 478 STRCAT "> " ; A min value follows |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
479 movff cf_min, lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
480 rcall display_formated |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
481 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
482 cf_no_min: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
483 rcall cf_fill_line ; Fill buffer |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
484 lfsr FSR2, letter+.7 ; Limit to 8 chars btw. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
485 call word_processor |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
486 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
487 ; Display max line |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
488 WIN_TOP .95 |
681 | 489 call DISP_standard_color |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
490 WIN_INVERT 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
491 lfsr FSR2, letter |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
492 |
100 | 493 btfsc cf_type,7 ; A 15bit value ? |
494 bra cf_no_max ; Don't display, hence clear line too... | |
495 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
496 btfss cf_type, CF_MAX_BIT ; A max value exists ? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
497 bra cf_no_max |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
498 |
355 | 499 btfss cf_type,CF_NEG_BIT |
500 bra cf_max_unsigned | |
501 | |
502 ; Uses 16bit sub for checking signed min value. | |
503 movff cf_max,sub_a+0 ; A <- max (with signed extend) | |
504 clrf sub_a+1 ; max have to be positiv. | |
505 | |
506 movff cf_value,sub_b+0 ; B <- value | |
507 clrf sub_b+1 | |
508 btfsc cf_value,7 ; extend sign if value < 0 | |
509 setf sub_b+1 | |
510 call sub16 ; Compute (A-B) | |
511 | |
512 btfss neg_flag ; Result < 0 ? | |
513 bra cf_max_passed ; NO | |
514 bra cf_max_failed ; YES | |
515 | |
516 cf_max_unsigned: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
517 movf cf_value,W ; Retrieve current max bound |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
518 subwf cf_max,W ; Compute (max-lo) |
360 | 519 bc cf_max_passed ; Ok if no carry, ie. max <= lo |
355 | 520 |
521 cf_max_failed: | |
681 | 522 call DISP_warnings_color |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
523 WIN_INVERT 1 |
355 | 524 |
525 cf_max_passed: | |
123 | 526 STRCAT "< " ; A max value follows |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
527 movff cf_max, lo |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
528 rcall display_formated |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
529 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
530 cf_no_max: |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
531 rcall cf_fill_line ; Fill buffer |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
532 lfsr FSR2, letter+.7 ; Limit to 8 chars btw. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
533 call word_processor |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
534 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
535 cf_minmax_done: |
681 | 536 call DISP_standard_color |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
537 WIN_INVERT 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
538 movff FSR1H, EEADRH |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
539 return |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
540 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
541 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
542 ; Display a single 8/15 bit value, according to cf_type. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
543 ; Input : hi:lo = data to display. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
544 ; cf_type = the type. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
545 ; cf_min, cf_max : the optional min/max. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
546 ; FSR2 = current string pointer. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
547 display_formated: |
355 | 548 movf cf_type,W ; Just set N flags |
549 bn cf_type_80 ; Keep 15bits value in old format. | |
550 | |
551 ;---- handle signed values ----------------------------------------------- | |
552 ; NOTE: only 8bit values can have a negativ flag right now. | |
553 btfss cf_type,CF_NEG_BIT ; Signed value ? | |
554 bra cf_type_unsigned ; NO: display unsigned as-is | |
555 | |
556 btfss lo,7 ; Negativ value ? | |
557 bra cf_type_pos ; NO: display positives with a + sign. | |
558 | |
559 PUTC '-' ; YES: display with a - sign. | |
560 negf lo ; and correct the said value. | |
561 bra cf_type_unsigned | |
562 | |
563 cf_type_pos: | |
564 PUTC '+' | |
79 | 565 |
566 ;---- decode type -------------------------------------------------------- | |
355 | 567 cf_type_unsigned: |
568 ; Jump table: ; test the value with cleared flags... | |
569 movf cf_type,W | |
570 andlw CF_TYPES ; Look just at types | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
571 bz cf_type_00 ; 8bit standard mode |
79 | 572 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
573 dcfsnz WREG |
79 | 574 bra cf_type_01 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
575 dcfsnz WREG |
79 | 576 bra cf_type_02 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
577 dcfsnz WREG |
79 | 578 bra cf_type_03 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
579 dcfsnz WREG |
79 | 580 bra cf_type_04 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
581 dcfsnz WREG |
79 | 582 bra cf_type_05 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
583 dcfsnz WREG |
79 | 584 bra cf_type_06 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
585 dcfsnz WREG |
79 | 586 bra cf_type_07 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
587 bra cf_type_00 ; Default to 8bit mode... |
79 | 588 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
589 cf_type_01: ; Type == 1 is CF_PERCENT mode |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
590 bcf leftbind |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
591 output_8 |
123 | 592 PUTC '%' |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
593 retlw 0 |
79 | 594 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
595 cf_type_02: ; Type == 2 is CF_DECI mode. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
596 clrf hi |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
597 bsf leftbind |
79 | 598 output_16dp 4 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
599 retlw 0 |
79 | 600 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
601 cf_type_03: ; Type == 3 is CF_CENTI mode. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
602 clrf hi |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
603 bsf leftbind |
79 | 604 output_16dp 3 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
605 retlw 0 |
79 | 606 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
607 cf_type_04: ; Type == 4 is CF_MILI mode |
79 | 608 output_16dp 2 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
609 retlw 0 |
79 | 610 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
611 cf_type_05: ; Type == 5 is CF_BOOL mode. |
79 | 612 movf lo,W ; Get flag value... |
613 bz cf_type_off | |
614 OUTPUTTEXT d'130' ; ON | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
615 retlw 0 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
616 |
79 | 617 cf_type_off: |
618 OUTPUTTEXT d'131' ; OFF | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
619 retlw 0 |
79 | 620 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
621 cf_type_06: ; Type == 6 is CF_SECS mode (mm:ss or hh:mm) |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
622 clrf hi |
79 | 623 call convert_time ; Convert to min:sec into hi:low. |
123 | 624 movff lo,TABLAT ; Save seconds for later. |
79 | 625 movff hi,lo ; Get minutes |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
626 bsf leftbind ; Skip leading space(s). |
79 | 627 output_8 ; Print them |
123 | 628 PUTC ':' ; Separator |
629 movff TABLAT,lo ; Get back seconds | |
79 | 630 output_99x ; lo in 2 digits with trailing zeros. |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
631 retlw 0 |
79 | 632 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
633 cf_type_07: ; Type == 7 is CF_COLOR swatch. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
634 bcf leftbind ; Keep leading space (better alignement) |
79 | 635 output_8 |
360 | 636 |
637 movff win_top,WREG ; Is it the step value ? | |
638 xorlw .95 ; Line for "Step:" | |
639 btfsc STATUS,Z | |
640 retlw -1 ; YES : return | |
641 | |
123 | 642 STRCAT_PRINT " " |
79 | 643 movf lo,W ; Get color. |
681 | 644 call DISP_set_color |
123 | 645 movlw .23 |
646 movff WREG,win_height ; row bottom (0-239) | |
79 | 647 movlw .110 |
123 | 648 movff WREG,win_leftx2 ; column left (0-159) |
649 movlw .148-.110+1 | |
650 movff WREG,win_width ; column right (0-159) | |
79 | 651 |
681 | 652 call DISP_box |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
653 retlw -1 ; wp already done. Skip it... |
79 | 654 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
655 cf_type_00: ; 8bit mode. Or unrecognized type... |
79 | 656 clrf hi |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
657 bsf leftbind |
79 | 658 |
355 | 659 cf_type_80: ; 15bit mode. |
79 | 660 bcf hi,7 |
661 output_16 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
662 retlw 0 |
84 | 663 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
664 ;----------------------------------------------------------------------------- |
84 | 665 |
666 cf_fill_line: ; Mattias: No flicker if u clear just what you need... | |
667 movf FSR2L,W ; How many chars lefts ? | |
164 | 668 sublw letter + .18 ; Remaining chars to fill: (letter + 18) - PTR |
84 | 669 btfsc STATUS,N ; Add chars until none left... |
670 return | |
123 | 671 PUTC ' ' |
84 | 672 bra cf_fill_line |
79 | 673 |
674 ;----------------------------------------------------------------------------- | |
0 | 675 |
676 do_customfunction: | |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
677 movff cf_page_number,EEADRH ; CF page number (0: 0-31, 1: 32-63) |
0 | 678 |
679 dcfsnz menupos,F | |
680 bra next_customfunction | |
681 dcfsnz menupos,F | |
682 bra toggle_plusminus | |
683 dcfsnz menupos,F | |
684 bra toggle_oneorten | |
685 dcfsnz menupos,F | |
686 bra restore_cfn_value | |
687 dcfsnz menupos,F | |
688 bra adjust_cfn_value | |
84 | 689 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
690 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
691 |
0 | 692 exit_customfunctions: |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
693 movff cf_page_number,menupos ; CF page number (0: 0-31, 1: 32-63) |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
694 incf menupos,F |
0 | 695 clrf EEADRH ; Clear EEADRH ! |
696 goto setup_menu2 ; exit... | |
697 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
698 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
699 |
0 | 700 next_customfunction: |
701 incf decodata+0 | |
702 btfsc decodata+0,5 ;>31? | |
703 clrf decodata+0 ;Yes, so reset to zero | |
704 | |
705 movf decodata+0,W | |
706 mullw d'4' | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
707 movff PRODL, cf32_x4 ; 12bit address for correct addressing |
0 | 708 |
709 movlw d'1' | |
710 movwf menupos | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
711 bra menu_custom_functions1 ; also debounces switches |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
712 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
713 ;----------------------------------------------------------------------------- |
0 | 714 |
715 toggle_plusminus: | |
716 btg first_FA | |
717 movlw d'2' | |
718 movwf menupos | |
719 bra menu_custom_functions1 ; also debounces switches | |
720 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
721 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
722 |
0 | 723 toggle_oneorten: |
360 | 724 movlw .10 ; Multiply step by 10, |
725 mulwf cf_step ; Result in PROD low. | |
726 | |
727 movf PRODH,W ; Check 1000 | |
728 bz toggle_oneorten_1 ; HIGH(new step) null == no overflow | |
729 movlw .1 ; Cycle to 1. | |
730 movwf cf_step | |
731 bra toggle_oneorten_3 | |
732 | |
733 toggle_oneorten_1: ; Special case for mm:ss | |
734 movf cf_type,W ; Get type | |
735 andlw CF_TYPES ; w/o min/max/neg flags. | |
736 xorlw CF_SEC ; Check for mm:ss ? | |
737 bnz toggle_oneorten_2 ; no: continue | |
738 movlw .100 ; Step = 100 ? | |
739 xorwf PRODL,W | |
740 bnz toggle_oneorten_2 ; no: continue | |
741 movlw .60 ; yes: replace by 1:00 | |
742 movff WREG,cf_step | |
743 bra toggle_oneorten_3 ; Done. | |
744 | |
745 toggle_oneorten_2: | |
746 movff PRODL,cf_step ; Just keep result. | |
747 toggle_oneorten_3: | |
0 | 748 movlw d'3' |
749 movwf menupos | |
750 bra menu_custom_functions1 ; also debounces switches | |
751 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
752 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
753 |
0 | 754 restore_cfn_value: |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
755 movf cf32_x4,W ; store default value |
0 | 756 addlw 0x82 |
757 movwf EEADR | |
360 | 758 movff cf_default+0,EEDATA |
759 movff cf_default+0,cf_value+0 | |
0 | 760 call write_eeprom ; Lowbyte |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
761 movf cf32_x4,W |
0 | 762 addlw 0x83 |
763 movwf EEADR | |
360 | 764 movff cf_default+1,EEDATA |
765 movff cf_default+1,cf_value+1 | |
0 | 766 call write_eeprom ; Highbyte |
767 | |
768 movlw d'4' | |
769 movwf menupos | |
770 bra menu_custom_functions1 ; also debounces switches | |
771 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
772 ;----------------------------------------------------------------------------- |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
773 ; Adjust current value. |
0 | 774 adjust_cfn_value: |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
775 movf cf32_x4,W ; get current value |
0 | 776 addlw 0x82 |
777 movwf EEADR | |
778 call read_eeprom ; Lowbyte | |
779 movff EEDATA,lo | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
780 movf cf32_x4,W |
0 | 781 addlw 0x83 |
782 movwf EEADR | |
783 call read_eeprom ; Highbyte | |
784 movff EEDATA,hi | |
785 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
786 movf cf_type,W |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
787 xorlw CF_BOOL |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
788 bnz adjust_cfn_value1 |
0 | 789 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
790 btg lo,0 ; Change lower bit. |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
791 bra adjust_cfn_value3 ; Store result |
0 | 792 |
793 adjust_cfn_value1: | |
360 | 794 movf cf_step,W ; 1, 10, 100 ? |
0 | 795 |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
796 btfss first_FA ; Minus? |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
797 bra adjust_cfn_value2 ; No, Plus |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
798 |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
799 subwf lo,F ; substract value |
0 | 800 movlw d'0' |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
801 btfsc cf_type,7 ; 8Bit value |
0 | 802 subwfb hi,F |
803 | |
804 movlw b'01111111' | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
805 btfsc hi,7 ; >32768? |
0 | 806 movwf hi |
807 | |
808 bra adjust_cfn_value3 | |
809 | |
810 adjust_cfn_value2: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
811 addwf lo,F ; add value |
0 | 812 movlw d'0' |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
813 btfsc cf_type,7 ; 8Bit value? |
0 | 814 addwfc hi,F |
815 | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
816 btfsc hi,7 ; >32768? |
0 | 817 clrf hi |
818 | |
819 adjust_cfn_value3: | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
820 movf cf32_x4,W ; Store current value |
0 | 821 addlw 0x82 |
822 movwf EEADR | |
823 movff lo,EEDATA | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
824 call write_eeprom ; Lowbyte |
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
825 movf cf32_x4,W |
0 | 826 addlw 0x83 |
827 movwf EEADR | |
828 movff hi,EEDATA | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
829 call write_eeprom ; Highbyte |
0 | 830 movlw d'5' |
831 movwf menupos | |
86
b40a0a6284da
adding custom functions with limits (jeando)
heinrichsweikamp
parents:
84
diff
changeset
|
832 bra menu_custom_functions1 ; also debounces switches |
94 | 833 |
834 ;----------------------------------------------------------------------------- | |
835 ; Check all CF values that have max and min constraints. | |
836 ; Input: cf_checker_counter. | |
837 ; Output: Pop warning with the first CF number if bad. | |
838 ; cf_checker_counter incremented. | |
839 ; Trashes: TBLPTR, EEADR, PROD | |
100 | 840 ; |
841 ; Note: the trick here is to do two sweep over the 64 CF values, to make sure | |
842 ; they are all ok. | |
94 | 843 |
844 check_customfunctions: | |
670 | 845 ; movlw max_custom_number+1 ; Defined in definitions.asm |
846 movlw .63 ; mH: CF checker does currently not work for Bank2 | |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
847 cpfseq cf_checker_counter ; All tested? |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
848 bra check_customfunctions1 ; No, continue |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
849 clrf cf_checker_counter ; clear counter |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
850 return ; YES: just do nothing. |
94 | 851 |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
852 check_customfunctions1: |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
853 ; Setup cf_page_number |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
854 movlw .0 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
855 movff WREG,cf_page_number |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
856 movlw d'31' |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
857 cpfsgt cf_checker_counter |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
858 bra check_customfunctions2 ; CF I |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
859 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
860 movlw .1 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
861 movff WREG,cf_page_number |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
862 movlw d'63' |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
863 cpfsgt cf_checker_counter |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
864 bra check_customfunctions2 ; CF II |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
865 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
866 movlw .2 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
867 movff WREG,cf_page_number ; CF III |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
868 |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
869 check_customfunctions2: |
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
870 ; Setup cf32_x4 |
100 | 871 movf cf_checker_counter,W |
94 | 872 rlcf WREG ; x4 |
873 rlcf WREG | |
874 andlw 4*.31 | |
875 movwf cf32_x4 | |
876 | |
877 ; Do the check | |
878 rcall check_one_cf | |
100 | 879 iorwf WREG ; Test return value. |
880 bz check_failed ; 0 == FAILED. | |
881 | |
882 ; Passed: Simple loop until 128 is reached: | |
573
77c8ff191cd7
Preparations for third bank of Custom Functions
heinrichsweikamp
parents:
478
diff
changeset
|
883 incf cf_checker_counter,F ; Next CF to check. |
100 | 884 bra check_customfunctions ; And loop until 128 reached (ie twice) |
94 | 885 |
100 | 886 check_failed: |
887 movlw .63 ; Make sure number is back to range 0..63 | |
888 andwf cf_checker_counter,F | |
889 | |
890 ; Went wrong: draw the warning line... | |
309 | 891 WIN_TOP .0 |
892 WIN_LEFT .125 | |
100 | 893 WIN_FONT FT_SMALL |
894 WIN_INVERT .1 ; Init new Wordprocessor | |
681 | 895 call DISP_warnings_color |
100 | 896 |
445 | 897 STRCPY TXT_CF2 |
100 | 898 movff cf_checker_counter,lo |
899 output_99x | |
309 | 900 STRCAT_PRINT "!" |
644 | 901 WIN_INVERT .0 ; Init new Wordprocessor |
94 | 902 |
100 | 903 ; When failed, increment counter modulo 64, to restart checks. |
904 incf cf_checker_counter,W | |
905 andlw .63 ; Modulo 64 | |
94 | 906 movwf cf_checker_counter |
907 return | |
908 | |
909 ; Check one CF value --------------------------------------------------------- | |
910 check_one_cf: | |
360 | 911 rcall cf_read_default ; Sets cf_value, cf_type, cf_min, cf_max. |
94 | 912 |
100 | 913 btfsc cf_type,7 ; A 15bit type ? |
914 bra check_cf_check ; Then we have to check it... | |
915 | |
916 movf cf_type,W ; 8bit MIN or MAX set ? | |
94 | 917 andlw (CF_MIN + CF_MAX) |
918 bnz check_cf_check ; yes: do something. | |
100 | 919 retlw -1 ; no: no problem then. |
94 | 920 |
921 ; It does have bound: | |
922 check_cf_check: | |
100 | 923 movf cf_checker_counter,W ; Get current CF number |
924 andlw .63 ; Keep range 0..63 | |
94 | 925 |
926 btfss cf_type,7 ; 15 or 8 bit value ? | |
927 bra cf_check_8bit | |
928 | |
99 | 929 ; Implement the 15bit check, even if not displayed... |
167 | 930 rcall getcustom15 ; Read into hi:lo |
94 | 931 |
932 movf cf_min,W ; Compute (bound-value) -> hi:lo | |
933 subwf lo,F | |
934 movf cf_max,W | |
100 | 935 bcf WREG,7 ; Clear min/max bit |
94 | 936 subwfb hi,F |
937 | |
938 movf lo,W ; Is it a 0 result ? | |
939 iorwf hi,W | |
940 bnz cf_15_not_equal ; NO: check sign. | |
941 retlw -1 ; YES: then it is ok. | |
942 | |
943 cf_15_not_equal: | |
99 | 944 btfss cf_max,7 ; Checking min or max ? |
94 | 945 btg hi,6 ; exchange wanted sign |
946 | |
947 btfss hi,6 ; Is sign correct ? | |
100 | 948 retlw 0 ; NO: return failed. |
949 retlw -1 ; YES: return passed. | |
94 | 950 |
951 ; Do a 8bit check | |
952 cf_check_8bit: | |
953 rcall getcustom8_1 ; Read into WREG | |
954 movwf lo ; Save it. | |
955 | |
956 btfss cf_type,CF_MIN_BIT | |
957 bra check_no_min | |
355 | 958 |
959 btfss cf_type,CF_NEG_BIT | |
960 bra check_min_unsigned | |
961 | |
962 ; Uses 16bit sub for checking signed min value. | |
963 movff lo,sub_a+0 ; A <- value | |
964 clrf sub_a+1 | |
360 | 965 btfsc lo,7 ; extend sign if value < 0 |
355 | 966 setf sub_a+1 |
967 | |
968 movff cf_min,sub_b+0 ; B <- min (with signed extend) | |
969 setf sub_b+1 ; min have to be negativ. | |
970 call sub16 ; Compute (A-B) | |
971 | |
972 btfss neg_flag ; Result < 0 ? | |
973 bra check_no_min ; NO | |
974 retlw 0 ; YES = FAILED | |
975 | |
976 check_min_unsigned: | |
94 | 977 cpfsgt cf_min ; Compare to cf_min |
100 | 978 bra check_no_min ; PASSED: continue. |
979 retlw 0 ; NO: return failed. | |
94 | 980 |
981 check_no_min: | |
100 | 982 btfss cf_type,CF_MAX_BIT ; Is there a MAX bound ? |
983 retlw -1 ; No check: return OK. | |
355 | 984 |
985 btfss cf_type,CF_NEG_BIT | |
986 bra check_max_unsigned | |
987 | |
988 ; Uses 16bit sub for checking signed min value. | |
989 movff cf_max,sub_a+0 ; A <- max (with signed extend) | |
990 clrf sub_a+1 ; max have to be positiv. | |
991 | |
992 movff lo,sub_b+0 ; B <- value | |
993 clrf sub_b+1 | |
360 | 994 btfsc lo,7 ; extend sign if value < 0 |
355 | 995 setf sub_b+1 |
996 call sub16 ; Compute (A-B) | |
997 | |
998 btfss neg_flag ; Result < 0 ? | |
999 retlw -1 ; NO | |
1000 retlw 0 ; YES | |
1001 | |
1002 check_max_unsigned: | |
94 | 1003 movf lo,W ; Compute value-max |
1004 cpfslt cf_max | |
100 | 1005 retlw -1 ; Bound met: return OK. |
1006 retlw 0 ; NO: return failed. |