Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/aa_wordprocessor.asm @ 786:0d1a82cdb3dc
compute ceiling in calc_hauptroutine_update_tissues
author | heinrichsweikamp |
---|---|
date | Mon, 30 Jun 2014 11:01:22 +0200 |
parents | f32b9ad6244c |
children | 2750099bf5bb |
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: |
775 | 105 decfsz WREG,A ; This is medium font ??? |
106 bra aa_char_2a | |
107 | |
123 | 108 ; Font LARGE block: |
109 movlw LOW aa_font90_block | |
110 movwf TBLPTRL,A | |
111 movlw HIGH aa_font90_block | |
112 movwf TBLPTRH,A | |
775 | 113 bra aa_char_3 |
114 | |
115 ; HUGE font --------------------------------------------------------- | |
116 aa_char_2a: | |
117 ; Font HUGE block: | |
118 movlw LOW aa_font120_block | |
119 movwf TBLPTRL,A | |
120 movlw HIGH aa_font120_block | |
121 movwf TBLPTRH,A | |
122 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
123 |
123 | 124 ; Execute font block ------------------------------------------------- |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
125 aa_char_3: |
123 | 126 ; This is safe iff the three fonts are in the same code segment |
127 ; (and that segment do not span the 64K edge...) | |
128 movlw UPPER aa_font28_block | |
129 movwf TBLPTRU,A | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
130 |
123 | 131 ; Proceed to character substitutions |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
132 aa_char_30: |
123 | 133 tblrd*+ ; Read FROM char |
134 movf TABLAT,W ; Get it, and set Z,N | |
135 bz aa_char_32 ; Break at end of translations | |
136 | |
137 tblrd*+ ; Read TO char | |
138 cpfseq PRODL,A ; FROM == current char ? | |
139 bra aa_char_30 ; Different: loop | |
140 movff TABLAT, PRODL ; make substitution | |
141 bra aa_char_30 ; Loop. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
142 |
123 | 143 ; 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
|
144 aa_char_32: |
123 | 145 tblrd*+ ; Read first char |
146 movf TABLAT,W ; get it. | |
147 subwf PRODL,F ; (char - first) --> PRODL | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
148 |
123 | 149 tblrd*+ ; Read nb chars |
150 movf TABLAT,W ; nbchars --> WREG | |
151 tblrd*+ ; Read default char | |
152 cpfslt PRODL ; if char > WREG ? | |
153 movff TABLAT,PRODL ; replace PRODL | |
91 | 154 |
123 | 155 ; Decode font height and anti-aliasing mode |
156 clrf aa_flags,ACCESS ; Default to no AA | |
157 tblrd*+ ; Read font height + AA flag | |
158 movf TABLAT,W ; into WREG | |
159 bnn aa_char_34 ; High bit set ? | |
160 bsf aa_antialias,ACCESS ; YES : then the font is AA. | |
161 aa_char_34: | |
162 andlw 0x7F ; Keep just font height, | |
163 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
|
164 |
123 | 165 ; Set PROM pointer to the char index |
166 movf PRODL,W ; Read back char | |
167 mullw 2 ; PROD = 2*(char - base), TBLPTR=idx | |
168 movf PRODL,W | |
169 addwf TBLPTRL,F ; Add into TBLPTR (low byte) | |
170 movf PRODH,W | |
171 addwfc TBLPTRH,F ; and high byte. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
172 |
123 | 173 ; Read start and stop pointers |
174 tblrd*+ ; aa_start = PROM16(*tblptr++) | |
175 movff TABLAT,aa_start+0 ; Read low byte | |
176 tblrd*+ | |
177 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
|
178 |
123 | 179 tblrd*+ ; aa_end = PROM16(*tblptr++) |
180 movff TABLAT,aa_end+0 ; Read low byte | |
181 tblrd*+ | |
182 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
|
183 |
123 | 184 return |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
185 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
186 ;------------------------------------------------------------------------------ |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
187 ; Character width |
123 | 188 ; 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
|
189 ; Output width added to aa_width |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
190 ; Trashed aa_bitlen, TBLPTR, TABLAT |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
191 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
192 aa_char_width: |
123 | 193 movff aa_start+0, TBLPTRL ; TBLPTR = aa_start |
194 movff aa_start+1, TBLPTRH | |
195 clrf aa_bitlen,ACCESS ; clear reminders... | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
196 |
123 | 197 ; Read bitmap byte, and decode length: |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
198 aa_char_width_1: |
123 | 199 ifdef AA_BYTE_SWAP |
200 btg TBLPTRL,0,A ; Toggle low ptr bit. | |
201 tblrd* | |
202 movf TABLAT,W,A ; Store to WREG | |
203 btg TBLPTRL,0,A ; Get is back | |
204 tblrd*+ ; then increment (but trash TABLAT) | |
205 movwf TABLAT,A ; Then restore copy to TABLAT. | |
206 else | |
207 tblrd*+ ; Normal read... | |
208 movf TABLAT,W,A ; Store copy to WREG | |
209 endif | |
210 btfss aa_antialias,ACCESS ; Antialiased font ? | |
211 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
|
212 |
123 | 213 bn aa_char_width_10 ; Non-white pixels ? |
214 andlw 0x1F ; Yes : 5 bits count. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
215 aa_char_width_10: |
123 | 216 andlw 0x7F ; No: 7 bit count. |
217 incf WREG,A ; WREG = repetition count | |
218 addwf aa_bitlen,F,ACCESS ; Add remaining pixels from last code. | |
219 | |
220 movf win_height,W,BANKED ; WREG = - height | |
221 negf WREG,A | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
222 |
123 | 223 ; 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
|
224 aa_char_width_2: |
123 | 225 addwf aa_bitlen,F,ACCESS ; Try to substract win_height |
226 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
|
227 |
123 | 228 infsnz aa_width+0,F,ACCESS ; Succeded: do a 16bit increment |
229 incf aa_width+1,F,ACCESS ; on the aa_width counter. | |
230 bra aa_char_width_2 ; and loop. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
231 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
232 aa_char_width_3: |
123 | 233 negf WREG,A ; WREG = +height |
234 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
|
235 |
123 | 236 ; Are we done ? |
237 movf TBLPTRL,W,A ; Compare TBLPTR to aa_end | |
238 cpfseq aa_end+0,ACCESS | |
239 bra aa_char_width_1 ; Loop if LOW is different | |
240 movf TBLPTRH,W,A | |
241 cpfseq aa_end+1,ACCESS ; Loop to if HIGH is different | |
242 bra aa_char_width_1 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
243 |
123 | 244 return |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
245 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
246 ;------------------------------------------------------------------------------ |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
247 ; String width |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
248 ; Inputs letter (SHOULD BE NULL TERMINATED) |
123 | 249 ; Output aa_width, win_height |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
250 ; 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
|
251 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
252 aa_string_width: |
123 | 253 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
|
254 |
123 | 255 clrf aa_width+0,ACCESS ; Clear width sum. |
256 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
|
257 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
258 aa_string_width_1: |
123 | 259 movf POSTINC2,W,A ; WREG = *FSR2++ |
260 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
|
261 |
123 | 262 rcall aa_char_setup ; setup aa_start / aa_end |
263 rcall aa_char_width ; sum-up width into aa_width | |
264 bra aa_string_width_1 ; and loop. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
265 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
266 aa_string_width99: |
123 | 267 return |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
268 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
269 ;------------------------------------------------------------------------------ |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
270 ; Decode a compressed char. |
123 | 271 ; 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
|
272 ; Output none |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
273 ; 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
|
274 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
275 aa_decode_char: |
123 | 276 movff aa_start+0, TBLPTRL ; TBLPTR = aa_start |
277 movff aa_start+1, TBLPTRH | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
278 |
123 | 279 ; Read bitmap byte, and decode color & length |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
280 aa_decode_1: |
123 | 281 ifdef AA_BYTE_SWAP |
282 btg TBLPTRL,0,A ; Toggle low ptr bit. | |
283 tblrd* | |
284 movf TABLAT,W,A ; Store to WREG | |
285 btg TBLPTRL,0,A ; Get is back | |
286 tblrd*+ ; then increment (but trash TABLAT) | |
287 movwf TABLAT,A ; Then restore copy to TABLAT. | |
288 else | |
289 tblrd*+ ; Normal read... | |
290 movf TABLAT,W,A ; Store copy to WREG | |
291 endif | |
292 btfss aa_antialias,ACCESS ; Antialiased font ? | |
293 bra aa_decode_10 ; No: always 7 bits count | |
294 bn aa_decode_10 ; Non-white pixels ? | |
295 andlw 0x1F ; Yes : 5 bits count. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
296 aa_decode_10: |
123 | 297 andlw 0x7F ; No: 7 bit count. |
298 incf WREG,A | |
299 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
|
300 |
123 | 301 ;---- COLOR DECODING ------------------------------------------------- |
302 ; | |
303 ; Code Normal Inverse | |
304 ; 1xx 0% 100% : Managed by aa_decode_13 | |
305 ; 011 25% 75% | |
306 ; 010 50% 50% | |
307 ; 001 75% 25% | |
308 ; 000 100% 0% : Managed by aa_decode_13 too. | |
309 ; | |
310 movf TABLAT,W,A ; Get back code | |
311 btfss aa_antialias,ACCESS ; Antialiased font ? | |
312 bra aa_decode_13 ; NO: 1bit case | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
313 |
123 | 314 ; Asymetry test: 1xx code is another case for 1bit color. |
315 ; This have to be done before inverse video, because | |
316 ; of the asymetric processing ! | |
317 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
|
318 |
123 | 319 ; Manage 000 special case too: |
320 andlw 0xE0 ; Select color bits | |
321 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
|
322 |
123 | 323 ; Apply reverse video, in a reversed way |
324 btfss win_invert,0 ; Inverse video mode ? | |
325 sublw 0x80 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
326 |
123 | 327 ; Move the two bits to aa_color_half and aa_color_quarter: |
328 swapf WREG ; --> 0000.0LL0 byte | |
329 iorlw b'001' ; We are in AA mode, don't forget it ! | |
330 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
|
331 |
123 | 332 ;---- 2 bit x RGB(16bits) computation -------------------------------- |
333 clrf PRODL ; We will accumulate result here... | |
334 clrf PRODH | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
335 |
142 | 336 ; Take color div 2 into aa_temp. Max red = 15/31 |
123 | 337 rrcf win_color1,W,BANKED ; xRRRRxGG |
338 andlw b'01111011' ; 0RRRR0GG (don't change C) | |
142 | 339 movwf aa_temp+0,ACCESS |
123 | 340 rrcf win_color2,W,BANKED ; GGGxBBBB |
341 andlw b'11101111' ; GGG0BBBB | |
142 | 342 movwf aa_temp+1,ACCESS |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
343 |
123 | 344 btfss aa_color_half,ACCESS |
345 bra aa_decode_12 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
346 |
142 | 347 movff aa_temp+0,PRODH ; Add color/2 if bit set. |
681 | 348 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
|
349 aa_decode_12: |
123 | 350 btfss aa_color_quart,ACCESS |
706 | 351 bra aa_decode_12b |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
352 |
123 | 353 ; Divide it once again by 2. Max red = 7/31. |
142 | 354 rrcf aa_temp+0,W,ACCESS ; xxRRRxxG |
355 andlw b'00111001' ; 00RRR00G (don't change C) | |
356 movwf aa_temp+0,ACCESS | |
357 rrcf aa_temp+1,W,ACCESS ; GGGxxBBB | |
358 andlw b'11100111' ; GGG00BBB | |
359 movwf aa_temp+1,ACCESS | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
360 |
142 | 361 movf aa_temp+1,W,ACCESS ; Add color/4 |
123 | 362 addwf PRODL,F ; NOTE: 7/31+15/31=22/31, |
142 | 363 movf aa_temp+0,W,ACCESS ; hence composants won't overlap. |
123 | 364 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
|
365 |
706 | 366 aa_decode_12b: |
705 | 367 movff win_flags,WREG ; BEWARE: bank0 bit-test |
368 btfss WREG,1 ; Display1? | |
369 bra aa_decode_3 ; No, Done. | |
370 | |
706 | 371 ; Convert 16Bit RGB b'RRRRRGGG GGGBBBBB' into 24Bit RGB b'RRRRRR00 GGGGGG00 BBBBBB00' |
372 ; PRODH PRODL win_color4 win_color5 win_color6 | |
705 | 373 ; Blue |
706 | 374 movff PRODL,win_color6 |
375 bcf STATUS,C | |
376 rlcf win_color6,F ; = UUBBBBB0 | |
705 | 377 bcf STATUS,C |
706 | 378 rlcf win_color6,F ; = UBBBBB00 |
379 bcf STATUS,C | |
380 rlcf win_color6,F ; = BBBBB000 | |
381 btfsc win_color6,7 | |
382 bsf win_color6,2 | |
383 | |
705 | 384 ; Green |
385 rrcf PRODH,F | |
386 rrcf PRODL,F | |
387 rrcf PRODH,F | |
706 | 388 rrcf PRODL,F |
389 rrcf PRODH,F ; = UUURRRRR | |
390 rrcf PRODL,F ; = GGGGGGUU | |
391 bcf PRODL,1 ; = GGGGGG0U | |
392 bcf PRODL,0 ; = GGGGGG00 | |
393 movff PRODL,win_color5 | |
394 | |
705 | 395 ; Red |
396 bcf STATUS,C | |
706 | 397 rlcf PRODH,F ; = UURRRRR0 |
398 bcf STATUS,C | |
399 rlcf PRODH,F ; = URRRRR00 | |
400 bcf STATUS,C | |
401 rlcf PRODH,F ; = RRRRR000 | |
402 btfsc PRODH,7 | |
403 bsf PRODH,2 | |
404 movff PRODH,win_color4 | |
123 | 405 bra aa_decode_3 ; Done. |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
406 |
123 | 407 ; ---- Simple BLACK and WHITE cases ------------------------------ |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
408 aa_decode_13: ; Got a 1xx or a 000 code... |
123 | 409 btfsc win_invert,0 ; Inverse video mode ? |
410 xorlw 0x80 ; YES: invert levels. | |
411 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
|
412 |
123 | 413 ; WHITE pixel (ie. full color) |
414 movff win_color1,PRODH ; current draw color | |
681 | 415 movff win_color2,PRODL ; (rem: DISPLAY is big endian) |
706 | 416 bra aa_decode_12b |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
417 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
418 aa_decode_2: |
123 | 419 clrf PRODH,A ; BLACK pixel |
420 clrf PRODL,A | |
706 | 421 clrf win_color4 |
422 clrf win_color5 | |
423 clrf win_color6 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
424 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
425 aa_decode_3: |
123 | 426 ;---- PIXEL WRITE LOOP ----------------------------------------------- |
706 | 427 ; AA_DATA_WRITE_PROD |
428 bsf DISPLAY_rs ; Data! | |
429 | |
430 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
431 btfsc WREG,1 ; Display1? | |
432 bra aa_decode_3_display1 ; Yes. | |
433 | |
434 movff PRODH,PORTD ; Move high byte to PORTD (DISPLAY is bigendian) | |
435 bcf DISPLAY_rw | |
436 bsf DISPLAY_rw | |
437 movff PRODL,PORTD ; Move low byte to PORTD | |
438 bra aa_decode_3_done | |
439 | |
440 aa_decode_3_display1: | |
441 movff win_color4,PORTD ; Move high byte to PORTD (DISPLAY is bigendian) | |
442 bcf DISPLAY_rw | |
443 bsf DISPLAY_rw | |
444 movff win_color5,PORTD ; Move low byte to PORTD | |
445 bcf DISPLAY_rw | |
446 bsf DISPLAY_rw | |
447 movff win_color6,PORTD ; Move low(est) byte to PORTD | |
448 aa_decode_3_done: | |
449 bcf DISPLAY_rw | |
450 bsf DISPLAY_rw | |
451 | |
123 | 452 decf aa_bitlen,F,ACCESS |
453 bnz aa_decode_3 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
454 |
123 | 455 ;---- BYTE-CODE LOOP ------------------------------------------------- |
456 ; Are we done ? | |
457 movf TBLPTRL,W,A ; Compare TBLPTR to aa_end | |
458 cpfseq aa_end+0,ACCESS | |
459 bra aa_decode_1 ; Loop if LOW is different | |
460 movf TBLPTRH,W,A | |
461 cpfseq aa_end+1,ACCESS ; Loop to if HIGH is different | |
462 bra aa_decode_1 | |
463 | |
464 return | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
465 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
466 ;------------------------------------------------------------------------------ |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
467 ; Setup pointers for a char: |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
468 ; Inputs : letter : string to print (SHOULD BE NULL TERMINATED) |
681 | 469 ; Output : DISPLAY commands on port D + clocks. |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
470 ; |
167 | 471 global aa_wordprocessor ; Callable from C-code. |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
472 aa_wordprocessor: |
123 | 473 ; Make sure context is well known |
474 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
|
475 |
123 | 476 rcall aa_string_width ; Set win_height, compute win_width |
681 | 477 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
|
478 |
123 | 479 ; Restart the loop for each char to print |
480 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
|
481 |
123 | 482 ; DATA bloc commande: |
483 AA_CMD_WRITE 0x22 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
484 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
485 aa_wordprocessor_1: |
123 | 486 movf POSTINC2,W,A ; WREG = *FSR2++ |
487 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
|
488 |
123 | 489 rcall aa_char_setup ; setup aa_start / aa_end |
490 rcall aa_decode_char ; write pixels to screen | |
491 bra aa_wordprocessor_1 ; and loop. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
492 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
493 aa_wordprocessor_99: |
123 | 494 ; END of bloc commande |
495 AA_CMD_WRITE 0x00 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
496 |
123 | 497 return |