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