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