0
|
1 ;=============================================================================
|
|
2 ;
|
634
|
3 ; File strings.asm * combined next generation V3.09.4l
|
0
|
4 ;
|
|
5 ; Implementation code various string functions.
|
|
6 ;
|
654
|
7 ; Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
|
0
|
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
|
634
|
18 extern text_1_base
|
|
19 extern text_1_text
|
604
|
20
|
634
|
21 IF _language_2 != none
|
|
22 extern text_2_base
|
|
23 extern text_2_text
|
|
24 ENDIF
|
623
|
25
|
0
|
26
|
|
27 ;=============================================================================
|
634
|
28 strings CODE
|
|
29 ;=============================================================================
|
|
30
|
|
31 ;-----------------------------------------------------------------------------
|
|
32 ; to be used via Macro: Variants that call the Word Processor at the end
|
|
33 ;-----------------------------------------------------------------------------
|
604
|
34
|
634
|
35 global strcpy_block_print
|
|
36 global strcat_block_print
|
|
37 strcpy_block_print:
|
|
38 lfsr FSR2,buffer ; load pointer to buffer
|
|
39 strcat_block_print:
|
|
40 bsf aa_aux_flag ; call Word Processor
|
|
41 bra strings_com_block_VARARG; continue with common part for VARARGS PROM texts
|
0
|
42
|
604
|
43
|
|
44 global strcpy_text_print
|
634
|
45 global strcat_text_print
|
0
|
46 strcpy_text_print:
|
634
|
47 lfsr FSR2,buffer ; load pointer to buffer
|
0
|
48 strcat_text_print:
|
634
|
49 bsf aa_aux_flag ; call Word Processor
|
|
50 bra strings_com_text_VARARG ; continue with common part for VARARGS multi-lingual texts
|
|
51
|
|
52
|
|
53 global putc_print
|
|
54 global print
|
|
55 putc_print:
|
|
56 movwf POSTINC2 ; append the character to the string
|
|
57 print:
|
|
58 bsf aa_aux_flag ; call Word Processor
|
|
59 bra strings_common_term ; append string terminator
|
|
60
|
|
61
|
|
62 ;-----------------------------------------------------------------------------
|
|
63 ; to be used via Macro: Variants that do not call the Word Processor at end
|
|
64 ;-----------------------------------------------------------------------------
|
|
65
|
|
66 global strcpy_block
|
|
67 global strcat_block
|
|
68 strcpy_block:
|
|
69 lfsr FSR2,buffer ; load pointer to buffer
|
|
70 strcat_block:
|
|
71 bcf aa_aux_flag ; do not call Word Processor
|
|
72 bra strings_com_block_VARARG; continue with common part for VARARGS PROM texts
|
|
73
|
|
74
|
|
75 global strcpy_text
|
|
76 global strcat_text
|
|
77 strcpy_text:
|
|
78 lfsr FSR2,buffer ; load pointer to buffer
|
|
79 strcat_text:
|
|
80 bcf aa_aux_flag ; do not call Word Processor
|
|
81 bra strings_com_text_VARARG ; continue with common part for VARARGS multi-lingual texts
|
|
82
|
0
|
83
|
634
|
84 global strcpy_text_FSR
|
|
85 global strcat_text_FSR
|
|
86 strcpy_text_FSR:
|
|
87 lfsr FSR2,buffer ; load pointer to buffer
|
|
88 strcat_text_FSR:
|
|
89 bcf aa_aux_flag ; do not call Word Processor
|
|
90 bra strings_com_text_FSR ; continue with common part for FSR multi-lingual texts
|
|
91
|
|
92
|
|
93 ;-----------------------------------------------------------------------------
|
|
94 ; Common Parts for all above Functions
|
|
95 ;-----------------------------------------------------------------------------
|
|
96
|
|
97 strings_com_block_VARARG:
|
|
98 VARARGS_BEGIN
|
|
99 rcall strcat_prom ; append text to buffer
|
|
100 VARARGS_ALIGN ; word-align the table pointer
|
|
101 VARARGS_END
|
|
102 bra strings_common_term ; continue with common part for all texts
|
|
103
|
|
104 strings_com_text_VARARG:
|
|
105 VARARGS_BEGIN
|
|
106 rcall text_get_fsr ; get pointer to multi-lingual text
|
|
107 VARARGS_END
|
|
108 ;bra strings_com_text_FSR ; continue with common part for FSR multi-lingual texts
|
|
109
|
|
110 strings_com_text_FSR:
|
|
111 rcall text_get_tblptr ; get pointer to translated text
|
|
112 rcall strcat_prom ; append text to buffer
|
|
113 ;bra strings_common_term ; continue with common part for all texts
|
|
114
|
|
115 strings_common_term:
|
|
116 clrf INDF2 ; append string terminator
|
|
117 btfss aa_aux_flag ; shall call the Word Processor?
|
|
118 return ; NO - done
|
|
119 goto aa_wordprocessor ; YES - dump buffer to screen and return
|
|
120
|
|
121
|
|
122 ;-----------------------------------------------------------------------------
|
|
123 ; Helper Function - get Pointer to multi-lingual Text into FSR1
|
0
|
124 ;
|
634
|
125 text_get_fsr:
|
|
126 tblrd*+ ; get pointer, low byte
|
|
127 movff TABLAT,FSR1L ; store in FSR1L
|
|
128 tblrd*+ ; get pointer, low byte
|
|
129 movff TABLAT,FSR1H ; store in FSR1H
|
|
130 return ; done
|
|
131
|
604
|
132
|
634
|
133 ;-----------------------------------------------------------------------------
|
|
134 ; Helper Function - get Pointer to translated Text into TBLPTR
|
|
135 ;
|
|
136 ; Input: FSR1 = pointer to multi-lingual text
|
|
137 ; opt_language = selected language
|
|
138 ; Output: TBLPTR = 24 bit PROM address 0x09000 / 0x09400 -> problem
|
|
139 ; 0x07000 / 0x07400 -> ok
|
0
|
140 text_get_tblptr:
|
634
|
141 ; load TBLPTR with the index address of the selected text, expanded from 12 to 24 bit
|
|
142 movlw UPPER(text_1_base) ; get address, upper byte = 0x00 of index base
|
|
143 movwf TBLPTRU ; set TBLPTR, upper byte to 0x00
|
|
144 movlw HIGH(text_1_base) ; get address, high byte = 0x90 of index base
|
|
145 iorwf FSR1H,W ; add address, high byte = 0x0H from FSR1H
|
|
146 movwf TBLPTRH ; set TBLPTR, high byte to 0x9H
|
|
147 movff FSR1L,TBLPTRL ; set TBLPTR, low byte to 0xLL from FSR1L
|
560
|
148
|
634
|
149 IF _language_2 != none
|
|
150 ; adjust the index address in case language 2 is selected
|
604
|
151 movff opt_language,WREG ; get language selection
|
634
|
152 tstfsz WREG ; language 2 selected ?
|
|
153 bsf TBLPTRH,2 ; YES - add offset (0x00400) between the index tables
|
604
|
154 ENDIF
|
0
|
155
|
634
|
156 ; read the address of the translated text in 16 bit format
|
|
157 tblrd*+ ; read low byte and buffer it in WREG
|
|
158 movff TABLAT,WREG ; ...
|
|
159 tblrd*+ ; read high byte and keep it in TABLAT
|
0
|
160
|
634
|
161 ; load TBLPTR with the address of the translated text expanded to 24 bit
|
|
162 movff WREG, TBLPTRL ; set TBLPTR, low byte
|
|
163 movlw UPPER(text_1_text) ; get address, upper byte of text table
|
|
164 IF _language_2 != none
|
|
165 btfsc TBLPTRH,2 ; using language 2?
|
|
166 movlw UPPER(text_2_text) ; YES - get upper address of language 2
|
604
|
167 ENDIF
|
634
|
168 movwf TBLPTRU ; set TBLPTR, upper byte
|
|
169 movff TABLAT,TBLPTRH ; set TBLPTR, high byte
|
604
|
170
|
634
|
171 return ; done
|
|
172
|
0
|
173
|
634
|
174 ;-----------------------------------------------------------------------------
|
|
175 ; Helper Function - append a null-terminated String from TBLPTR to Buffer
|
0
|
176 ;
|
623
|
177 ; Input: TBLPTR : string pointer into PROM
|
|
178 ; FRS2 : current character position
|
|
179 ; Output: string in buffer, FSR2 pointing to the closing null byte
|
0
|
180 ;
|
|
181 strcat_prom:
|
634
|
182 tblrd*+ ; read one character from PROM
|
|
183 movf TABLAT,W ; copy character to WREG
|
|
184 movwf POSTINC2 ; copy from WREG to buffer and increment buffer pointer
|
|
185 ; was character = NULL ?
|
|
186 bnz strcat_prom ; NO - loop
|
|
187 movf POSTDEC2,W ; YES - dummy read to step back buffer pointer by 1
|
|
188 return ; - done
|
0
|
189
|
|
190
|
634
|
191 ;-----------------------------------------------------------------------------
|
|
192 ; to by used via Macro: set Font Size and Output Position in one Batch
|
|
193 ;
|
604
|
194 global start_tiny_block
|
0
|
195 start_tiny_block:
|
634
|
196 movlw .0 ; set size encoding
|
|
197 bra start_block_common ; start block
|
0
|
198
|
604
|
199 global start_small_block
|
0
|
200 start_small_block:
|
634
|
201 movlw .1 ; set size encoding
|
|
202 bra start_block_common ; start block
|
0
|
203
|
604
|
204 global start_std_block
|
0
|
205 start_std_block:
|
634
|
206 movlw .2 ; set size encoding
|
|
207 bra start_block_common ; start block
|
0
|
208
|
604
|
209 global start_medium_block
|
0
|
210 start_medium_block:
|
634
|
211 movlw .3 ; set size encoding
|
|
212 bra start_block_common ; start block
|
0
|
213
|
604
|
214 global start_large_block
|
0
|
215 start_large_block:
|
634
|
216 movlw .4 ; set size encoding
|
|
217 bra start_block_common ; start block
|
623
|
218
|
|
219 global start_huge_block
|
|
220 start_huge_block:
|
634
|
221 movlw .5 ; set size encoding
|
|
222 ;bra start_block_common ; start block
|
628
|
223
|
634
|
224 start_block_common:
|
|
225 movff WREG,font_size ; needs a bank-safe move here! (TODO: why?)
|
623
|
226
|
604
|
227 VARARGS_BEGIN
|
634
|
228 VARARGS_GET8 win_leftx2 ; get horizontal position
|
|
229 VARARGS_GET8 win_top ; get vertical position
|
604
|
230 VARARGS_END
|
634
|
231
|
|
232 lfsr FSR2,buffer ; initialize output buffer
|
|
233 return ; done
|
0
|
234
|
634
|
235 ;-----------------------------------------------------------------------------
|
|
236
|
|
237 END
|