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