annotate code_part1/OSTC_code_asm_part1/aa_wordprocessor.asm @ 131:03df42de03e1

Merge 129 with 130
author Heinrichsweikamp
date Wed, 05 Jan 2011 07:46:20 +0100
parents 6a94f96e9cea
children 8b75ba28d641
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
3 ; File aa_wordprocessor.asm
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
4 ;
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
5 ; Anti-aliased word processor
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
6 ;
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
7 ; This program is free software: you can redistribute it and/or modify
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
8 ; it under the terms of the GNU General Public License as published by
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
9 ; the Free Software Foundation, either version 3 of the License, or
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
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
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
12 ; This program is distributed in the hope that it will be useful,
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
15 ; GNU General Public License for more details.
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
16 ;
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
17 ; You should have received a copy of the GNU General Public License
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
18 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
19 ;
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
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
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
24 ; 2010-12-01 : [jDG] Adding 3bits antialiased fonts.
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
27 ; BUGS :
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
28 ; * If the three fonts are not in the same half of the PROM memory, TBLPTRU
d79bf9df55d7 aa_wordprocessor too fast ?
JeanDo
parents: 91
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
53 ; Temporary variables are overlayed in bank 0 ACCESS, used also by C-code
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
54 ; (p2_deco), MPLAB math abd stdlib libraries.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
55
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
56 CBLOCK 0x000
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
57 aa_flags ; Various flags for aa_wordprocessor
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
58 aa_width:2 ; Width in pixels (0..319)
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
59 aa_bitlen ; Count of pixels when decoding bitmaps.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
60 aa_start:2 ; PROM ptr to start of encoded bitmap
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
61 aa_end:2 ; and end of it.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
62 aa_colorDiv:2 ; Current color, divided by 2 or 4
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
79 movf win_font,W,BANKED ; Get font number (updates Z flag)
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
80 bnz aa_char_1
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
81
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
82 ; SMALL font ---------------------------------------------------------
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
85 movlw LOW aa_font28_block
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
86 movwf TBLPTRL,A
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
87 movlw HIGH aa_font28_block
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
88 movwf TBLPTRH,A
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
89 bra aa_char_3
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
90
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
93 decfsz WREG,A ; This is medium font ???
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
94 bra aa_char_2
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
95
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
96 ; Font MEDIUM block:
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
97 movlw LOW aa_font48_block
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
98 movwf TBLPTRL,A
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
99 movlw HIGH aa_font48_block
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
100 movwf TBLPTRH,A
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
101 bra aa_char_3
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
102
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
105 ; Font LARGE block:
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
106 movlw LOW aa_font90_block
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
107 movwf TBLPTRL,A
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
108 movlw HIGH aa_font90_block
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
109 movwf TBLPTRH,A
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
110
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
113 ; This is safe iff the three fonts are in the same code segment
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
114 ; (and that segment do not span the 64K edge...)
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
115 movlw UPPER aa_font28_block
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
116 movwf TBLPTRU,A
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
117
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
120 tblrd*+ ; Read FROM char
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
121 movf TABLAT,W ; Get it, and set Z,N
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
122 bz aa_char_32 ; Break at end of translations
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
124 tblrd*+ ; Read TO char
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
125 cpfseq PRODL,A ; FROM == current char ?
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
126 bra aa_char_30 ; Different: loop
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
127 movff TABLAT, PRODL ; make substitution
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
132 tblrd*+ ; Read first char
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
133 movf TABLAT,W ; get it.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
136 tblrd*+ ; Read nb chars
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
137 movf TABLAT,W ; nbchars --> WREG
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
138 tblrd*+ ; Read default char
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
139 cpfslt PRODL ; if char > WREG ?
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
140 movff TABLAT,PRODL ; replace PRODL
91
3bcccb697bce Added HW logo and dimmed cursor in small font.
JeanDo
parents: 83
diff changeset
141
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
142 ; Decode font height and anti-aliasing mode
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
143 clrf aa_flags,ACCESS ; Default to no AA
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
144 tblrd*+ ; Read font height + AA flag
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
145 movf TABLAT,W ; into WREG
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
146 bnn aa_char_34 ; High bit set ?
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
147 bsf aa_antialias,ACCESS ; YES : then the font is AA.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
148 aa_char_34:
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
149 andlw 0x7F ; Keep just font height,
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
152 ; Set PROM pointer to the char index
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
153 movf PRODL,W ; Read back char
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
154 mullw 2 ; PROD = 2*(char - base), TBLPTR=idx
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
155 movf PRODL,W
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
156 addwf TBLPTRL,F ; Add into TBLPTR (low byte)
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
157 movf PRODH,W
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
160 ; Read start and stop pointers
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
161 tblrd*+ ; aa_start = PROM16(*tblptr++)
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
162 movff TABLAT,aa_start+0 ; Read low byte
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
163 tblrd*+
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
166 tblrd*+ ; aa_end = PROM16(*tblptr++)
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
167 movff TABLAT,aa_end+0 ; Read low byte
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
168 tblrd*+
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
180 movff aa_start+0, TBLPTRL ; TBLPTR = aa_start
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
181 movff aa_start+1, TBLPTRH
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
186 ifdef AA_BYTE_SWAP
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
187 btg TBLPTRL,0,A ; Toggle low ptr bit.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
188 tblrd*
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
189 movf TABLAT,W,A ; Store to WREG
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
190 btg TBLPTRL,0,A ; Get is back
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
191 tblrd*+ ; then increment (but trash TABLAT)
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
192 movwf TABLAT,A ; Then restore copy to TABLAT.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
193 else
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
194 tblrd*+ ; Normal read...
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
195 movf TABLAT,W,A ; Store copy to WREG
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
196 endif
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
197 btfss aa_antialias,ACCESS ; Antialiased font ?
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
200 bn aa_char_width_10 ; Non-white pixels ?
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
203 andlw 0x7F ; No: 7 bit count.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
204 incf WREG,A ; WREG = repetition count
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
205 addwf aa_bitlen,F,ACCESS ; Add remaining pixels from last code.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
206
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
207 movf win_height,W,BANKED ; WREG = - height
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
208 negf WREG,A
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
209
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
212 addwf aa_bitlen,F,ACCESS ; Try to substract win_height
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
215 infsnz aa_width+0,F,ACCESS ; Succeded: do a 16bit increment
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
216 incf aa_width+1,F,ACCESS ; on the aa_width counter.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
220 negf WREG,A ; WREG = +height
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
223 ; Are we done ?
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
224 movf TBLPTRL,W,A ; Compare TBLPTR to aa_end
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
225 cpfseq aa_end+0,ACCESS
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
226 bra aa_char_width_1 ; Loop if LOW is different
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
227 movf TBLPTRH,W,A
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
228 cpfseq aa_end+1,ACCESS ; Loop to if HIGH is different
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
242 clrf aa_width+0,ACCESS ; Clear width sum.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
246 movf POSTINC2,W,A ; WREG = *FSR2++
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
249 rcall aa_char_setup ; setup aa_start / aa_end
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
250 rcall aa_char_width ; sum-up width into aa_width
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
266 movlw cmd
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
267 rcall PLED_CmdWrite
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
268 ; bcf oled_rs ; Cmd mode
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
269 ; movwf PORTD,A
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
270 ; bcf oled_rw ; Tick the clock
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
271 ; bsf oled_rw
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
279 rcall PLED_DataWrite_PROD
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
280 ; bsf oled_rs ; Data mode
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
281 ; movff PRODH,PORTD ; NOTE: OLED is BIGENDIAN!
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
282 ; bcf oled_rw ; Tick the clock
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
283 ; bsf oled_rw
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
284 ; movff PRODL,PORTD
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
285 ; bcf oled_rw ; Tick the clock
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
286 ; bsf oled_rw
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
296 movf win_leftx2,W,BANKED ; Compute left = 2*leftx2
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
297 mullw 2
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
298 AA_CMD_WRITE 0x35 ; this is the left border
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
299 AA_DATA_WRITE_PROD
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
300
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
301 movf aa_width+0,W,ACCESS ; right = left + width - 1
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
302 addwf PRODL,F,A
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
303 movf aa_width+1,W,ACCESS
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
304 addwfc PRODH,F,A
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
305 decf PRODL,F,A ; decrement result
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
306 bc aa_box_cmd_1 ; No borrow (/Carry) ? skip propagating.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
309 AA_CMD_WRITE 0x36 ; Write and the right border
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
310 AA_DATA_WRITE_PROD
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
311
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
312 movf win_top,W,BANKED ; Write top / bottom window
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
313 movwf PRODH,A ; (remember PRODH output first)
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
314 addwf win_height,W,BANKED
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
315 decf WREG,A
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
316 movwf PRODL,A ; And PRODL is later...
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
317 AA_CMD_WRITE 0x37
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
318 AA_DATA_WRITE_PROD
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
319
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
320 movf win_top,W,BANKED ; Start ptr top
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
321 mullw 1 ; Load into PRODH:L
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
322 AA_CMD_WRITE 0x20
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
323 AA_DATA_WRITE_PROD
96
25433449bcb5 adding anti-aliased fonts!
heinrichsweikamp
parents: 95
diff changeset
324
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
325 movf win_leftx2,W,BANKED ; Start ptr left
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
326 mullw 2
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
327 AA_CMD_WRITE 0x21
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
328 AA_DATA_WRITE_PROD
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
329
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
339 movff aa_start+0, TBLPTRL ; TBLPTR = aa_start
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
344 ifdef AA_BYTE_SWAP
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
345 btg TBLPTRL,0,A ; Toggle low ptr bit.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
346 tblrd*
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
347 movf TABLAT,W,A ; Store to WREG
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
348 btg TBLPTRL,0,A ; Get is back
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
349 tblrd*+ ; then increment (but trash TABLAT)
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
350 movwf TABLAT,A ; Then restore copy to TABLAT.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
351 else
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
352 tblrd*+ ; Normal read...
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
353 movf TABLAT,W,A ; Store copy to WREG
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
354 endif
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
355 btfss aa_antialias,ACCESS ; Antialiased font ?
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
356 bra aa_decode_10 ; No: always 7 bits count
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
357 bn aa_decode_10 ; Non-white pixels ?
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
360 andlw 0x7F ; No: 7 bit count.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
361 incf WREG,A
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
364 ;---- COLOR DECODING -------------------------------------------------
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
365 ;
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
366 ; Code Normal Inverse
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
367 ; 1xx 0% 100% : Managed by aa_decode_13
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
368 ; 011 25% 75%
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
369 ; 010 50% 50%
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
370 ; 001 75% 25%
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
371 ; 000 100% 0% : Managed by aa_decode_13 too.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
372 ;
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
373 movf TABLAT,W,A ; Get back code
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
374 btfss aa_antialias,ACCESS ; Antialiased font ?
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
377 ; Asymetry test: 1xx code is another case for 1bit color.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
378 ; This have to be done before inverse video, because
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
379 ; of the asymetric processing !
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
382 ; Manage 000 special case too:
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
383 andlw 0xE0 ; Select color bits
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
386 ; Apply reverse video, in a reversed way
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
387 btfss win_invert,0 ; Inverse video mode ?
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
388 sublw 0x80
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
389
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
390 ; Move the two bits to aa_color_half and aa_color_quarter:
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
391 swapf WREG ; --> 0000.0LL0 byte
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
392 iorlw b'001' ; We are in AA mode, don't forget it !
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
395 ;---- 2 bit x RGB(16bits) computation --------------------------------
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
396 clrf PRODL ; We will accumulate result here...
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
397 clrf PRODH
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
398
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
399 ; Take color div 2 into aa_colorDiv. Max red = 15/31
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
400 rrcf win_color1,W,BANKED ; xRRRRxGG
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
401 andlw b'01111011' ; 0RRRR0GG (don't change C)
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
402 movwf aa_colorDiv+0,ACCESS
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
403 rrcf win_color2,W,BANKED ; GGGxBBBB
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
404 andlw b'11101111' ; GGG0BBBB
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
407 btfss aa_color_half,ACCESS
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
408 bra aa_decode_12
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
409
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
410 movff aa_colorDiv+0,PRODH ; Add color/2 if bit set.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
413 btfss aa_color_quart,ACCESS
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
414 bra aa_decode_3
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
415
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
416 ; Divide it once again by 2. Max red = 7/31.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
417 rrcf aa_colorDiv+0,W,ACCESS ; xxRRRxxG
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
418 andlw b'00111001' ; 00RRR00G (don't change C)
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
419 movwf aa_colorDiv+0,ACCESS
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
420 rrcf aa_colorDiv+1,W,ACCESS ; GGGxxBBB
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
421 andlw b'11100111' ; GGG00BBB
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
424 movf aa_colorDiv+1,W,ACCESS ; Add color/4
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
425 addwf PRODL,F ; NOTE: 7/31+15/31=22/31,
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
426 movf aa_colorDiv+0,W,ACCESS ; hence composants won't overlap.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
433 btfsc win_invert,0 ; Inverse video mode ?
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
434 xorlw 0x80 ; YES: invert levels.
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
437 ; WHITE pixel (ie. full color)
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
438 movff win_color1,PRODH ; current draw color
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
439 movff win_color2,PRODL ; (rem: OLED is big endian)
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
443 clrf PRODH,A ; BLACK pixel
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
447 ;---- PIXEL WRITE LOOP -----------------------------------------------
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
448 AA_DATA_WRITE_PROD
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
449 decf aa_bitlen,F,ACCESS
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
450 bnz aa_decode_3
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
451
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
452 ;---- BYTE-CODE LOOP -------------------------------------------------
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
453 ; Are we done ?
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
454 movf TBLPTRL,W,A ; Compare TBLPTR to aa_end
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
455 cpfseq aa_end+0,ACCESS
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
456 bra aa_decode_1 ; Loop if LOW is different
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
457 movf TBLPTRH,W,A
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
458 cpfseq aa_end+1,ACCESS ; Loop to if HIGH is different
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
459 bra aa_decode_1
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
460
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
469 ; Make sure context is well known
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
472 rcall aa_string_width ; Set win_height, compute win_width
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
475 ; Restart the loop for each char to print
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
478 ; DATA bloc commande:
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
482 movf POSTINC2,W,A ; WREG = *FSR2++
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
485 rcall aa_char_setup ; setup aa_start / aa_end
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
486 rcall aa_decode_char ; write pixels to screen
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
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
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
490 ; END of bloc commande
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
491 AA_CMD_WRITE 0x00
83
3e351e25f5d1 adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
diff changeset
492
123
6a94f96e9cea The big cleanup, again.
JeanDo
parents: 116
diff changeset
493 return