annotate src/aa_wordprocessor.asm @ 628:cd58f7fc86db

3.05 stable work
author heinrichsweikamp
date Thu, 19 Sep 2019 12:01:29 +0200
parents c40025d8e750
children 4050675965ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
3 ; File aa_wordprocessor.asm combined next generation V3.03.7
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Anti-aliased word processor
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
10 ; 2010-11-22 : [jDG] Creation
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
11 ; 2010-12-01 : [jDG] Adding 3bits anti-aliased fonts
0
heinrichsweikamp
parents:
diff changeset
12 ; 2010-12-30 : [jDG] Revised to put temp into ACCESSRAM0
heinrichsweikamp
parents:
diff changeset
13 ; 2012-08-12 : [mH] Moved font28 into bootloader section 0x1C000
heinrichsweikamp
parents:
diff changeset
14 ;
heinrichsweikamp
parents:
diff changeset
15 ; BUGS :
heinrichsweikamp
parents:
diff changeset
16 ; * If the three fonts are not in the same half of the PROM memory, TBLPTRU
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
17 ; will be badly set, and font48 or font90 will display gibberish...
0
heinrichsweikamp
parents:
diff changeset
18 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
19 ;
heinrichsweikamp
parents:
diff changeset
20 ; MEMORY FOOTPRINT:
heinrichsweikamp
parents:
diff changeset
21 ;------------------
heinrichsweikamp
parents:
diff changeset
22 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
23 ; wp_wordprocessor : 8 KB, including fonts
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
24 ; aa_wordprocessor : 0.5 KB code
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
25 ; + 3.5 KB aa_font28 (reduced to 99 chars)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
26 ; + 1.6 KB aa_font48
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
27 ; + 2.2 KB aa_font90
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
28 ; = 7.9 KB including fonts
0
heinrichsweikamp
parents:
diff changeset
29 ;
heinrichsweikamp
parents:
diff changeset
30 ; Input registers:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
31 ; buffer:26 String to print
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
32 ; win_font Font size (0=tiny, 1=small, 2=std, 3=medium, 4=large, 5=XL)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
33 ; win_color1:2 16bits unpacked color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
34 ; win_top, win_leftx2 Position on screen
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
35 ; win_inverse Inverse video mode
0
heinrichsweikamp
parents:
diff changeset
36 ;
heinrichsweikamp
parents:
diff changeset
37 ; Available general purpose registers:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
38 ; PRODH, PRODL needed for array indexing
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
39 ; FSRx 12bits, used for indirect addressing
0
heinrichsweikamp
parents:
diff changeset
40 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
41
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 189
diff changeset
42 #include "hwos.inc"
0
heinrichsweikamp
parents:
diff changeset
43 #include "tft.inc"
heinrichsweikamp
parents:
diff changeset
44
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
45 extern aa_font16_block
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
46 extern aa_font28_block
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
47 extern aa_font34_block
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
48 extern aa_font48_block
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
49 extern aa_font90_block
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
50 extern aa_font92_block
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
51
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
52 extern convert_for_display2
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
53
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
54
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
55 aa_word CODE
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
56
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
57 ;=============================================================================
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
58
0
heinrichsweikamp
parents:
diff changeset
59 ;------------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
60 ; Setup pointers for a char:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
61 ; Inputs WREG = char to draw, win_font
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
62 ; Output aa_start, aa_end, win_height, AA_flags
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
63 ; Trashed PRODH, PRODL, TBLPTR, TABLAT
0
heinrichsweikamp
parents:
diff changeset
64 ;
heinrichsweikamp
parents:
diff changeset
65 aa_char_setup:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
66 movwf PRODL ; save char into PROD for now
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
67 movf win_font,W ; get font number (updates Z flag)
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
68 bnz aa_char_1 ; requested tiny font? (bra of no)
0
heinrichsweikamp
parents:
diff changeset
69
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
70 ; 0: TINY font -------------------------------------------------------
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
71 ; Font TINY character folding...
0
heinrichsweikamp
parents:
diff changeset
72 aa_char_0:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
73 movlw LOW aa_font16_block
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
74 movwf TBLPTRL
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
75 movlw HIGH aa_font16_block
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
76 movwf TBLPTRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
77 movlw UPPER aa_font16_block
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
78 movwf TBLPTRU
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
79 bra aa_char_99
0
heinrichsweikamp
parents:
diff changeset
80
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
81 ; 1: SMALL font ------------------------------------------------------
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
82 ; Font SMALL character folding...
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
83 aa_char_1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
84 decfsz WREG ; requested small font?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
85 bra aa_char_2 ; NO
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
86 movlw LOW aa_font28_block
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
87 movwf TBLPTRL
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
88 movlw HIGH aa_font28_block
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
89 movwf TBLPTRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
90 movlw UPPER aa_font28_block
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
91 movwf TBLPTRU
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
92 bra aa_char_99
0
heinrichsweikamp
parents:
diff changeset
93
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
94 ; 2: STD font --------------------------------------------------------
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
95 ; Font STANDARD character folding...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
96 aa_char_2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
97 decfsz WREG ; requested std font?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
98 bra aa_char_3 ; NO
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
99 movlw LOW aa_font34_block
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
100 movwf TBLPTRL
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
101 movlw HIGH aa_font34_block
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
102 movwf TBLPTRH
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
103 movlw UPPER aa_font34_block
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
104 movwf TBLPTRU
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
105 bra aa_char_99
0
heinrichsweikamp
parents:
diff changeset
106
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
107 ; 3: MEDIUM font -----------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
108 aa_char_3:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
109 decfsz WREG ; requested medium font?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
110 bra aa_char_4 ; NO
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
111 movlw LOW aa_font48_block
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
112 movwf TBLPTRL
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
113 movlw HIGH aa_font48_block
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
114 movwf TBLPTRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
115 movlw UPPER aa_font48_block
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
116 movwf TBLPTRU
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
117 bra aa_char_99
0
heinrichsweikamp
parents:
diff changeset
118
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
119 ; 4: LARGE font ------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
120 aa_char_4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
121 decfsz WREG ; requested large font?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
122 bra aa_char_5 ; NO
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
123 movlw LOW aa_font90_block
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
124 movwf TBLPTRL
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
125 movlw HIGH aa_font90_block
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
126 movwf TBLPTRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
127 movlw UPPER aa_font90_block
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
128 movwf TBLPTRU
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
129 bra aa_char_99
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
130
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
131 ; 5: XTRA LARGE font -------------------------------------------------
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
132 aa_char_5:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
133 movlw LOW aa_font92_block
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
134 movwf TBLPTRL
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
135 movlw HIGH aa_font92_block
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
136 movwf TBLPTRH
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
137 movlw UPPER aa_font92_block
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
138 movwf TBLPTRU
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
139
0
heinrichsweikamp
parents:
diff changeset
140
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
141 ; Execute font block -------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
142 aa_char_99:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
143 ; This is safe if all fonts are in the same code segment
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
144 ; (and that segment does not span the 64K edge...)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
145 movlw UPPER aa_font16_block
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
146 movwf TBLPTRU
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
147
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
148 ; Proceed to character substitutions
0
heinrichsweikamp
parents:
diff changeset
149 aa_char_30:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
150 tblrd*+ ; read FROM char
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
151 movf TABLAT,W ; get it, and set Z,N
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
152 bz aa_char_32 ; break at end of translations
0
heinrichsweikamp
parents:
diff changeset
153
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
154 tblrd*+ ; read TO char
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
155 cpfseq PRODL ; FROM == current char ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
156 bra aa_char_30 ; different -> loop
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
157 movff TABLAT, PRODL ; make substitution
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
158 bra aa_char_30 ; loop
0
heinrichsweikamp
parents:
diff changeset
159
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
160 ; Make sure char is in the available range
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
161 aa_char_32:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
162 tblrd*+ ; read first char
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
163 movf TABLAT,W ; get it
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
164 subwf PRODL,F ; (char - first) --> PRODL
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
165 tblrd*+ ; read nb chars
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
166 movf TABLAT,W ; nbchars --> WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
167 tblrd*+ ; read default char
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
168 cpfslt PRODL ; char > WREG ?
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
169 movff TABLAT,PRODL ; replace PRODL
0
heinrichsweikamp
parents:
diff changeset
170
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
171 ; Decode font height and anti-aliasing mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
172 bcf aa_antialias ; default to no AA
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
173 tblrd*+ ; read font height + AA flag
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
174 movf TABLAT,W ; into WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
175 bnn aa_char_34 ; high bit set ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
176 bsf aa_antialias ; YES - then the font is AA
0
heinrichsweikamp
parents:
diff changeset
177 aa_char_34:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
178 andlw 0x7F ; keep just font height,
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
179 movwf win_height ; then save it (its a register)
0
heinrichsweikamp
parents:
diff changeset
180
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
181 ; Set PROM pointer to the char index
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
182 movf PRODL,W ; read back char
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
183 mullw 2 ; PROD = 2*(char - base), TBLPTR=idx
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
184 movf PRODL,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
185 addwf TBLPTRL,F ; add into TBLPTR (low byte)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
186 movf PRODH,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
187 addwfc TBLPTRH,F ; and high byte
0
heinrichsweikamp
parents:
diff changeset
188
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
189 ; Read start and stop pointers
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
190 tblrd*+ ; aa_start = PROM16(*tblptr++)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
191 movff TABLAT,aa_start+0 ; read low byte
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
192 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
193 movff TABLAT,aa_start+1 ; and high byte
0
heinrichsweikamp
parents:
diff changeset
194
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
195 tblrd*+ ; aa_end = PROM16(*tblptr++)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
196 movff TABLAT,aa_end+0 ; read low byte
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
197 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
198 movff TABLAT,aa_end+1 ; and high byte
0
heinrichsweikamp
parents:
diff changeset
199
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
200 return
0
heinrichsweikamp
parents:
diff changeset
201
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
202
0
heinrichsweikamp
parents:
diff changeset
203 ;------------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
204 ; Character width
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
205 ; Input aa_start, aa_end, win_width, win_height, AA_flags
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
206 ; Output width added to win_width
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
207 ; Trashed aa_bitlen, TBLPTR, TABLAT
0
heinrichsweikamp
parents:
diff changeset
208 ;
heinrichsweikamp
parents:
diff changeset
209 aa_char_width:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
210 movff aa_start+0, TBLPTRL ; TBLPTR = aa_start
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
211 movff aa_start+1, TBLPTRH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
212 clrf aa_bitlen ; clear reminders...
0
heinrichsweikamp
parents:
diff changeset
213
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
214 ; Read bitmap byte, and decode length:
0
heinrichsweikamp
parents:
diff changeset
215 aa_char_width_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
216
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
217 ifdef AA_BYTE_SWAP
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
218 btg TBLPTRL ; toggle low ptr bit
0
heinrichsweikamp
parents:
diff changeset
219 tblrd*
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
220 movf TABLAT,W ; store to WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
221 btg TBLPTRL ; get is back
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
222 tblrd*+ ; then increment (but trash TABLAT)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
223 movwf TABLAT ; then restore copy to TABLAT
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
224 else
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
225 tblrd*+ ; normal read...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
226 movf TABLAT,W ; store copy to WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
227 endif
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
228
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
229 btfss aa_antialias ; anti-aliased font ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
230 bra aa_char_width_10 ; NO - always 7 bit count
0
heinrichsweikamp
parents:
diff changeset
231
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
232 bn aa_char_width_10 ; none-white pixels?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
233 andlw 0x1F ; YES - 5 bit count
0
heinrichsweikamp
parents:
diff changeset
234 aa_char_width_10:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
235 andlw 0x7F ; NO - 7 bit count
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
236 incf WREG ; WREG = repetition count
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
237 addwf aa_bitlen,F ; add remaining pixels from last code
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
238
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
239 movf win_height,W ; WREG -= height
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
240 negf WREG
0
heinrichsweikamp
parents:
diff changeset
241
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
242 ; This is a hand-made division by successive subtraction of height
0
heinrichsweikamp
parents:
diff changeset
243 aa_char_width_2:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
244 addwf aa_bitlen,F ; try to subtract win_height
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
245 bn aa_char_width_3 ; if neg it was a bad idea...
0
heinrichsweikamp
parents:
diff changeset
246
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
247 infsnz win_width+0,F ; succeeded: do a 16 bit increment
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
248 incf win_width+1,F ; on the win_width counter
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
249 bra aa_char_width_2 ; and loop
0
heinrichsweikamp
parents:
diff changeset
250
heinrichsweikamp
parents:
diff changeset
251 aa_char_width_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
252 negf WREG ; WREG = +height
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
253 addwf aa_bitlen,F ; restore true reminder
0
heinrichsweikamp
parents:
diff changeset
254
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
255 ; Are we done ?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
256 movf TBLPTRL,W ; compare TBLPTR to aa_end
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
257 cpfseq aa_end+0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
258 bra aa_char_width_1 ; loop if LOW is different
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
259 movf TBLPTRH,W
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
260 cpfseq aa_end+1 ; loop to if HIGH is different
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
261 bra aa_char_width_1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
262 return
0
heinrichsweikamp
parents:
diff changeset
263
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
264
0
heinrichsweikamp
parents:
diff changeset
265 ;------------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
266 ; String width
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
267 ; Input buffer (SHOULD BE NULL TERMINATED)
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
268 ; Output win_width, win_height
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
269 ; Trashed PROD, TBLPTR, FSR2, aa_bitlen, aa_start, aa_end, AA_flags
0
heinrichsweikamp
parents:
diff changeset
270 ;
heinrichsweikamp
parents:
diff changeset
271 aa_string_width:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
272 lfsr FSR2, buffer ; FSR2 pointer to start of string
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
273 clrf win_width+0 ; clear width sum
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
274 clrf win_width+1 ; (16 bit counter)
0
heinrichsweikamp
parents:
diff changeset
275
heinrichsweikamp
parents:
diff changeset
276 aa_string_width_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
277 movf POSTINC2,W ; WREG = *FSR2++
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
278 bz aa_string_width99 ; exit if null byte encountered
0
heinrichsweikamp
parents:
diff changeset
279
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
280 rcall aa_char_setup ; setup aa_start / aa_end
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
281 rcall aa_char_width ; sum-up width into win_width
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
282 bra aa_string_width_1 ; and loop
0
heinrichsweikamp
parents:
diff changeset
283
heinrichsweikamp
parents:
diff changeset
284 aa_string_width99:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
285 return
0
heinrichsweikamp
parents:
diff changeset
286
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
287
0
heinrichsweikamp
parents:
diff changeset
288 ;------------------------------------------------------------------------------
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
289 ; Decode a compressed char
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
290 ; Input aa_start, aa_end, win_height, win_invert, win_color1, win_color2
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
291 ; Output none
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
292 ; Trashed TBLPTR, TABLAT, PROD, aa_bitlen, AA_flags, aa_colorDir:2
0
heinrichsweikamp
parents:
diff changeset
293 ;
heinrichsweikamp
parents:
diff changeset
294 aa_decode_char:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
295 movff aa_start+0, TBLPTRL ; TBLPTR = aa_start
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
296 movff aa_start+1, TBLPTRH
0
heinrichsweikamp
parents:
diff changeset
297
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
298 ; Read bitmap byte, and decode color & length
0
heinrichsweikamp
parents:
diff changeset
299 aa_decode_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
300
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
301 ifdef AA_BYTE_SWAP
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
302 btg TBLPTRL ; toggle low ptr bit
0
heinrichsweikamp
parents:
diff changeset
303 tblrd*
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
304 movf TABLAT,W ; store to WREG
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
305 btg TBLPTRL ; get is back
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
306 tblrd*+ ; then increment (but trash TABLAT)
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
307 movwf TABLAT ; then restore copy to TABLAT
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
308 else
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
309 tblrd*+ ; normal read...
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
310 movf TABLAT,W ; store copy to WREG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
311 endif
0
heinrichsweikamp
parents:
diff changeset
312
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
313 btfss aa_antialias ; anti-aliased font?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
314 bra aa_decode_10 ; NO - always 7 bit count
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
315 bn aa_decode_10 ; none-white pixels?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
316 andlw 0x1F ; Yes - 5 bit count
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
317 aa_decode_10:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
318 andlw 0x7F ; NO - 7 bit count
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
319 incf WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
320 movwf aa_bitlen ; repetition count --> aa_bitlen
0
heinrichsweikamp
parents:
diff changeset
321
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
322 ;---- COLOR DECODING -------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
323 ;
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
324 ; Code Normal Inverse
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
325 ; 1xx 0% 100% : Managed by aa_decode_13
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
326 ; 011 25% 75%
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
327 ; 010 50% 50%
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
328 ; 001 75% 25%
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
329 ; 000 100% 0% : Managed by aa_decode_13, too
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
330 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
331 movf TABLAT,W ; get back code
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
332 btfss aa_antialias ; anti-aliased font?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
333 bra aa_decode_13 ; NO - 1 bit case
0
heinrichsweikamp
parents:
diff changeset
334
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
335 ; Asymmetry test: 1xx code is another case for 1bit color.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
336 ; This have to be done before inverse video, because
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
337 ; of the asymmetric processing!
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
338 bn aa_decode_13 ; decode as none-aa
0
heinrichsweikamp
parents:
diff changeset
339
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
340 ; Manage 000 special case too:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
341 andlw 0xE0 ; select color bits, is it a 000 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
342 bz aa_decode_13 ; YES
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
343
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
344 ; Apply reverse video, in a reversed way
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
345 btfss win_invert ; inverse video mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
346 sublw 0x80 ; NO
0
heinrichsweikamp
parents:
diff changeset
347
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
348 ; Extract color quarter and color half information
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
349 bsf aa_antialias ; set AA mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
350 bcf aa_color_quarter ; default to no color quarter
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
351 btfsc WREG,5 ; color quarter encoded?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
352 bsf aa_color_quarter ; YES - set flag
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
353 bcf aa_color_half ; default to no color half
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
354 btfsc WREG,6 ; color half encoded?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
355 bsf aa_color_half ; YES - set flag
0
heinrichsweikamp
parents:
diff changeset
356
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
357 ;---- 2 bit x RGB(16bits) computation --------------------------------
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
358 clrf PRODL ; we will accumulate result here...
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
359 clrf PRODH
0
heinrichsweikamp
parents:
diff changeset
360
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
361 ; Take color div 2 into aa_temp. Max red = 15/31
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
362 rrcf win_color1,W ; xRRRRxGG
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
363 andlw b'01111011' ; 0RRRR0GG (don't change C)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
364 movwf aa_temp+0
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
365 rrcf win_color2,W ; GGGxBBBB
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
366 andlw b'11101111' ; GGG0BBBB
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
367 movwf aa_temp+1
0
heinrichsweikamp
parents:
diff changeset
368
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
369 btfss aa_color_half
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
370 bra aa_decode_12
0
heinrichsweikamp
parents:
diff changeset
371
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
372 movff aa_temp+0,PRODH ; add color/2 if bit set
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
373 movff aa_temp+1,PRODL ; TFT is big endian, so swap here
0
heinrichsweikamp
parents:
diff changeset
374 aa_decode_12:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
375 btfss aa_color_quarter
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
376 bra aa_decode_3
0
heinrichsweikamp
parents:
diff changeset
377
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
378 ; Divide it once again by 2. Max red = 7/31.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
379 rrcf aa_temp+0,W ; xxRRRxxG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
380 andlw b'00111001' ; 00RRR00G (don't change C)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
381 movwf aa_temp+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
382 rrcf aa_temp+1,W ; GGGxxBBB
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
383 andlw b'11100111' ; GGG00BBB
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
384 movwf aa_temp+1
0
heinrichsweikamp
parents:
diff changeset
385
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
386 movf aa_temp+1,W ; add color/4
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
387 addwf PRODL,F ; NOTE: 7/31+15/31=22/31,
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
388 movf aa_temp+0,W ; hence components won't overlap
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
389 addwfc PRODH,F ; in right order, to propagate carry
0
heinrichsweikamp
parents:
diff changeset
390
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
391 aa_decode_12b:
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
392 btfss screen_type2 ; display 2?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
393 bra aa_decode_3 ; NO - done
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
394
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
395 call convert_for_display2 ; convert 16 bit RGB b'RRRRRGGG GGGBBBBB' into 24 bit RGB b'RRRRRR00 GGGGGG00 BBBBBB00'
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
396
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
397 bra aa_decode_3 ; done
0
heinrichsweikamp
parents:
diff changeset
398
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
399 ; ---- Simple BLACK and WHITE cases ------------------------------
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
400 aa_decode_13: ; got a 1xx or a 000 code...
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
401 btfsc win_invert ; inverse video mode ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
402 xorlw 0x80 ; YES - invert levels
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
403 bn aa_decode_2 ; then test high bit
0
heinrichsweikamp
parents:
diff changeset
404
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
405 ; WHITE pixel (i.e. full color)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
406 movff win_color1,PRODH ; current draw color
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
407 movff win_color2,PRODL ; remark: DISPLAY is big endian
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
408 bra aa_decode_12b
0
heinrichsweikamp
parents:
diff changeset
409
heinrichsweikamp
parents:
diff changeset
410 aa_decode_2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
411 clrf PRODH ; BLACK pixel
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
412 clrf PRODL
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
413 clrf win_color5
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
414 clrf win_color4
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
415 clrf win_color3
0
heinrichsweikamp
parents:
diff changeset
416
heinrichsweikamp
parents:
diff changeset
417 aa_decode_3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
418 ;---- PIXEL WRITE LOOP -----------------------------------------------
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
419 bsf tft_rs ; Data!
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
420
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
421 btfsc screen_type2 ; display 2 ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
422 bra aa_decode_3_display2 ; YES
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
423 btfsc screen_type3 ; display 3 ?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
424 bra aa_decode_3_display3 ; YES
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
425
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
426 movff PRODH,PORTA ; move high byte to PORTA
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
427 movff PRODL,PORTH ; move low byte to PORTH
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
428 aa_decode_3_display0and1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
429 bcf tft_nwr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
430 bsf tft_nwr ; tick
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
431 decf aa_bitlen,F
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
432 bnz aa_decode_3_display0and1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
433 bra aa_decode_3_done
0
heinrichsweikamp
parents:
diff changeset
434
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
435 aa_decode_3_display2:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
436 movff win_color5,PORTH ; move high byte to PORTH (DISPLAY is big endian)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
437 bcf tft_nwr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
438 bsf tft_nwr ; tick
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
439 movff win_color4,PORTH ; move low byte to PORTH
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
440 bcf tft_nwr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
441 bsf tft_nwr ; tick
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
442 movff win_color3,PORTH ; move low(est) byte to PORTH
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
443 bcf tft_nwr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
444 bsf tft_nwr ; tick
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
445 decf aa_bitlen,F
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
446 bnz aa_decode_3_display2
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
447 bra aa_decode_3_done
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
448
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
449 aa_decode_3_display3:
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
450 movff PRODH,PORTH ; move high byte to PORTH (DISPLAY is big endian)
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
451 bcf tft_nwr
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
452 bsf tft_nwr ; tick
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
453 movff PRODL,PORTH ; move low byte to PORTH
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
454 bcf tft_nwr
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
455 bsf tft_nwr ; tick
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
456 decf aa_bitlen,F
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
457 bnz aa_decode_3_display3
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
458
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
459 aa_decode_3_done:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
460 ;---- BYTE-CODE LOOP -------------------------------------------------
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
461 ; are we done ?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
462 movf TBLPTRL,W ; compare TBLPTR with aa_end
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
463 cpfseq aa_end+0
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
464 bra aa_decode_1 ; loop if LOW is different
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
465 movf TBLPTRH,W
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
466 cpfseq aa_end+1 ; loop to if HIGH is different
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
467 bra aa_decode_1
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
468 return
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
469
0
heinrichsweikamp
parents:
diff changeset
470
heinrichsweikamp
parents:
diff changeset
471 ;------------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
472 ; Setup pointers for a char:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
473 ; Inputs : buffer : string to print (NULL TERMINATED)
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
474 ; Output : TFT commands on PORTH (Upper) and PORTA (lower) + clocks
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
475 ;
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
476 global aa_wordprocessor ; callable from C-code
0
heinrichsweikamp
parents:
diff changeset
477 aa_wordprocessor:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
478 rcall aa_string_width ; set win_height, compute win_width:2
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
479 call TFT_box_write ; use that for the box
0
heinrichsweikamp
parents:
diff changeset
480
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
481 ; Restart the loop for each char to print
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
482 lfsr FSR2, buffer ; FSR2 points to the start of the string
0
heinrichsweikamp
parents:
diff changeset
483
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
484 ; DATA block command
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
485 Index_out 0x22 ; index_out is a macro defined in tft.inc
0
heinrichsweikamp
parents:
diff changeset
486
heinrichsweikamp
parents:
diff changeset
487 aa_wordprocessor_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
488 movf POSTINC2,W ; WREG = *FSR2++
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
489 bz aa_wordprocessor_99 ; exit if null byte encountered
0
heinrichsweikamp
parents:
diff changeset
490
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
491 rcall aa_char_setup ; setup aa_start / aa_end
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
492 rcall aa_decode_char ; write pixels to screen
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
493 bra aa_wordprocessor_1 ; and loop
0
heinrichsweikamp
parents:
diff changeset
494
heinrichsweikamp
parents:
diff changeset
495 aa_wordprocessor_99:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
496 ; END of bloc command
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
497 Index_out 0x00
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
498 return
0
heinrichsweikamp
parents:
diff changeset
499
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
500 END