0
|
1 ;=============================================================================
|
|
2 ;
|
604
|
3 ; File strings.asm V2.99c
|
0
|
4 ;
|
|
5 ; Implementation code various string functions.
|
|
6 ;
|
|
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
|
|
8 ;=============================================================================
|
|
9 ; HISTORY
|
604
|
10 ; 2010-12-02 : [jDG] Creation
|
0
|
11 ;
|
|
12 ; See strings.inc for doc and public calling macros.
|
|
13
|
275
|
14 #include "hwos.inc"
|
0
|
15 #include "varargs.inc"
|
|
16
|
604
|
17 extern aa_wordprocessor
|
|
18
|
|
19 strings CODE
|
0
|
20
|
|
21 ;=============================================================================
|
604
|
22 ; Variants that call word_processor at the end
|
|
23
|
|
24 global strcpy_block_print
|
0
|
25 strcpy_block_print:
|
604
|
26 lfsr FSR2,buffer
|
|
27 global strcat_block_print
|
0
|
28 strcat_block_print:
|
604
|
29 clrf PRODL,A
|
|
30 bra strings_common
|
|
31
|
0
|
32
|
604
|
33 ; Variants that do not call word_processor at end
|
|
34
|
|
35 global strcpy_block
|
0
|
36 strcpy_block:
|
604
|
37 lfsr FSR2,buffer
|
|
38 global strcat_block
|
0
|
39 strcat_block:
|
604
|
40 setf PRODL,A
|
|
41
|
|
42
|
|
43 ; Common part: append the string from PROM return address
|
0
|
44
|
604
|
45 strings_common:
|
|
46 VARARGS_BEGIN
|
|
47 rcall strcat_prom
|
|
48 VARARGS_ALIGN
|
|
49 VARARGS_END
|
0
|
50
|
604
|
51 btfsc PRODL,0,A ; ahall we print afterwards?
|
|
52 return ; NO - then return straight away
|
|
53 goto aa_wordprocessor ; YES - print it...
|
0
|
54
|
|
55 ;=============================================================================
|
604
|
56 ; Copy multi-lingual text from FSR1 12 bit pointer to buffer
|
0
|
57 ;
|
604
|
58 ; Input: FSR1 = 12 bit pointer to multi-lingual text
|
|
59 ; Output: FSR2 pointing to closing null byte in buffer
|
|
60 ; Trashed: TBLPTR, TABLAT
|
|
61
|
|
62 global strcpy_text
|
0
|
63 strcpy_text:
|
604
|
64 rcall text_get_tblptr
|
|
65 bra strcpy_prom
|
0
|
66
|
604
|
67 ; Copy and print multi-lingual text from FSR1 12 bit pointer to buffer
|
0
|
68 ;
|
604
|
69 ; Input: FSR1 = 12 bit pointer to multi-lingual text
|
|
70 ; Output: FSR2 pointing to closing null byte in buffer
|
|
71 ; Trashed: TBLPTR, TABLAT
|
|
72
|
|
73 global strcpy_text_print
|
0
|
74 strcpy_text_print:
|
604
|
75 rcall text_get_tblptr
|
|
76 bra strcpy_prom_print
|
0
|
77
|
604
|
78 ; Append multi-lingual text from FSR1 12 bit pointers to buffer at FRS2
|
0
|
79 ;
|
604
|
80 ; Input: FSR1 = 12 bit pointer to multi-lingual text
|
|
81 ; FSR2 = current position in buffer
|
|
82 ; Output: FSR2 pointing to closing null byte in buffer
|
|
83 ; Trashed: TBLPTR, TABLAT
|
|
84
|
|
85 global strcat_text
|
0
|
86 strcat_text:
|
604
|
87 rcall text_get_tblptr
|
|
88 bra strcat_prom
|
0
|
89
|
604
|
90 ; Append and print multi-lingual text from FSR1 12 bit pointers to buffer at FRS2
|
0
|
91 ;
|
604
|
92 ; Input: FSR1 = 12 bit pointer to multi-lingual text
|
|
93 ; FSR2 = current position in buffer
|
|
94 ; Output: FSR2 pointing to closing null byte in buffer
|
|
95 ; Trashed: TBLPTR, TABLAT
|
|
96
|
|
97 global strcat_text_print
|
0
|
98 strcat_text_print:
|
604
|
99 rcall text_get_tblptr
|
|
100 bra strcat_prom_print
|
0
|
101
|
|
102 ;=============================================================================
|
604
|
103 ; Get pointer to multilingual text in TBLPTR
|
0
|
104 ;
|
604
|
105 ; Input: FSR1 = 12 bit text handle
|
|
106 ; opt_language = current language
|
|
107 ; Output: TBLPTR = 24 bit PROM address
|
|
108
|
|
109 global text_get_tblptr
|
0
|
110 text_get_tblptr:
|
604
|
111 extern text_1_base
|
|
112 movlw UPPER(text_1_base) ; complete 12 bit address to 24 bit address
|
|
113 movwf TBLPTRU
|
|
114 movlw HIGH(text_1_base)
|
|
115 andlw 0xF0
|
|
116 iorwf FSR1H,W
|
|
117 movwf TBLPTRH
|
|
118 movff FSR1L,TBLPTRL
|
560
|
119
|
604
|
120 IF _language_2!=none
|
|
121 movff opt_language,WREG ; get language selection
|
|
122 bz text_get_lang1 ; 0: language 1
|
|
123 dcfsnz WREG
|
|
124 bra text_get_lang2 ; 1: language 2
|
|
125 ENDIF
|
0
|
126
|
604
|
127 text_get_lang1: ; read 2-byte pointer to string
|
|
128 tblrd*+
|
|
129 movff TABLAT,WREG
|
|
130 tblrd*+
|
|
131 movff WREG,TBLPTRL
|
|
132 movff TABLAT,TBLPTRH
|
|
133 return
|
0
|
134
|
604
|
135 IF _language_2!=none
|
|
136 text_get_lang2: ; add offset for second language
|
|
137 extern text_2_base
|
|
138 movlw LOW(text_2_base)
|
|
139 addwf TBLPTRL
|
|
140 movlw HIGH(text_2_base)
|
|
141 addwfc TBLPTRH
|
|
142 movlw UPPER(text_2_base)
|
|
143 addwfc TBLPTRU
|
0
|
144
|
604
|
145 movlw LOW(text_1_base)
|
|
146 subwf TBLPTRL
|
|
147 movlw HIGH(text_1_base)
|
|
148 subwfb TBLPTRH
|
|
149 movlw UPPER(text_1_base)
|
|
150 subwfb TBLPTRU
|
|
151 bra text_get_lang1
|
|
152 ENDIF
|
|
153
|
0
|
154 ;=============================================================================
|
604
|
155 ; Copy a null-terminated string from TBLPTR to buffer
|
0
|
156 ;
|
604
|
157 ; Input: TBLPTR : string pointer into PROM
|
|
158 ; Output: string in buffer, FSR2 pointing to the closing null byte
|
0
|
159 ;
|
604
|
160 global strcpy_prom
|
0
|
161 strcpy_prom:
|
604
|
162 lfsr FSR2,buffer
|
|
163 ;bra strcat_prom
|
0
|
164
|
604
|
165 ; Append a null-terminated string from TBLPTR to buffer
|
0
|
166 ;
|
604
|
167 ; Input: TBLPTR : string pointer into PROM
|
|
168 ; FRS2 : current character position
|
|
169 ; Output: string in buffer, FSR2 pointing to the closing null byte
|
0
|
170 ;
|
604
|
171 global strcat_prom
|
0
|
172 strcat_prom:
|
604
|
173 tblrd*+
|
|
174 movf TABLAT,W
|
|
175 movwf POSTINC2
|
|
176 bnz strcat_prom
|
|
177 movf POSTDEC2,W ; step back one char
|
|
178 return
|
0
|
179
|
|
180 ;=============================================================================
|
|
181 ; Variant that calls word processor right-away...
|
|
182
|
604
|
183 global strcpy_prom_print
|
|
184 global strcat_prom_print
|
0
|
185 strcpy_prom_print:
|
604
|
186 lfsr FSR2,buffer
|
0
|
187 strcat_prom_print:
|
604
|
188 rcall strcat_prom
|
|
189 goto aa_wordprocessor
|
0
|
190
|
|
191 ;=============================================================================
|
|
192
|
604
|
193 global start_tiny_block
|
0
|
194 start_tiny_block:
|
604
|
195 clrf WREG
|
|
196 movff WREG, win_font ; needs a bank-safe move here !
|
|
197 bra start_common
|
0
|
198
|
604
|
199 global start_small_block
|
0
|
200 start_small_block:
|
604
|
201 movlw 1
|
|
202 movff WREG, win_font ; needs a bank-safe move here !
|
|
203 bra start_common
|
0
|
204
|
604
|
205 global start_std_block
|
0
|
206 start_std_block:
|
604
|
207 movlw 2
|
|
208 movff WREG, win_font ; needs a bank-safe move here !
|
|
209 bra start_common
|
0
|
210
|
604
|
211 global start_medium_block
|
0
|
212 start_medium_block:
|
604
|
213 movlw 3
|
|
214 movff WREG, win_font ; needs a bank-safe move here !
|
|
215 bra start_common
|
0
|
216
|
604
|
217 global start_large_block
|
0
|
218 start_large_block:
|
604
|
219 movlw 4
|
|
220 movff WREG, win_font ; needs a bank-safe move here !
|
|
221 ;bra start_common
|
|
222
|
0
|
223 start_common:
|
604
|
224 VARARGS_BEGIN
|
|
225 VARARGS_GET8 win_leftx2
|
|
226 VARARGS_GET8 win_top
|
|
227 VARARGS_END
|
|
228 lfsr FSR2,buffer ; point to buffer
|
|
229 return
|
0
|
230
|
604
|
231 END |