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