annotate src/strings.asm @ 2:ab8a7c3f1db0

battery warning levels, max. brightnes setting
author heinrichsweikamp
date Sun, 05 May 2013 15:37:24 +0200
parents 11d4fc797f74
children 40ff64d60054
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File strings.asm
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Implementation code various string functions.
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2010-12-02 : [jDG] Creation...
heinrichsweikamp
parents:
diff changeset
11 ;
heinrichsweikamp
parents:
diff changeset
12 ; See strings.inc for doc and public calling macros.
heinrichsweikamp
parents:
diff changeset
13
heinrichsweikamp
parents:
diff changeset
14 #include "ostc3.inc"
heinrichsweikamp
parents:
diff changeset
15 #include "varargs.inc"
heinrichsweikamp
parents:
diff changeset
16
heinrichsweikamp
parents:
diff changeset
17 extern aa_wordprocessor
heinrichsweikamp
parents:
diff changeset
18
heinrichsweikamp
parents:
diff changeset
19 basic CODE
heinrichsweikamp
parents:
diff changeset
20 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
21 ; Variants that call word_processor at the end:
heinrichsweikamp
parents:
diff changeset
22 global strcpy_block_print
heinrichsweikamp
parents:
diff changeset
23 strcpy_block_print:
heinrichsweikamp
parents:
diff changeset
24 lfsr FSR2, buffer
heinrichsweikamp
parents:
diff changeset
25 global strcat_block_print
heinrichsweikamp
parents:
diff changeset
26 strcat_block_print:
heinrichsweikamp
parents:
diff changeset
27 clrf PRODL,A
heinrichsweikamp
parents:
diff changeset
28 bra strings_common
heinrichsweikamp
parents:
diff changeset
29
heinrichsweikamp
parents:
diff changeset
30 ; Variants that do not call word_processor at end:
heinrichsweikamp
parents:
diff changeset
31 global strcpy_block
heinrichsweikamp
parents:
diff changeset
32 strcpy_block:
heinrichsweikamp
parents:
diff changeset
33 lfsr FSR2, buffer
heinrichsweikamp
parents:
diff changeset
34 global strcat_block
heinrichsweikamp
parents:
diff changeset
35 strcat_block:
heinrichsweikamp
parents:
diff changeset
36 setf PRODL,A
heinrichsweikamp
parents:
diff changeset
37
heinrichsweikamp
parents:
diff changeset
38 ; Common part: append the string from PROM return address:
heinrichsweikamp
parents:
diff changeset
39 strings_common:
heinrichsweikamp
parents:
diff changeset
40 VARARGS_BEGIN
heinrichsweikamp
parents:
diff changeset
41
heinrichsweikamp
parents:
diff changeset
42 rcall strcat_prom
heinrichsweikamp
parents:
diff changeset
43
heinrichsweikamp
parents:
diff changeset
44 VARARGS_ALIGN
heinrichsweikamp
parents:
diff changeset
45 VARARGS_END
heinrichsweikamp
parents:
diff changeset
46
heinrichsweikamp
parents:
diff changeset
47 btfsc PRODL,0,A ; Should we print afterward ?
heinrichsweikamp
parents:
diff changeset
48 return ; NO: then return straight away.
heinrichsweikamp
parents:
diff changeset
49 goto aa_wordprocessor ; ELSE: print it...
heinrichsweikamp
parents:
diff changeset
50
heinrichsweikamp
parents:
diff changeset
51 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
52 ; Copy multi-lingual text from FSR1 12bit pointers, to buffer.
heinrichsweikamp
parents:
diff changeset
53 ;
heinrichsweikamp
parents:
diff changeset
54 ; Input: FSR1 = 12bit pointer to multi-lingual text.
heinrichsweikamp
parents:
diff changeset
55 ; Output: FSR2 points to closing null byte in buffer.
heinrichsweikamp
parents:
diff changeset
56 ; Trashed: TBLPTR, TABLAT.
heinrichsweikamp
parents:
diff changeset
57 global strcpy_text
heinrichsweikamp
parents:
diff changeset
58 strcpy_text:
heinrichsweikamp
parents:
diff changeset
59 rcall text_get_tblptr
heinrichsweikamp
parents:
diff changeset
60 bra strcpy_prom
heinrichsweikamp
parents:
diff changeset
61
heinrichsweikamp
parents:
diff changeset
62 ; Copy then print multi-lingual text from FSR1 12bit pointers, to buffer.
heinrichsweikamp
parents:
diff changeset
63 ;
heinrichsweikamp
parents:
diff changeset
64 ; Input: FSR1 = 12bit pointer to multi-lingual text.
heinrichsweikamp
parents:
diff changeset
65 ; Output: FSR2 points to closing null byte in buffer.
heinrichsweikamp
parents:
diff changeset
66 ; Trashed: TBLPTR, TABLAT.
heinrichsweikamp
parents:
diff changeset
67 global strcpy_text_print
heinrichsweikamp
parents:
diff changeset
68 strcpy_text_print:
heinrichsweikamp
parents:
diff changeset
69 rcall text_get_tblptr
heinrichsweikamp
parents:
diff changeset
70 bra strcpy_prom_print
heinrichsweikamp
parents:
diff changeset
71
heinrichsweikamp
parents:
diff changeset
72 ; Append multi-lingual text from FSR1 12bit pointers, to buffer at FRS2.
heinrichsweikamp
parents:
diff changeset
73 ;
heinrichsweikamp
parents:
diff changeset
74 ; Input: FSR1 = 12bit pointer to multi-lingual text.
heinrichsweikamp
parents:
diff changeset
75 ; FSR2 = Current position in buffer.
heinrichsweikamp
parents:
diff changeset
76 ; Output: FSR2 points to closing null byte in buffer.
heinrichsweikamp
parents:
diff changeset
77 ; Trashed: TBLPTR, TABLAT.
heinrichsweikamp
parents:
diff changeset
78 global strcat_text
heinrichsweikamp
parents:
diff changeset
79 strcat_text:
heinrichsweikamp
parents:
diff changeset
80 rcall text_get_tblptr
heinrichsweikamp
parents:
diff changeset
81 bra strcat_prom
heinrichsweikamp
parents:
diff changeset
82
heinrichsweikamp
parents:
diff changeset
83 ; Append then print multi-lingual text from FSR1 12bit pointers, to buffer at FRS2.
heinrichsweikamp
parents:
diff changeset
84 ;
heinrichsweikamp
parents:
diff changeset
85 ; Input: FSR1 = 12bit pointer to multi-lingual text.
heinrichsweikamp
parents:
diff changeset
86 ; FSR2 = Current position in buffer.
heinrichsweikamp
parents:
diff changeset
87 ; Output: FSR2 points to closing null byte in buffer.
heinrichsweikamp
parents:
diff changeset
88 ; Trashed: TBLPTR, TABLAT.
heinrichsweikamp
parents:
diff changeset
89 global strcat_text_print
heinrichsweikamp
parents:
diff changeset
90 strcat_text_print:
heinrichsweikamp
parents:
diff changeset
91 rcall text_get_tblptr
heinrichsweikamp
parents:
diff changeset
92 bra strcat_prom_print
heinrichsweikamp
parents:
diff changeset
93
heinrichsweikamp
parents:
diff changeset
94 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
95 ; Get pointer to multilingual texl in TBLPTR
heinrichsweikamp
parents:
diff changeset
96 ;
heinrichsweikamp
parents:
diff changeset
97 ; Input: FSR1 = 12bits of text handle.
heinrichsweikamp
parents:
diff changeset
98 ; opt_language = current language.
heinrichsweikamp
parents:
diff changeset
99 ; Output: TBLPTR = 24bits of PROM address.
heinrichsweikamp
parents:
diff changeset
100 ;
heinrichsweikamp
parents:
diff changeset
101 global text_get_tblptr
heinrichsweikamp
parents:
diff changeset
102 text_get_tblptr:
heinrichsweikamp
parents:
diff changeset
103 extern text_english_base
heinrichsweikamp
parents:
diff changeset
104 movlw UPPER(text_english_base); Complete 12bits to 24bits address.
heinrichsweikamp
parents:
diff changeset
105 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
106 movlw HIGH(text_english_base)
heinrichsweikamp
parents:
diff changeset
107 andlw 0xF0
heinrichsweikamp
parents:
diff changeset
108 iorwf FSR1H,W
heinrichsweikamp
parents:
diff changeset
109 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
110 movff FSR1L,TBLPTRL
heinrichsweikamp
parents:
diff changeset
111
heinrichsweikamp
parents:
diff changeset
112 movff opt_language,WREG ; Get lang
heinrichsweikamp
parents:
diff changeset
113 bz text_get_english ; 0 == English
heinrichsweikamp
parents:
diff changeset
114 dcfsnz WREG ; 1 == German
heinrichsweikamp
parents:
diff changeset
115 bra text_get_german
heinrichsweikamp
parents:
diff changeset
116 dcfsnz WREG ; 2 == French
heinrichsweikamp
parents:
diff changeset
117 bra text_get_french
heinrichsweikamp
parents:
diff changeset
118 dcfsnz WREG ; 3 == Italian
heinrichsweikamp
parents:
diff changeset
119 bra text_get_italian
heinrichsweikamp
parents:
diff changeset
120 ; Other ??? Keep english...
heinrichsweikamp
parents:
diff changeset
121
heinrichsweikamp
parents:
diff changeset
122 ; Read 2-byte pointer to string
heinrichsweikamp
parents:
diff changeset
123 text_get_english:
heinrichsweikamp
parents:
diff changeset
124 tblrd*+
heinrichsweikamp
parents:
diff changeset
125 movff TABLAT,WREG
heinrichsweikamp
parents:
diff changeset
126 tblrd*+
heinrichsweikamp
parents:
diff changeset
127 movff WREG,TBLPTRL
heinrichsweikamp
parents:
diff changeset
128 movff TABLAT,TBLPTRH
heinrichsweikamp
parents:
diff changeset
129 return
heinrichsweikamp
parents:
diff changeset
130
heinrichsweikamp
parents:
diff changeset
131 ; Add correction for German table:
heinrichsweikamp
parents:
diff changeset
132 text_get_german:
heinrichsweikamp
parents:
diff changeset
133 extern text_german_base
heinrichsweikamp
parents:
diff changeset
134 movlw LOW(text_german_base)
heinrichsweikamp
parents:
diff changeset
135 addwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
136 movlw HIGH(text_german_base)
heinrichsweikamp
parents:
diff changeset
137 addwfc TBLPTRH
heinrichsweikamp
parents:
diff changeset
138 movlw UPPER(text_german_base)
heinrichsweikamp
parents:
diff changeset
139 addwfc TBLPTRU
heinrichsweikamp
parents:
diff changeset
140
heinrichsweikamp
parents:
diff changeset
141 movlw LOW(text_english_base)
heinrichsweikamp
parents:
diff changeset
142 subwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
143 movlw HIGH(text_english_base)
heinrichsweikamp
parents:
diff changeset
144 subwfb TBLPTRH
heinrichsweikamp
parents:
diff changeset
145 movlw UPPER(text_english_base)
heinrichsweikamp
parents:
diff changeset
146 subwfb TBLPTRU
heinrichsweikamp
parents:
diff changeset
147 bra text_get_english
heinrichsweikamp
parents:
diff changeset
148
heinrichsweikamp
parents:
diff changeset
149 ; Add correction for French table:
heinrichsweikamp
parents:
diff changeset
150 text_get_french:
heinrichsweikamp
parents:
diff changeset
151 extern text_french_base
heinrichsweikamp
parents:
diff changeset
152 movlw LOW(text_french_base)
heinrichsweikamp
parents:
diff changeset
153 addwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
154 movlw HIGH(text_french_base)
heinrichsweikamp
parents:
diff changeset
155 addwfc TBLPTRH
heinrichsweikamp
parents:
diff changeset
156 movlw UPPER(text_french_base)
heinrichsweikamp
parents:
diff changeset
157 addwfc TBLPTRU
heinrichsweikamp
parents:
diff changeset
158
heinrichsweikamp
parents:
diff changeset
159 movlw LOW(text_english_base)
heinrichsweikamp
parents:
diff changeset
160 subwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
161 movlw HIGH(text_english_base)
heinrichsweikamp
parents:
diff changeset
162 subwfb TBLPTRH
heinrichsweikamp
parents:
diff changeset
163 movlw UPPER(text_english_base)
heinrichsweikamp
parents:
diff changeset
164 subwfb TBLPTRU
heinrichsweikamp
parents:
diff changeset
165 bra text_get_english
heinrichsweikamp
parents:
diff changeset
166
heinrichsweikamp
parents:
diff changeset
167 ; Add correction for Spanish table:
heinrichsweikamp
parents:
diff changeset
168 text_get_italian:
heinrichsweikamp
parents:
diff changeset
169 extern text_italian_base
heinrichsweikamp
parents:
diff changeset
170 movlw LOW(text_italian_base)
heinrichsweikamp
parents:
diff changeset
171 addwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
172 movlw HIGH(text_italian_base)
heinrichsweikamp
parents:
diff changeset
173 addwfc TBLPTRH
heinrichsweikamp
parents:
diff changeset
174 movlw UPPER(text_italian_base)
heinrichsweikamp
parents:
diff changeset
175 addwfc TBLPTRU
heinrichsweikamp
parents:
diff changeset
176
heinrichsweikamp
parents:
diff changeset
177 movlw LOW(text_english_base)
heinrichsweikamp
parents:
diff changeset
178 subwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
179 movlw HIGH(text_english_base)
heinrichsweikamp
parents:
diff changeset
180 subwfb TBLPTRH
heinrichsweikamp
parents:
diff changeset
181 movlw UPPER(text_english_base)
heinrichsweikamp
parents:
diff changeset
182 subwfb TBLPTRU
heinrichsweikamp
parents:
diff changeset
183 bra text_get_english
heinrichsweikamp
parents:
diff changeset
184
heinrichsweikamp
parents:
diff changeset
185 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
186 ; Copy a null-terminated string from TBLPTR to buffer.
heinrichsweikamp
parents:
diff changeset
187 ;
heinrichsweikamp
parents:
diff changeset
188 ; Input: TBLPTR : string pointer into PROM.
heinrichsweikamp
parents:
diff changeset
189 ; Output: string in buffer, FSR2 pointer on the closing null byte.
heinrichsweikamp
parents:
diff changeset
190 ;
heinrichsweikamp
parents:
diff changeset
191 global strcpy_prom
heinrichsweikamp
parents:
diff changeset
192 strcpy_prom:
heinrichsweikamp
parents:
diff changeset
193 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
194
heinrichsweikamp
parents:
diff changeset
195 ; Append a null-terminated string from TBLPTR to buffer.
heinrichsweikamp
parents:
diff changeset
196 ;
heinrichsweikamp
parents:
diff changeset
197 ; Input: TBLPTR : string pointer into PROM.
heinrichsweikamp
parents:
diff changeset
198 ; FRS2 : current character position.
heinrichsweikamp
parents:
diff changeset
199 ; Output: string in buffer, FSR2 pointer on the closing null byte.
heinrichsweikamp
parents:
diff changeset
200 ;
heinrichsweikamp
parents:
diff changeset
201 global strcat_prom
heinrichsweikamp
parents:
diff changeset
202 strcat_prom:
heinrichsweikamp
parents:
diff changeset
203 tblrd*+
heinrichsweikamp
parents:
diff changeset
204 movf TABLAT,W
heinrichsweikamp
parents:
diff changeset
205 movwf POSTINC2
heinrichsweikamp
parents:
diff changeset
206 bnz strcat_prom
heinrichsweikamp
parents:
diff changeset
207 movf POSTDEC2,W ; rewind one char in string buffer.
heinrichsweikamp
parents:
diff changeset
208 return
heinrichsweikamp
parents:
diff changeset
209
heinrichsweikamp
parents:
diff changeset
210 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
211 ; Variant that calls word processor right-away...
heinrichsweikamp
parents:
diff changeset
212 global strcpy_prom_print
heinrichsweikamp
parents:
diff changeset
213 global strcat_prom_print
heinrichsweikamp
parents:
diff changeset
214
heinrichsweikamp
parents:
diff changeset
215 strcpy_prom_print:
heinrichsweikamp
parents:
diff changeset
216 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
217 strcat_prom_print:
heinrichsweikamp
parents:
diff changeset
218 rcall strcat_prom
heinrichsweikamp
parents:
diff changeset
219 goto aa_wordprocessor
heinrichsweikamp
parents:
diff changeset
220
heinrichsweikamp
parents:
diff changeset
221 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
222
heinrichsweikamp
parents:
diff changeset
223 global start_tiny_block
heinrichsweikamp
parents:
diff changeset
224 start_tiny_block:
heinrichsweikamp
parents:
diff changeset
225 clrf WREG
heinrichsweikamp
parents:
diff changeset
226 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
227 movff WREG, win_invert
heinrichsweikamp
parents:
diff changeset
228 bra start_common
heinrichsweikamp
parents:
diff changeset
229
heinrichsweikamp
parents:
diff changeset
230 global start_tiny_invert_block
heinrichsweikamp
parents:
diff changeset
231 start_tiny_invert_block:
heinrichsweikamp
parents:
diff changeset
232 clrf WREG
heinrichsweikamp
parents:
diff changeset
233 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
234 movlw 1
heinrichsweikamp
parents:
diff changeset
235 movff WREG, win_invert
heinrichsweikamp
parents:
diff changeset
236 bra start_common
heinrichsweikamp
parents:
diff changeset
237
heinrichsweikamp
parents:
diff changeset
238 global start_small_block
heinrichsweikamp
parents:
diff changeset
239 start_small_block:
heinrichsweikamp
parents:
diff changeset
240 movlw 1
heinrichsweikamp
parents:
diff changeset
241 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
242 clrf WREG
heinrichsweikamp
parents:
diff changeset
243 movff WREG, win_invert
heinrichsweikamp
parents:
diff changeset
244 bra start_common
heinrichsweikamp
parents:
diff changeset
245
heinrichsweikamp
parents:
diff changeset
246 global start_small_invert_block
heinrichsweikamp
parents:
diff changeset
247 start_small_invert_block:
heinrichsweikamp
parents:
diff changeset
248 movlw 1
heinrichsweikamp
parents:
diff changeset
249 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
250 movff WREG, win_invert
heinrichsweikamp
parents:
diff changeset
251 bra start_common
heinrichsweikamp
parents:
diff changeset
252
heinrichsweikamp
parents:
diff changeset
253 global start_std_block
heinrichsweikamp
parents:
diff changeset
254 start_std_block:
heinrichsweikamp
parents:
diff changeset
255 movlw 2
heinrichsweikamp
parents:
diff changeset
256 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
257 clrf WREG
heinrichsweikamp
parents:
diff changeset
258 movff WREG, win_invert
heinrichsweikamp
parents:
diff changeset
259 bra start_common
heinrichsweikamp
parents:
diff changeset
260
heinrichsweikamp
parents:
diff changeset
261 global start_std_invert_block
heinrichsweikamp
parents:
diff changeset
262 start_std_invert_block:
heinrichsweikamp
parents:
diff changeset
263 movlw 2
heinrichsweikamp
parents:
diff changeset
264 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
265 movlw 1
heinrichsweikamp
parents:
diff changeset
266 movff WREG, win_invert
heinrichsweikamp
parents:
diff changeset
267 bra start_common
heinrichsweikamp
parents:
diff changeset
268
heinrichsweikamp
parents:
diff changeset
269 global start_medium_block
heinrichsweikamp
parents:
diff changeset
270 start_medium_block:
heinrichsweikamp
parents:
diff changeset
271 movlw 3
heinrichsweikamp
parents:
diff changeset
272 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
273 clrf WREG
heinrichsweikamp
parents:
diff changeset
274 movff WREG, win_invert
heinrichsweikamp
parents:
diff changeset
275 bra start_common
heinrichsweikamp
parents:
diff changeset
276
heinrichsweikamp
parents:
diff changeset
277 global start_medium_invert_block
heinrichsweikamp
parents:
diff changeset
278 start_medium_invert_block:
heinrichsweikamp
parents:
diff changeset
279 movlw 3
heinrichsweikamp
parents:
diff changeset
280 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
281 movlw 1
heinrichsweikamp
parents:
diff changeset
282 movff WREG, win_invert
heinrichsweikamp
parents:
diff changeset
283 bra start_common
heinrichsweikamp
parents:
diff changeset
284
heinrichsweikamp
parents:
diff changeset
285 global start_large_block
heinrichsweikamp
parents:
diff changeset
286 start_large_block:
heinrichsweikamp
parents:
diff changeset
287 movlw 4
heinrichsweikamp
parents:
diff changeset
288 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
289 clrf WREG
heinrichsweikamp
parents:
diff changeset
290 movff WREG, win_invert
heinrichsweikamp
parents:
diff changeset
291 bra start_common
heinrichsweikamp
parents:
diff changeset
292
heinrichsweikamp
parents:
diff changeset
293 global start_large_invert_block
heinrichsweikamp
parents:
diff changeset
294 start_large_invert_block:
heinrichsweikamp
parents:
diff changeset
295 movlw 4
heinrichsweikamp
parents:
diff changeset
296 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
297 movlw 1
heinrichsweikamp
parents:
diff changeset
298 movff WREG, win_invert
heinrichsweikamp
parents:
diff changeset
299 bra start_common
heinrichsweikamp
parents:
diff changeset
300
heinrichsweikamp
parents:
diff changeset
301 start_common:
heinrichsweikamp
parents:
diff changeset
302 VARARGS_BEGIN
heinrichsweikamp
parents:
diff changeset
303 VARARGS_GET8 win_leftx2
heinrichsweikamp
parents:
diff changeset
304 VARARGS_GET8 win_top
heinrichsweikamp
parents:
diff changeset
305 VARARGS_END
heinrichsweikamp
parents:
diff changeset
306 return
heinrichsweikamp
parents:
diff changeset
307
heinrichsweikamp
parents:
diff changeset
308 END