Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/aa_wordprocessor.asm @ 128:4c588c3d1f12
Saturation graphs in customview divemode
author | JeanDo |
---|---|
date | Tue, 04 Jan 2011 15:14:42 +0100 |
parents | 6a94f96e9cea |
children | 8b75ba28d641 |
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 |
54 ; (p2_deco), MPLAB math abd stdlib libraries. | |
55 | |
56 CBLOCK 0x000 | |
57 aa_flags ; Various flags for aa_wordprocessor | |
58 aa_width:2 ; Width in pixels (0..319) | |
59 aa_bitlen ; Count of pixels when decoding bitmaps. | |
60 aa_start:2 ; PROM ptr to start of encoded bitmap | |
61 aa_end:2 ; and end of it. | |
62 aa_colorDiv:2 ; Current color, divided by 2 or 4 | |
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 ; Fast macros to write to OLED display. |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
258 ; Adding a call/return adds 3 words and a pipeline flush, hence make it |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
259 ; nearly twice slower... |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
260 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
261 ; Input : commande as macro parameter. |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
262 ; Output : NONE |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
263 ; Trash : WREG |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
264 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
265 AA_CMD_WRITE macro cmd |
123 | 266 movlw cmd |
267 rcall PLED_CmdWrite | |
268 ; bcf oled_rs ; Cmd mode | |
269 ; movwf PORTD,A | |
270 ; bcf oled_rw ; Tick the clock | |
271 ; bsf oled_rw | |
272 endm | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
273 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
274 ; Input : PRODH:L as 16bits data. |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
275 ; Output : NONE |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
276 ; Trash : NONE |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
277 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
278 AA_DATA_WRITE_PROD macro |
123 | 279 rcall PLED_DataWrite_PROD |
280 ; bsf oled_rs ; Data mode | |
281 ; movff PRODH,PORTD ; NOTE: OLED is BIGENDIAN! | |
282 ; bcf oled_rw ; Tick the clock | |
283 ; bsf oled_rw | |
284 ; movff PRODL,PORTD | |
285 ; bcf oled_rw ; Tick the clock | |
286 ; bsf oled_rw | |
287 endm | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
288 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
289 ;------------------------------------------------------------------------------ |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
290 ; Output OLED Window Address commands. |
123 | 291 ; Inputs : win_top, win_leftx2, win_height, aa_width. |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
292 ; Output : PortD commands. |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
293 ; Trashed: PROD |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
294 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
295 aa_box_cmd: |
123 | 296 movf win_leftx2,W,BANKED ; Compute left = 2*leftx2 |
297 mullw 2 | |
298 AA_CMD_WRITE 0x35 ; this is the left border | |
299 AA_DATA_WRITE_PROD | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
300 |
123 | 301 movf aa_width+0,W,ACCESS ; right = left + width - 1 |
302 addwf PRODL,F,A | |
303 movf aa_width+1,W,ACCESS | |
304 addwfc PRODH,F,A | |
305 decf PRODL,F,A ; decrement result | |
306 bc aa_box_cmd_1 ; No borrow (/Carry) ? skip propagating. | |
307 decf PRODH,F,A | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
308 aa_box_cmd_1: |
123 | 309 AA_CMD_WRITE 0x36 ; Write and the right border |
310 AA_DATA_WRITE_PROD | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
311 |
123 | 312 movf win_top,W,BANKED ; Write top / bottom window |
313 movwf PRODH,A ; (remember PRODH output first) | |
314 addwf win_height,W,BANKED | |
315 decf WREG,A | |
316 movwf PRODL,A ; And PRODL is later... | |
317 AA_CMD_WRITE 0x37 | |
318 AA_DATA_WRITE_PROD | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
319 |
123 | 320 movf win_top,W,BANKED ; Start ptr top |
321 mullw 1 ; Load into PRODH:L | |
322 AA_CMD_WRITE 0x20 | |
323 AA_DATA_WRITE_PROD | |
96 | 324 |
123 | 325 movf win_leftx2,W,BANKED ; Start ptr left |
326 mullw 2 | |
327 AA_CMD_WRITE 0x21 | |
328 AA_DATA_WRITE_PROD | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
329 |
123 | 330 return |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
331 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
332 ;------------------------------------------------------------------------------ |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
333 ; Decode a compressed char. |
123 | 334 ; 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
|
335 ; Output none |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
336 ; 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
|
337 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
338 aa_decode_char: |
123 | 339 movff aa_start+0, TBLPTRL ; TBLPTR = aa_start |
340 movff aa_start+1, TBLPTRH | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
341 |
123 | 342 ; Read bitmap byte, and decode color & length |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
343 aa_decode_1: |
123 | 344 ifdef AA_BYTE_SWAP |
345 btg TBLPTRL,0,A ; Toggle low ptr bit. | |
346 tblrd* | |
347 movf TABLAT,W,A ; Store to WREG | |
348 btg TBLPTRL,0,A ; Get is back | |
349 tblrd*+ ; then increment (but trash TABLAT) | |
350 movwf TABLAT,A ; Then restore copy to TABLAT. | |
351 else | |
352 tblrd*+ ; Normal read... | |
353 movf TABLAT,W,A ; Store copy to WREG | |
354 endif | |
355 btfss aa_antialias,ACCESS ; Antialiased font ? | |
356 bra aa_decode_10 ; No: always 7 bits count | |
357 bn aa_decode_10 ; Non-white pixels ? | |
358 andlw 0x1F ; Yes : 5 bits count. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
359 aa_decode_10: |
123 | 360 andlw 0x7F ; No: 7 bit count. |
361 incf WREG,A | |
362 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
|
363 |
123 | 364 ;---- COLOR DECODING ------------------------------------------------- |
365 ; | |
366 ; Code Normal Inverse | |
367 ; 1xx 0% 100% : Managed by aa_decode_13 | |
368 ; 011 25% 75% | |
369 ; 010 50% 50% | |
370 ; 001 75% 25% | |
371 ; 000 100% 0% : Managed by aa_decode_13 too. | |
372 ; | |
373 movf TABLAT,W,A ; Get back code | |
374 btfss aa_antialias,ACCESS ; Antialiased font ? | |
375 bra aa_decode_13 ; NO: 1bit case | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
376 |
123 | 377 ; Asymetry test: 1xx code is another case for 1bit color. |
378 ; This have to be done before inverse video, because | |
379 ; of the asymetric processing ! | |
380 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
|
381 |
123 | 382 ; Manage 000 special case too: |
383 andlw 0xE0 ; Select color bits | |
384 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
|
385 |
123 | 386 ; Apply reverse video, in a reversed way |
387 btfss win_invert,0 ; Inverse video mode ? | |
388 sublw 0x80 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
389 |
123 | 390 ; Move the two bits to aa_color_half and aa_color_quarter: |
391 swapf WREG ; --> 0000.0LL0 byte | |
392 iorlw b'001' ; We are in AA mode, don't forget it ! | |
393 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
|
394 |
123 | 395 ;---- 2 bit x RGB(16bits) computation -------------------------------- |
396 clrf PRODL ; We will accumulate result here... | |
397 clrf PRODH | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
398 |
123 | 399 ; Take color div 2 into aa_colorDiv. Max red = 15/31 |
400 rrcf win_color1,W,BANKED ; xRRRRxGG | |
401 andlw b'01111011' ; 0RRRR0GG (don't change C) | |
402 movwf aa_colorDiv+0,ACCESS | |
403 rrcf win_color2,W,BANKED ; GGGxBBBB | |
404 andlw b'11101111' ; GGG0BBBB | |
405 movwf aa_colorDiv+1,ACCESS | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
406 |
123 | 407 btfss aa_color_half,ACCESS |
408 bra aa_decode_12 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
409 |
123 | 410 movff aa_colorDiv+0,PRODH ; Add color/2 if bit set. |
411 movff aa_colorDiv+1,PRODL ; OLED is big endian, so swap here. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
412 aa_decode_12: |
123 | 413 btfss aa_color_quart,ACCESS |
414 bra aa_decode_3 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
415 |
123 | 416 ; Divide it once again by 2. Max red = 7/31. |
417 rrcf aa_colorDiv+0,W,ACCESS ; xxRRRxxG | |
418 andlw b'00111001' ; 00RRR00G (don't change C) | |
419 movwf aa_colorDiv+0,ACCESS | |
420 rrcf aa_colorDiv+1,W,ACCESS ; GGGxxBBB | |
421 andlw b'11100111' ; GGG00BBB | |
422 movwf aa_colorDiv+1,ACCESS | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
423 |
123 | 424 movf aa_colorDiv+1,W,ACCESS ; Add color/4 |
425 addwf PRODL,F ; NOTE: 7/31+15/31=22/31, | |
426 movf aa_colorDiv+0,W,ACCESS ; hence composants won't overlap. | |
427 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
|
428 |
123 | 429 bra aa_decode_3 ; Done. |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
430 |
123 | 431 ; ---- Simple BLACK and WHITE cases ------------------------------ |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
432 aa_decode_13: ; Got a 1xx or a 000 code... |
123 | 433 btfsc win_invert,0 ; Inverse video mode ? |
434 xorlw 0x80 ; YES: invert levels. | |
435 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
|
436 |
123 | 437 ; WHITE pixel (ie. full color) |
438 movff win_color1,PRODH ; current draw color | |
439 movff win_color2,PRODL ; (rem: OLED is big endian) | |
440 bra aa_decode_3 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
441 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
442 aa_decode_2: |
123 | 443 clrf PRODH,A ; BLACK pixel |
444 clrf PRODL,A | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
445 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
446 aa_decode_3: |
123 | 447 ;---- PIXEL WRITE LOOP ----------------------------------------------- |
448 AA_DATA_WRITE_PROD | |
449 decf aa_bitlen,F,ACCESS | |
450 bnz aa_decode_3 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
451 |
123 | 452 ;---- BYTE-CODE LOOP ------------------------------------------------- |
453 ; Are we done ? | |
454 movf TBLPTRL,W,A ; Compare TBLPTR to aa_end | |
455 cpfseq aa_end+0,ACCESS | |
456 bra aa_decode_1 ; Loop if LOW is different | |
457 movf TBLPTRH,W,A | |
458 cpfseq aa_end+1,ACCESS ; Loop to if HIGH is different | |
459 bra aa_decode_1 | |
460 | |
461 return | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
462 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
463 ;------------------------------------------------------------------------------ |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
464 ; Setup pointers for a char: |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
465 ; Inputs : letter : string to print (SHOULD BE NULL TERMINATED) |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
466 ; Output : OLED commands on port D + clocks. |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
467 ; |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
468 aa_wordprocessor: |
123 | 469 ; Make sure context is well known |
470 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
|
471 |
123 | 472 rcall aa_string_width ; Set win_height, compute win_width |
473 rcall aa_box_cmd ; Use that for the box. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
474 |
123 | 475 ; Restart the loop for each char to print |
476 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
|
477 |
123 | 478 ; DATA bloc commande: |
479 AA_CMD_WRITE 0x22 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
480 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
481 aa_wordprocessor_1: |
123 | 482 movf POSTINC2,W,A ; WREG = *FSR2++ |
483 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
|
484 |
123 | 485 rcall aa_char_setup ; setup aa_start / aa_end |
486 rcall aa_decode_char ; write pixels to screen | |
487 bra aa_wordprocessor_1 ; and loop. | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
488 |
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
489 aa_wordprocessor_99: |
123 | 490 ; END of bloc commande |
491 AA_CMD_WRITE 0x00 | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff
changeset
|
492 |
123 | 493 return |