Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/aa_wordprocessor.asm @ 747:6e6b87566f59
minor spanish update
author | heinrichsweikamp |
---|---|
date | Fri, 23 Aug 2013 16:01:26 +0200 |
parents | d68c6a6b1f38 |
children | f32b9ad6244c |
rev | line source |
---|---|
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
1 ;============================================================================= |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
2 ; |
95 | 3 ; File aa_wordprocessor.asm |
4 ; | |
5 ; Anti-aliased word processor | |
6 ; | |
7 ; This program is free software: you can redistribute it and/or modify | |
8 ; it under the terms of the GNU General Public License as published by | |
9 ; the Free Software Foundation, either version 3 of the License, or | |
10 ; (at your option) any later version. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
11 ; |
95 | 12 ; This program is distributed in the hope that it will be useful, |
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ; GNU General Public License for more details. | |
16 ; | |
17 ; You should have received a copy of the GNU General Public License | |
18 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 ; | |
20 ; Copyright (c) 2010, JD Gascuel. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
21 ;============================================================================= |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
22 ; HISTORY |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
23 ; 2010-11-22 : [jDG] Creation. |
95 | 24 ; 2010-12-01 : [jDG] Adding 3bits antialiased fonts. |
123 | 25 ; 2010-12-30 : [jDG] Revised to put temp into ACCESSRAM0 |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
26 ; |
95 | 27 ; BUGS : |
28 ; * If the three fonts are not in the same half of the PROM memory, TBLPTRU | |
29 ; will be badly set, and font48 or font90 will display giberish... | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
30 ;============================================================================= |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
31 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
32 ; MEMORY FOOTPRINT: |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
33 ;------------------ |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
34 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
35 ; wp_wordprocessor : 8KB, including fonts. |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
36 ; aa_wordprocessor : 0.5KB code |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
37 ; + 3.5KB aa_font28 (reduced to 99 chars) |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
38 ; + 1.6KB aa_font48 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
39 ; + 2.2KB aa_font90 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
40 ; = 7.9 KB including fonts... |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
41 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
42 ; Input registers: |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
43 ; letter:26 String to print. |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
44 ; win_font Font size (0=small, 1=medium, 2=large) |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
45 ; win_color1:2 16bits unpacked color |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
46 ; win_top, win_leftx2 Position on screen |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
47 ; win_inverse Inverse video mode. |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
48 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
49 ; Available general purpose registers: |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
50 ; PRODH, PRODL (needed for array indexing) |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
51 ; FSRx 12bits. Usefull as RAM pointers. |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
52 ;============================================================================= |
123 | 53 ; Temporary variables are overlayed in bank 0 ACCESS, used also by C-code |
260
bde83cac971f
BUGFIX bb13 : deco_calc_desaturation_time() should reset TBLPTR Upper register.
JeanDo
parents:
167
diff
changeset
|
54 ; (p2_deco), MPLAB math and stdlib libraries. |
123 | 55 |
56 CBLOCK 0x000 | |
260
bde83cac971f
BUGFIX bb13 : deco_calc_desaturation_time() should reset TBLPTR Upper register.
JeanDo
parents:
167
diff
changeset
|
57 aa_flags ; Various flags for aa_wordprocessor |
bde83cac971f
BUGFIX bb13 : deco_calc_desaturation_time() should reset TBLPTR Upper register.
JeanDo
parents:
167
diff
changeset
|
58 aa_width:2 ; Width in pixels (0..319) |
bde83cac971f
BUGFIX bb13 : deco_calc_desaturation_time() should reset TBLPTR Upper register.
JeanDo
parents:
167
diff
changeset
|
59 aa_bitlen ; Count of pixels when decoding bitmaps. |
bde83cac971f
BUGFIX bb13 : deco_calc_desaturation_time() should reset TBLPTR Upper register.
JeanDo
parents:
167
diff
changeset
|
60 aa_start:2 ; PROM ptr to start of encoded bitmap |
bde83cac971f
BUGFIX bb13 : deco_calc_desaturation_time() should reset TBLPTR Upper register.
JeanDo
parents:
167
diff
changeset
|
61 aa_end:2 ; and end of it. |
bde83cac971f
BUGFIX bb13 : deco_calc_desaturation_time() should reset TBLPTR Upper register.
JeanDo
parents:
167
diff
changeset
|
62 aa_temp:2 ; Current color, divided by 2 or 4 |
123 | 63 ENDC |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
64 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
65 ; Flags allocation: |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
66 #define aa_antialias aa_flags,0 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
67 #define aa_color_quart aa_flags,1 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
68 #define aa_color_half aa_flags,2 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
69 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
70 ;------------------------------------------------------------------------------ |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
71 ; Setup pointers for a char: |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
72 ; Inputs WREG = char to draw, win_font |
123 | 73 ; Output aa_start, aa_end, win_height, aa_flags |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
74 ; Trashed PRODH, PRODL, TBLPTR, TABLAT |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
75 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
76 aa_char_setup: |
123 | 77 movwf PRODL,A ; save char into PROD for now. |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
78 |
123 | 79 movf win_font,W,BANKED ; Get font number (updates Z flag) |
80 bnz aa_char_1 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
81 |
123 | 82 ; SMALL font --------------------------------------------------------- |
83 ; Font SMALL character folding... | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
84 aa_char_0: |
123 | 85 movlw LOW aa_font28_block |
86 movwf TBLPTRL,A | |
87 movlw HIGH aa_font28_block | |
88 movwf TBLPTRH,A | |
89 bra aa_char_3 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
90 |
123 | 91 ; MEDIUM font -------------------------------------------------------- |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
92 aa_char_1: |
123 | 93 decfsz WREG,A ; This is medium font ??? |
94 bra aa_char_2 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
95 |
123 | 96 ; Font MEDIUM block: |
97 movlw LOW aa_font48_block | |
98 movwf TBLPTRL,A | |
99 movlw HIGH aa_font48_block | |
100 movwf TBLPTRH,A | |
101 bra aa_char_3 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
102 |
123 | 103 ; LARGE font --------------------------------------------------------- |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
104 aa_char_2: |
123 | 105 ; Font LARGE block: |
106 movlw LOW aa_font90_block | |
107 movwf TBLPTRL,A | |
108 movlw HIGH aa_font90_block | |
109 movwf TBLPTRH,A | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
110 |
123 | 111 ; Execute font block ------------------------------------------------- |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
112 aa_char_3: |
123 | 113 ; This is safe iff the three fonts are in the same code segment |
114 ; (and that segment do not span the 64K edge...) | |
115 movlw UPPER aa_font28_block | |
116 movwf TBLPTRU,A | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
117 |
123 | 118 ; Proceed to character substitutions |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
119 aa_char_30: |
123 | 120 tblrd*+ ; Read FROM char |
121 movf TABLAT,W ; Get it, and set Z,N | |
122 bz aa_char_32 ; Break at end of translations | |
123 | |
124 tblrd*+ ; Read TO char | |
125 cpfseq PRODL,A ; FROM == current char ? | |
126 bra aa_char_30 ; Different: loop | |
127 movff TABLAT, PRODL ; make substitution | |
128 bra aa_char_30 ; Loop. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
129 |
123 | 130 ; Make sure char is in the available range |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
131 aa_char_32: |
123 | 132 tblrd*+ ; Read first char |
133 movf TABLAT,W ; get it. | |
134 subwf PRODL,F ; (char - first) --> PRODL | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
135 |
123 | 136 tblrd*+ ; Read nb chars |
137 movf TABLAT,W ; nbchars --> WREG | |
138 tblrd*+ ; Read default char | |
139 cpfslt PRODL ; if char > WREG ? | |
140 movff TABLAT,PRODL ; replace PRODL | |
91 | 141 |
123 | 142 ; Decode font height and anti-aliasing mode |
143 clrf aa_flags,ACCESS ; Default to no AA | |
144 tblrd*+ ; Read font height + AA flag | |
145 movf TABLAT,W ; into WREG | |
146 bnn aa_char_34 ; High bit set ? | |
147 bsf aa_antialias,ACCESS ; YES : then the font is AA. | |
148 aa_char_34: | |
149 andlw 0x7F ; Keep just font height, | |
150 movwf win_height,BANKED ; then save it (its a register) | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
151 |
123 | 152 ; Set PROM pointer to the char index |
153 movf PRODL,W ; Read back char | |
154 mullw 2 ; PROD = 2*(char - base), TBLPTR=idx | |
155 movf PRODL,W | |
156 addwf TBLPTRL,F ; Add into TBLPTR (low byte) | |
157 movf PRODH,W | |
158 addwfc TBLPTRH,F ; and high byte. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
159 |
123 | 160 ; Read start and stop pointers |
161 tblrd*+ ; aa_start = PROM16(*tblptr++) | |
162 movff TABLAT,aa_start+0 ; Read low byte | |
163 tblrd*+ | |
164 movff TABLAT,aa_start+1 ; and high byte | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
165 |
123 | 166 tblrd*+ ; aa_end = PROM16(*tblptr++) |
167 movff TABLAT,aa_end+0 ; Read low byte | |
168 tblrd*+ | |
169 movff TABLAT,aa_end+1 ; and high byte | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
170 |
123 | 171 return |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
172 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
173 ;------------------------------------------------------------------------------ |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
174 ; Character width |
123 | 175 ; Inputs aa_start, aa_end, aa_width, win_height, aa_flags |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
176 ; Output width added to aa_width |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
177 ; Trashed aa_bitlen, TBLPTR, TABLAT |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
178 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
179 aa_char_width: |
123 | 180 movff aa_start+0, TBLPTRL ; TBLPTR = aa_start |
181 movff aa_start+1, TBLPTRH | |
182 clrf aa_bitlen,ACCESS ; clear reminders... | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
183 |
123 | 184 ; Read bitmap byte, and decode length: |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
185 aa_char_width_1: |
123 | 186 ifdef AA_BYTE_SWAP |
187 btg TBLPTRL,0,A ; Toggle low ptr bit. | |
188 tblrd* | |
189 movf TABLAT,W,A ; Store to WREG | |
190 btg TBLPTRL,0,A ; Get is back | |
191 tblrd*+ ; then increment (but trash TABLAT) | |
192 movwf TABLAT,A ; Then restore copy to TABLAT. | |
193 else | |
194 tblrd*+ ; Normal read... | |
195 movf TABLAT,W,A ; Store copy to WREG | |
196 endif | |
197 btfss aa_antialias,ACCESS ; Antialiased font ? | |
198 bra aa_char_width_10 ; No: always 7 bits count | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
199 |
123 | 200 bn aa_char_width_10 ; Non-white pixels ? |
201 andlw 0x1F ; Yes : 5 bits count. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
202 aa_char_width_10: |
123 | 203 andlw 0x7F ; No: 7 bit count. |
204 incf WREG,A ; WREG = repetition count | |
205 addwf aa_bitlen,F,ACCESS ; Add remaining pixels from last code. | |
206 | |
207 movf win_height,W,BANKED ; WREG = - height | |
208 negf WREG,A | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
209 |
123 | 210 ; This is a hand-made division by successive substraction of height |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
211 aa_char_width_2: |
123 | 212 addwf aa_bitlen,F,ACCESS ; Try to substract win_height |
213 bn aa_char_width_3 ; If neg it was a bad idea... | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
214 |
123 | 215 infsnz aa_width+0,F,ACCESS ; Succeded: do a 16bit increment |
216 incf aa_width+1,F,ACCESS ; on the aa_width counter. | |
217 bra aa_char_width_2 ; and loop. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
218 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
219 aa_char_width_3: |
123 | 220 negf WREG,A ; WREG = +height |
221 addwf aa_bitlen,F,ACCESS ; Restore true reminder. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
222 |
123 | 223 ; Are we done ? |
224 movf TBLPTRL,W,A ; Compare TBLPTR to aa_end | |
225 cpfseq aa_end+0,ACCESS | |
226 bra aa_char_width_1 ; Loop if LOW is different | |
227 movf TBLPTRH,W,A | |
228 cpfseq aa_end+1,ACCESS ; Loop to if HIGH is different | |
229 bra aa_char_width_1 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
230 |
123 | 231 return |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
232 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
233 ;------------------------------------------------------------------------------ |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
234 ; String width |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
235 ; Inputs letter (SHOULD BE NULL TERMINATED) |
123 | 236 ; Output aa_width, win_height |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
237 ; Trashed PROD, TBLPTR, FSR2, aa_bitlen, aa_start, aa_end, aa_flags |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
238 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
239 aa_string_width: |
123 | 240 lfsr FSR2, letter ; FSR2 pointer to start of string. |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
241 |
123 | 242 clrf aa_width+0,ACCESS ; Clear width sum. |
243 clrf aa_width+1,ACCESS ; (16 bit counter) | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
244 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
245 aa_string_width_1: |
123 | 246 movf POSTINC2,W,A ; WREG = *FSR2++ |
247 bz aa_string_width99 ; Exit if null byte encountered. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
248 |
123 | 249 rcall aa_char_setup ; setup aa_start / aa_end |
250 rcall aa_char_width ; sum-up width into aa_width | |
251 bra aa_string_width_1 ; and loop. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
252 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
253 aa_string_width99: |
123 | 254 return |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
255 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
256 ;------------------------------------------------------------------------------ |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
257 ; Decode a compressed char. |
123 | 258 ; Inputs aa_start, aa_end, win_height, win_invert, win_color1, win_color2 |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
259 ; Output none |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
260 ; Trashed TBLPTR, TABLAT, PROD, aa_bitlen, aa_flags, aa_colorDir:2 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
261 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
262 aa_decode_char: |
123 | 263 movff aa_start+0, TBLPTRL ; TBLPTR = aa_start |
264 movff aa_start+1, TBLPTRH | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
265 |
123 | 266 ; Read bitmap byte, and decode color & length |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
267 aa_decode_1: |
123 | 268 ifdef AA_BYTE_SWAP |
269 btg TBLPTRL,0,A ; Toggle low ptr bit. | |
270 tblrd* | |
271 movf TABLAT,W,A ; Store to WREG | |
272 btg TBLPTRL,0,A ; Get is back | |
273 tblrd*+ ; then increment (but trash TABLAT) | |
274 movwf TABLAT,A ; Then restore copy to TABLAT. | |
275 else | |
276 tblrd*+ ; Normal read... | |
277 movf TABLAT,W,A ; Store copy to WREG | |
278 endif | |
279 btfss aa_antialias,ACCESS ; Antialiased font ? | |
280 bra aa_decode_10 ; No: always 7 bits count | |
281 bn aa_decode_10 ; Non-white pixels ? | |
282 andlw 0x1F ; Yes : 5 bits count. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
283 aa_decode_10: |
123 | 284 andlw 0x7F ; No: 7 bit count. |
285 incf WREG,A | |
286 movwf aa_bitlen,ACCESS ; repetition count --> aa_bitlen | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
287 |
123 | 288 ;---- COLOR DECODING ------------------------------------------------- |
289 ; | |
290 ; Code Normal Inverse | |
291 ; 1xx 0% 100% : Managed by aa_decode_13 | |
292 ; 011 25% 75% | |
293 ; 010 50% 50% | |
294 ; 001 75% 25% | |
295 ; 000 100% 0% : Managed by aa_decode_13 too. | |
296 ; | |
297 movf TABLAT,W,A ; Get back code | |
298 btfss aa_antialias,ACCESS ; Antialiased font ? | |
299 bra aa_decode_13 ; NO: 1bit case | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
300 |
123 | 301 ; Asymetry test: 1xx code is another case for 1bit color. |
302 ; This have to be done before inverse video, because | |
303 ; of the asymetric processing ! | |
304 bn aa_decode_13 ; decode as not-aa | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
305 |
123 | 306 ; Manage 000 special case too: |
307 andlw 0xE0 ; Select color bits | |
308 bz aa_decode_13 ; That's a 000 ! | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
309 |
123 | 310 ; Apply reverse video, in a reversed way |
311 btfss win_invert,0 ; Inverse video mode ? | |
312 sublw 0x80 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
313 |
123 | 314 ; Move the two bits to aa_color_half and aa_color_quarter: |
315 swapf WREG ; --> 0000.0LL0 byte | |
316 iorlw b'001' ; We are in AA mode, don't forget it ! | |
317 movwf aa_flags,ACCESS ; save that to aa_color_(half/quad)/AA flags. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
318 |
123 | 319 ;---- 2 bit x RGB(16bits) computation -------------------------------- |
320 clrf PRODL ; We will accumulate result here... | |
321 clrf PRODH | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
322 |
142 | 323 ; Take color div 2 into aa_temp. Max red = 15/31 |
123 | 324 rrcf win_color1,W,BANKED ; xRRRRxGG |
325 andlw b'01111011' ; 0RRRR0GG (don't change C) | |
142 | 326 movwf aa_temp+0,ACCESS |
123 | 327 rrcf win_color2,W,BANKED ; GGGxBBBB |
328 andlw b'11101111' ; GGG0BBBB | |
142 | 329 movwf aa_temp+1,ACCESS |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
330 |
123 | 331 btfss aa_color_half,ACCESS |
332 bra aa_decode_12 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
333 |
142 | 334 movff aa_temp+0,PRODH ; Add color/2 if bit set. |
681 | 335 movff aa_temp+1,PRODL ; DISPLAY is big endian, so swap here. |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
336 aa_decode_12: |
123 | 337 btfss aa_color_quart,ACCESS |
706 | 338 bra aa_decode_12b |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
339 |
123 | 340 ; Divide it once again by 2. Max red = 7/31. |
142 | 341 rrcf aa_temp+0,W,ACCESS ; xxRRRxxG |
342 andlw b'00111001' ; 00RRR00G (don't change C) | |
343 movwf aa_temp+0,ACCESS | |
344 rrcf aa_temp+1,W,ACCESS ; GGGxxBBB | |
345 andlw b'11100111' ; GGG00BBB | |
346 movwf aa_temp+1,ACCESS | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
347 |
142 | 348 movf aa_temp+1,W,ACCESS ; Add color/4 |
123 | 349 addwf PRODL,F ; NOTE: 7/31+15/31=22/31, |
142 | 350 movf aa_temp+0,W,ACCESS ; hence composants won't overlap. |
123 | 351 addwfc PRODH,F ; In right order, to propagate carry. |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
352 |
706 | 353 aa_decode_12b: |
705 | 354 movff win_flags,WREG ; BEWARE: bank0 bit-test |
355 btfss WREG,1 ; Display1? | |
356 bra aa_decode_3 ; No, Done. | |
357 | |
706 | 358 ; Convert 16Bit RGB b'RRRRRGGG GGGBBBBB' into 24Bit RGB b'RRRRRR00 GGGGGG00 BBBBBB00' |
359 ; PRODH PRODL win_color4 win_color5 win_color6 | |
705 | 360 ; Blue |
706 | 361 movff PRODL,win_color6 |
362 bcf STATUS,C | |
363 rlcf win_color6,F ; = UUBBBBB0 | |
705 | 364 bcf STATUS,C |
706 | 365 rlcf win_color6,F ; = UBBBBB00 |
366 bcf STATUS,C | |
367 rlcf win_color6,F ; = BBBBB000 | |
368 btfsc win_color6,7 | |
369 bsf win_color6,2 | |
370 | |
705 | 371 ; Green |
372 rrcf PRODH,F | |
373 rrcf PRODL,F | |
374 rrcf PRODH,F | |
706 | 375 rrcf PRODL,F |
376 rrcf PRODH,F ; = UUURRRRR | |
377 rrcf PRODL,F ; = GGGGGGUU | |
378 bcf PRODL,1 ; = GGGGGG0U | |
379 bcf PRODL,0 ; = GGGGGG00 | |
380 movff PRODL,win_color5 | |
381 | |
705 | 382 ; Red |
383 bcf STATUS,C | |
706 | 384 rlcf PRODH,F ; = UURRRRR0 |
385 bcf STATUS,C | |
386 rlcf PRODH,F ; = URRRRR00 | |
387 bcf STATUS,C | |
388 rlcf PRODH,F ; = RRRRR000 | |
389 btfsc PRODH,7 | |
390 bsf PRODH,2 | |
391 movff PRODH,win_color4 | |
123 | 392 bra aa_decode_3 ; Done. |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
393 |
123 | 394 ; ---- Simple BLACK and WHITE cases ------------------------------ |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
395 aa_decode_13: ; Got a 1xx or a 000 code... |
123 | 396 btfsc win_invert,0 ; Inverse video mode ? |
397 xorlw 0x80 ; YES: invert levels. | |
398 bn aa_decode_2 ; Then test high bit. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
399 |
123 | 400 ; WHITE pixel (ie. full color) |
401 movff win_color1,PRODH ; current draw color | |
681 | 402 movff win_color2,PRODL ; (rem: DISPLAY is big endian) |
706 | 403 bra aa_decode_12b |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
404 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
405 aa_decode_2: |
123 | 406 clrf PRODH,A ; BLACK pixel |
407 clrf PRODL,A | |
706 | 408 clrf win_color4 |
409 clrf win_color5 | |
410 clrf win_color6 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
411 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
412 aa_decode_3: |
123 | 413 ;---- PIXEL WRITE LOOP ----------------------------------------------- |
706 | 414 ; AA_DATA_WRITE_PROD |
415 bsf DISPLAY_rs ; Data! | |
416 | |
417 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
418 btfsc WREG,1 ; Display1? | |
419 bra aa_decode_3_display1 ; Yes. | |
420 | |
421 movff PRODH,PORTD ; Move high byte to PORTD (DISPLAY is bigendian) | |
422 bcf DISPLAY_rw | |
423 bsf DISPLAY_rw | |
424 movff PRODL,PORTD ; Move low byte to PORTD | |
425 bra aa_decode_3_done | |
426 | |
427 aa_decode_3_display1: | |
428 movff win_color4,PORTD ; Move high byte to PORTD (DISPLAY is bigendian) | |
429 bcf DISPLAY_rw | |
430 bsf DISPLAY_rw | |
431 movff win_color5,PORTD ; Move low byte to PORTD | |
432 bcf DISPLAY_rw | |
433 bsf DISPLAY_rw | |
434 movff win_color6,PORTD ; Move low(est) byte to PORTD | |
435 aa_decode_3_done: | |
436 bcf DISPLAY_rw | |
437 bsf DISPLAY_rw | |
438 | |
123 | 439 decf aa_bitlen,F,ACCESS |
440 bnz aa_decode_3 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
441 |
123 | 442 ;---- BYTE-CODE LOOP ------------------------------------------------- |
443 ; Are we done ? | |
444 movf TBLPTRL,W,A ; Compare TBLPTR to aa_end | |
445 cpfseq aa_end+0,ACCESS | |
446 bra aa_decode_1 ; Loop if LOW is different | |
447 movf TBLPTRH,W,A | |
448 cpfseq aa_end+1,ACCESS ; Loop to if HIGH is different | |
449 bra aa_decode_1 | |
450 | |
451 return | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
452 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
453 ;------------------------------------------------------------------------------ |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
454 ; Setup pointers for a char: |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
455 ; Inputs : letter : string to print (SHOULD BE NULL TERMINATED) |
681 | 456 ; Output : DISPLAY commands on port D + clocks. |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
457 ; |
167 | 458 global aa_wordprocessor ; Callable from C-code. |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
459 aa_wordprocessor: |
123 | 460 ; Make sure context is well known |
461 movlb HIGH win_top ; Switch to bank 0... | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
462 |
123 | 463 rcall aa_string_width ; Set win_height, compute win_width |
681 | 464 call DISP_box_write ; Use that for the box. |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
465 |
123 | 466 ; Restart the loop for each char to print |
467 lfsr FSR2, letter ; FSR2 pointer to start of string. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
468 |
123 | 469 ; DATA bloc commande: |
470 AA_CMD_WRITE 0x22 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
471 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
472 aa_wordprocessor_1: |
123 | 473 movf POSTINC2,W,A ; WREG = *FSR2++ |
474 bz aa_wordprocessor_99 ; Exit if null byte encountered. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
475 |
123 | 476 rcall aa_char_setup ; setup aa_start / aa_end |
477 rcall aa_decode_char ; write pixels to screen | |
478 bra aa_wordprocessor_1 ; and loop. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
479 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
480 aa_wordprocessor_99: |
123 | 481 ; END of bloc commande |
482 AA_CMD_WRITE 0x00 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
483 |
123 | 484 return |