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