annotate src/strings.asm @ 276:e4cb495aed3d

Increase byte timeout in PC download mode, faster response to "Exit" in main menu
author heinrichsweikamp
date Tue, 12 May 2015 14:24:46 +0200
parents 653a3ab08062
children aadfe9f2edaf
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
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 251
diff changeset
14 #include "hwos.inc"
0
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
251
3fec179a6220 some cleanup, temporaly disable dive_warning.inc
heinrichsweikamp
parents: 189
diff changeset
167 ; Add correction for italian table:
0
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 bra start_common
heinrichsweikamp
parents:
diff changeset
228
heinrichsweikamp
parents:
diff changeset
229 global start_small_block
heinrichsweikamp
parents:
diff changeset
230 start_small_block:
heinrichsweikamp
parents:
diff changeset
231 movlw 1
heinrichsweikamp
parents:
diff changeset
232 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
233 bra start_common
heinrichsweikamp
parents:
diff changeset
234
heinrichsweikamp
parents:
diff changeset
235 global start_std_block
heinrichsweikamp
parents:
diff changeset
236 start_std_block:
heinrichsweikamp
parents:
diff changeset
237 movlw 2
heinrichsweikamp
parents:
diff changeset
238 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
239 bra start_common
heinrichsweikamp
parents:
diff changeset
240
heinrichsweikamp
parents:
diff changeset
241 global start_medium_block
heinrichsweikamp
parents:
diff changeset
242 start_medium_block:
heinrichsweikamp
parents:
diff changeset
243 movlw 3
heinrichsweikamp
parents:
diff changeset
244 movff WREG, win_font ; Need a bank-safe move here !
heinrichsweikamp
parents:
diff changeset
245 bra start_common
heinrichsweikamp
parents:
diff changeset
246
heinrichsweikamp
parents:
diff changeset
247 global start_large_block
heinrichsweikamp
parents:
diff changeset
248 start_large_block:
heinrichsweikamp
parents:
diff changeset
249 movlw 4
heinrichsweikamp
parents:
diff changeset
250 movff WREG, win_font ; Need a bank-safe move here !
189
e79bc535ef9e ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents: 124
diff changeset
251 ; bra start_common
0
heinrichsweikamp
parents:
diff changeset
252 start_common:
heinrichsweikamp
parents:
diff changeset
253 VARARGS_BEGIN
heinrichsweikamp
parents:
diff changeset
254 VARARGS_GET8 win_leftx2
heinrichsweikamp
parents:
diff changeset
255 VARARGS_GET8 win_top
heinrichsweikamp
parents:
diff changeset
256 VARARGS_END
124
40ff64d60054 cleanup
heinrichsweikamp
parents: 0
diff changeset
257 lfsr FSR2,buffer ; point to buffer here
0
heinrichsweikamp
parents:
diff changeset
258 return
heinrichsweikamp
parents:
diff changeset
259
heinrichsweikamp
parents:
diff changeset
260 END