Mercurial > public > hwos_code
annotate src/strings.asm @ 230:f6548e8f06f5
Bugfix: Check for divemode before checking for menu
author | mh@mh-THINK |
---|---|
date | Fri, 20 Feb 2015 00:15:22 +0100 |
parents | e79bc535ef9e |
children | 3fec179a6220 |
rev | line source |
---|---|
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 bra start_common | |
228 | |
229 global start_small_block | |
230 start_small_block: | |
231 movlw 1 | |
232 movff WREG, win_font ; Need a bank-safe move here ! | |
233 bra start_common | |
234 | |
235 global start_std_block | |
236 start_std_block: | |
237 movlw 2 | |
238 movff WREG, win_font ; Need a bank-safe move here ! | |
239 bra start_common | |
240 | |
241 global start_medium_block | |
242 start_medium_block: | |
243 movlw 3 | |
244 movff WREG, win_font ; Need a bank-safe move here ! | |
245 bra start_common | |
246 | |
247 global start_large_block | |
248 start_large_block: | |
249 movlw 4 | |
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 | 252 start_common: |
253 VARARGS_BEGIN | |
254 VARARGS_GET8 win_leftx2 | |
255 VARARGS_GET8 win_top | |
256 VARARGS_END | |
124 | 257 lfsr FSR2,buffer ; point to buffer here |
0 | 258 return |
259 | |
260 END |