Mercurial > public > hwos_code
comparison src/aa_wordprocessor.asm @ 604:ca4556fb60b9
bump to 2.99beta, work on 3.00 stable
| author | heinrichsweikamp |
|---|---|
| date | Thu, 22 Nov 2018 19:47:26 +0100 |
| parents | b455b31ce022 |
| children | d866684249bd |
comparison
equal
deleted
inserted
replaced
| 603:00b24fb4324d | 604:ca4556fb60b9 |
|---|---|
| 1 ;============================================================================= | 1 ;============================================================================= |
| 2 ; | 2 ; |
| 3 ; File aa_wordprocessor.asm ## V2.97 | 3 ; File aa_wordprocessor.asm ## V2.99e |
| 4 ; | 4 ; |
| 5 ; Anti-aliased word processor | 5 ; Anti-aliased word processor |
| 6 ; | 6 ; |
| 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
| 8 ;============================================================================= | 8 ;============================================================================= |
| 9 ; HISTORY | 9 ; HISTORY |
| 10 ; 2010-11-22 : [jDG] Creation. | 10 ; 2010-11-22 : [jDG] Creation |
| 11 ; 2010-12-01 : [jDG] Adding 3bits anti-aliased fonts. | 11 ; 2010-12-01 : [jDG] Adding 3bits anti-aliased fonts |
| 12 ; 2010-12-30 : [jDG] Revised to put temp into ACCESSRAM0 | 12 ; 2010-12-30 : [jDG] Revised to put temp into ACCESSRAM0 |
| 13 ; 2012-08-12 : [mH] Moved font28 into bootloader section 0x1C000 | 13 ; 2012-08-12 : [mH] Moved font28 into bootloader section 0x1C000 |
| 14 ; | 14 ; |
| 15 ; BUGS : | 15 ; BUGS : |
| 16 ; * If the three fonts are not in the same half of the PROM memory, TBLPTRU | 16 ; * If the three fonts are not in the same half of the PROM memory, TBLPTRU |
| 46 extern aa_font28_block | 46 extern aa_font28_block |
| 47 extern aa_font36_block | 47 extern aa_font36_block |
| 48 extern aa_font48_block | 48 extern aa_font48_block |
| 49 extern aa_font90_block | 49 extern aa_font90_block |
| 50 | 50 |
| 51 aa_word CODE | |
| 52 | |
| 51 ;------------------------------------------------------------------------------ | 53 ;------------------------------------------------------------------------------ |
| 52 ; Setup pointers for a char: | 54 ; Setup pointers for a char: |
| 53 ; Inputs WREG = char to draw, win_font | 55 ; Inputs WREG = char to draw, win_font |
| 54 ; Output aa_start, aa_end, win_height, aa_flags | 56 ; Output aa_start, aa_end, win_height, aa_flags |
| 55 ; Trashed PRODH, PRODL, TBLPTR, TABLAT | 57 ; Trashed PRODH, PRODL, TBLPTR, TABLAT |
| 56 ; | 58 ; |
| 57 basic CODE | 59 |
| 58 aa_char_setup: | 60 aa_char_setup: |
| 59 movwf PRODL ; save char into PROD for now | 61 movwf PRODL ; save char into PROD for now |
| 60 movf win_font,W,BANKED ; Get font number (updates Z flag) | 62 movf win_font,W ; get font number (updates Z flag) |
| 61 bnz aa_char_1 | 63 bnz aa_char_1 |
| 62 | 64 |
| 63 ; TINY font --------------------------------------------------------- | 65 ; TINY font --------------------------------------------------------- |
| 64 ; Font TINY character folding... | 66 ; Font TINY character folding... |
| 65 aa_char_0: | 67 aa_char_0: |
| 72 bra aa_char_99 | 74 bra aa_char_99 |
| 73 | 75 |
| 74 ; SMALL font --------------------------------------------------------- | 76 ; SMALL font --------------------------------------------------------- |
| 75 ; Font SMALL character folding... | 77 ; Font SMALL character folding... |
| 76 aa_char_1: | 78 aa_char_1: |
| 77 decfsz WREG ; This is small font ??? | 79 decfsz WREG ; requested small font? |
| 78 bra aa_char_2 | 80 bra aa_char_2 ; NO |
| 79 movlw LOW aa_font28_block | 81 movlw LOW aa_font28_block |
| 80 movwf TBLPTRL | 82 movwf TBLPTRL |
| 81 movlw HIGH aa_font28_block | 83 movlw HIGH aa_font28_block |
| 82 movwf TBLPTRH | 84 movwf TBLPTRH |
| 83 movlw UPPER aa_font28_block | 85 movlw UPPER aa_font28_block |
| 85 bra aa_char_99 | 87 bra aa_char_99 |
| 86 | 88 |
| 87 ; STD font ----------------------------------------------------------- | 89 ; STD font ----------------------------------------------------------- |
| 88 ; Font SMALL character folding... | 90 ; Font SMALL character folding... |
| 89 aa_char_2: | 91 aa_char_2: |
| 90 decfsz WREG ; This is small font ??? | 92 decfsz WREG ; requested std font? |
| 91 bra aa_char_3 | 93 bra aa_char_3 ; NO |
| 92 movlw LOW aa_font36_block | 94 movlw LOW aa_font36_block |
| 93 movwf TBLPTRL | 95 movwf TBLPTRL |
| 94 movlw HIGH aa_font36_block | 96 movlw HIGH aa_font36_block |
| 95 movwf TBLPTRH | 97 movwf TBLPTRH |
| 96 movlw UPPER aa_font36_block | 98 movlw UPPER aa_font36_block |
| 97 movwf TBLPTRU | 99 movwf TBLPTRU |
| 98 bra aa_char_99 | 100 bra aa_char_99 |
| 99 | 101 |
| 100 ; MEDIUM font -------------------------------------------------------- | 102 ; MEDIUM font -------------------------------------------------------- |
| 101 aa_char_3: | 103 aa_char_3: |
| 102 decfsz WREG ; This is medium font ??? | 104 decfsz WREG ; requested medium font? |
| 103 bra aa_char_4 | 105 bra aa_char_4 ; NO |
| 104 | |
| 105 ; Font MEDIUM block: | |
| 106 movlw LOW aa_font48_block | 106 movlw LOW aa_font48_block |
| 107 movwf TBLPTRL | 107 movwf TBLPTRL |
| 108 movlw HIGH aa_font48_block | 108 movlw HIGH aa_font48_block |
| 109 movwf TBLPTRH | 109 movwf TBLPTRH |
| 110 movlw UPPER aa_font48_block | 110 movlw UPPER aa_font48_block |
| 111 movwf TBLPTRU | 111 movwf TBLPTRU |
| 112 bra aa_char_99 | 112 bra aa_char_99 |
| 113 | 113 |
| 114 ; LARGE font --------------------------------------------------------- | 114 ; LARGE font --------------------------------------------------------- |
| 115 aa_char_4: | 115 aa_char_4: |
| 116 ; Font LARGE block: | 116 ; no to all above - must be large font then... |
| 117 movlw LOW aa_font90_block | 117 movlw LOW aa_font90_block |
| 118 movwf TBLPTRL | 118 movwf TBLPTRL |
| 119 movlw HIGH aa_font90_block | 119 movlw HIGH aa_font90_block |
| 120 movwf TBLPTRH | 120 movwf TBLPTRH |
| 121 movlw UPPER aa_font90_block | 121 movlw UPPER aa_font90_block |
| 128 movlw UPPER aa_font16_block | 128 movlw UPPER aa_font16_block |
| 129 movwf TBLPTRU | 129 movwf TBLPTRU |
| 130 | 130 |
| 131 ; Proceed to character substitutions | 131 ; Proceed to character substitutions |
| 132 aa_char_30: | 132 aa_char_30: |
| 133 tblrd*+ ; Read FROM char | 133 tblrd*+ ; read FROM char |
| 134 movf TABLAT,W ; Get it, and set Z,N | 134 movf TABLAT,W ; get it, and set Z,N |
| 135 bz aa_char_32 ; Break at end of translations | 135 bz aa_char_32 ; break at end of translations |
| 136 | 136 |
| 137 tblrd*+ ; Read TO char | 137 tblrd*+ ; read TO char |
| 138 cpfseq PRODL ; FROM == current char ? | 138 cpfseq PRODL ; FROM == current char ? |
| 139 bra aa_char_30 ; Different: loop | 139 bra aa_char_30 ; different -> loop |
| 140 movff TABLAT, PRODL ; make substitution | 140 movff TABLAT, PRODL ; make substitution |
| 141 bra aa_char_30 ; Loop | 141 bra aa_char_30 ; loop |
| 142 | 142 |
| 143 ; Make sure char is in the available range | 143 ; Make sure char is in the available range |
| 144 aa_char_32: | 144 aa_char_32: |
| 145 tblrd*+ ; Read first char | 145 tblrd*+ ; read first char |
| 146 movf TABLAT,W ; get it | 146 movf TABLAT,W ; get it |
| 147 subwf PRODL,F ; (char - first) --> PRODL | 147 subwf PRODL,F ; (char - first) --> PRODL |
| 148 tblrd*+ ; Read nb chars | 148 tblrd*+ ; read nb chars |
| 149 movf TABLAT,W ; nbchars --> WREG | 149 movf TABLAT,W ; nbchars --> WREG |
| 150 tblrd*+ ; Read default char | 150 tblrd*+ ; read default char |
| 151 cpfslt PRODL ; if char > WREG ? | 151 cpfslt PRODL ; char > WREG ? |
| 152 movff TABLAT,PRODL ; replace PRODL | 152 movff TABLAT,PRODL ; replace PRODL |
| 153 | 153 |
| 154 ; Decode font height and anti-aliasing mode | 154 ; Decode font height and anti-aliasing mode |
| 155 clrf aa_flags ; Default to no AA | 155 clrf aa_flags ; default to no AA |
| 156 tblrd*+ ; Read font height + AA flag | 156 tblrd*+ ; read font height + AA flag |
| 157 movf TABLAT,W ; into WREG | 157 movf TABLAT,W ; into WREG |
| 158 bnn aa_char_34 ; High bit set ? | 158 bnn aa_char_34 ; high bit set ? |
| 159 bsf aa_antialias ; YES : then the font is AA | 159 bsf aa_antialias ; YES - then the font is AA |
| 160 aa_char_34: | 160 aa_char_34: |
| 161 andlw 0x7F ; Keep just font height, | 161 andlw 0x7F ; keep just font height, |
| 162 movwf win_height,BANKED ; then save it (its a register) | 162 movwf win_height ; then save it (its a register) |
| 163 | 163 |
| 164 ; Set PROM pointer to the char index | 164 ; Set PROM pointer to the char index |
| 165 movf PRODL,W ; Read back char | 165 movf PRODL,W ; read back char |
| 166 mullw 2 ; PROD = 2*(char - base), TBLPTR=idx | 166 mullw 2 ; PROD = 2*(char - base), TBLPTR=idx |
| 167 movf PRODL,W | 167 movf PRODL,W |
| 168 addwf TBLPTRL,F ; Add into TBLPTR (low byte) | 168 addwf TBLPTRL,F ; add into TBLPTR (low byte) |
| 169 movf PRODH,W | 169 movf PRODH,W |
| 170 addwfc TBLPTRH,F ; and high byte | 170 addwfc TBLPTRH,F ; and high byte |
| 171 | 171 |
| 172 ; Read start and stop pointers | 172 ; Read start and stop pointers |
| 173 tblrd*+ ; aa_start = PROM16(*tblptr++) | 173 tblrd*+ ; aa_start = PROM16(*tblptr++) |
| 174 movff TABLAT,aa_start+0 ; Read low byte | 174 movff TABLAT,aa_start+0 ; read low byte |
| 175 tblrd*+ | 175 tblrd*+ |
| 176 movff TABLAT,aa_start+1 ; and high byte | 176 movff TABLAT,aa_start+1 ; and high byte |
| 177 | 177 |
| 178 tblrd*+ ; aa_end = PROM16(*tblptr++) | 178 tblrd*+ ; aa_end = PROM16(*tblptr++) |
| 179 movff TABLAT,aa_end+0 ; Read low byte | 179 movff TABLAT,aa_end+0 ; read low byte |
| 180 tblrd*+ | 180 tblrd*+ |
| 181 movff TABLAT,aa_end+1 ; and high byte | 181 movff TABLAT,aa_end+1 ; and high byte |
| 182 | 182 |
| 183 return | 183 return |
| 184 | 184 |
| 191 aa_char_width: | 191 aa_char_width: |
| 192 movff aa_start+0, TBLPTRL ; TBLPTR = aa_start | 192 movff aa_start+0, TBLPTRL ; TBLPTR = aa_start |
| 193 movff aa_start+1, TBLPTRH | 193 movff aa_start+1, TBLPTRH |
| 194 clrf aa_bitlen ; clear reminders... | 194 clrf aa_bitlen ; clear reminders... |
| 195 | 195 |
| 196 ; Read bitmap byte, and decode length: | 196 ; Read bitmap byte, and decode length: |
| 197 aa_char_width_1: | 197 aa_char_width_1: |
| 198 | 198 |
| 199 ifdef AA_BYTE_SWAP | 199 ifdef AA_BYTE_SWAP |
| 200 btg TBLPTRL,0 ; Toggle low ptr bit | 200 btg TBLPTRL ; toggle low ptr bit |
| 201 tblrd* | 201 tblrd* |
| 202 movf TABLAT,W ; Store to WREG | 202 movf TABLAT,W ; store to WREG |
| 203 btg TBLPTRL,0 ; Get is back | 203 btg TBLPTRL ; get is back |
| 204 tblrd*+ ; then increment (but trash TABLAT) | 204 tblrd*+ ; then increment (but trash TABLAT) |
| 205 movwf TABLAT ; Then restore copy to TABLAT | 205 movwf TABLAT ; then restore copy to TABLAT |
| 206 else | 206 else |
| 207 tblrd*+ ; Normal read... | 207 tblrd*+ ; normal read... |
| 208 movf TABLAT,W ; Store copy to WREG | 208 movf TABLAT,W ; store copy to WREG |
| 209 endif | 209 endif |
| 210 | 210 |
| 211 btfss aa_antialias ; Anti-aliased font ? | 211 btfss aa_antialias ; anti-aliased font ? |
| 212 bra aa_char_width_10 ; No: always 7 bits count | 212 bra aa_char_width_10 ; NO - always 7 bit count |
| 213 | 213 |
| 214 bn aa_char_width_10 ; Non-white pixels ? | 214 bn aa_char_width_10 ; none-white pixels? |
| 215 andlw 0x1F ; Yes : 5 bits count | 215 andlw 0x1F ; YES - 5 bit count |
| 216 aa_char_width_10: | 216 aa_char_width_10: |
| 217 andlw 0x7F ; No: 7 bit count | 217 andlw 0x7F ; NO - 7 bit count |
| 218 incf WREG ; WREG = repetition count | 218 incf WREG ; WREG = repetition count |
| 219 addwf aa_bitlen,F ; Add remaining pixels from last code | 219 addwf aa_bitlen,F ; add remaining pixels from last code |
| 220 | 220 |
| 221 movf win_height,W,BANKED ; WREG = - height | 221 movf win_height,W ; WREG -= height |
| 222 negf WREG | 222 negf WREG |
| 223 | 223 |
| 224 ; This is a hand-made division by successive subtraction of height | 224 ; This is a hand-made division by successive subtraction of height |
| 225 aa_char_width_2: | 225 aa_char_width_2: |
| 226 addwf aa_bitlen,F ; Try to subtract win_height | 226 addwf aa_bitlen,F ; try to subtract win_height |
| 227 bn aa_char_width_3 ; If neg it was a bad idea... | 227 bn aa_char_width_3 ; if neg it was a bad idea... |
| 228 | 228 |
| 229 infsnz win_width+0,F ; Succeeded: do a 16bit increment | 229 infsnz win_width+0,F ; succeeded: do a 16 bit increment |
| 230 incf win_width+1,F ; on the win_width counter | 230 incf win_width+1,F ; on the win_width counter |
| 231 bra aa_char_width_2 ; and loop | 231 bra aa_char_width_2 ; and loop |
| 232 | 232 |
| 233 aa_char_width_3: | 233 aa_char_width_3: |
| 234 negf WREG ; WREG = +height | 234 negf WREG ; WREG = +height |
| 235 addwf aa_bitlen,F ; Restore true reminder | 235 addwf aa_bitlen,F ; restore true reminder |
| 236 | 236 |
| 237 ; Are we done ? | 237 ; Are we done ? |
| 238 movf TBLPTRL,W ; Compare TBLPTR to aa_end | 238 movf TBLPTRL,W ; compare TBLPTR to aa_end |
| 239 cpfseq aa_end+0 | 239 cpfseq aa_end+0 |
| 240 bra aa_char_width_1 ; Loop if LOW is different | 240 bra aa_char_width_1 ; loop if LOW is different |
| 241 movf TBLPTRH,W | 241 movf TBLPTRH,W |
| 242 cpfseq aa_end+1 ; Loop to if HIGH is different | 242 cpfseq aa_end+1 ; loop to if HIGH is different |
| 243 bra aa_char_width_1 | 243 bra aa_char_width_1 |
| 244 return | 244 return |
| 245 | 245 |
| 246 ;------------------------------------------------------------------------------ | 246 ;------------------------------------------------------------------------------ |
| 247 ; String width | 247 ; String width |
| 249 ; Output win_width, win_height | 249 ; Output win_width, win_height |
| 250 ; Trashed PROD, TBLPTR, FSR2, aa_bitlen, aa_start, aa_end, aa_flags | 250 ; Trashed PROD, TBLPTR, FSR2, aa_bitlen, aa_start, aa_end, aa_flags |
| 251 ; | 251 ; |
| 252 aa_string_width: | 252 aa_string_width: |
| 253 lfsr FSR2, buffer ; FSR2 pointer to start of string | 253 lfsr FSR2, buffer ; FSR2 pointer to start of string |
| 254 clrf win_width+0 ; Clear width sum | 254 clrf win_width+0 ; clear width sum |
| 255 clrf win_width+1 ; (16 bit counter) | 255 clrf win_width+1 ; (16 bit counter) |
| 256 | 256 |
| 257 aa_string_width_1: | 257 aa_string_width_1: |
| 258 movf POSTINC2,W ; WREG = *FSR2++ | 258 movf POSTINC2,W ; WREG = *FSR2++ |
| 259 bz aa_string_width99 ; Exit if null byte encountered | 259 bz aa_string_width99 ; exit if null byte encountered |
| 260 | 260 |
| 261 rcall aa_char_setup ; setup aa_start / aa_end | 261 rcall aa_char_setup ; setup aa_start / aa_end |
| 262 rcall aa_char_width ; sum-up width into win_width | 262 rcall aa_char_width ; sum-up width into win_width |
| 263 bra aa_string_width_1 ; and loop | 263 bra aa_string_width_1 ; and loop |
| 264 | 264 |
| 277 | 277 |
| 278 ; Read bitmap byte, and decode color & length | 278 ; Read bitmap byte, and decode color & length |
| 279 aa_decode_1: | 279 aa_decode_1: |
| 280 | 280 |
| 281 ifdef AA_BYTE_SWAP | 281 ifdef AA_BYTE_SWAP |
| 282 btg TBLPTRL,0 ; Toggle low ptr bit | 282 btg TBLPTRL ; toggle low ptr bit |
| 283 tblrd* | 283 tblrd* |
| 284 movf TABLAT,W ; Store to WREG | 284 movf TABLAT,W ; store to WREG |
| 285 btg TBLPTRL,0 ; Get is back | 285 btg TBLPTRL ; get is back |
| 286 tblrd*+ ; then increment (but trash TABLAT) | 286 tblrd*+ ; then increment (but trash TABLAT) |
| 287 movwf TABLAT ; Then restore copy to TABLAT | 287 movwf TABLAT ; then restore copy to TABLAT |
| 288 else | 288 else |
| 289 tblrd*+ ; Normal read... | 289 tblrd*+ ; normal read... |
| 290 movf TABLAT,W ; Store copy to WREG | 290 movf TABLAT,W ; store copy to WREG |
| 291 endif | 291 endif |
| 292 | 292 |
| 293 btfss aa_antialias ; Anti-aliased font ? | 293 btfss aa_antialias ; anti-aliased font? |
| 294 bra aa_decode_10 ; No: always 7 bits count | 294 bra aa_decode_10 ; NO - always 7 bit count |
| 295 bn aa_decode_10 ; Non-white pixels ? | 295 bn aa_decode_10 ; none-white pixels? |
| 296 andlw 0x1F ; Yes : 5 bits count | 296 andlw 0x1F ; Yes - 5 bit count |
| 297 aa_decode_10: | 297 aa_decode_10: |
| 298 andlw 0x7F ; No: 7 bit count | 298 andlw 0x7F ; NO - 7 bit count |
| 299 incf WREG | 299 incf WREG |
| 300 movwf aa_bitlen ; repetition count --> aa_bitlen | 300 movwf aa_bitlen ; repetition count --> aa_bitlen |
| 301 | 301 |
| 302 ;---- COLOR DECODING ------------------------------------------------- | 302 ;---- COLOR DECODING ------------------------------------------------- |
| 303 ; | 303 ; |
| 304 ; Code Normal Inverse | 304 ; Code Normal Inverse |
| 305 ; 1xx 0% 100% : Managed by aa_decode_13 | 305 ; 1xx 0% 100% : Managed by aa_decode_13 |
| 306 ; 011 25% 75% | 306 ; 011 25% 75% |
| 307 ; 010 50% 50% | 307 ; 010 50% 50% |
| 308 ; 001 75% 25% | 308 ; 001 75% 25% |
| 309 ; 000 100% 0% : Managed by aa_decode_13 too | 309 ; 000 100% 0% : Managed by aa_decode_13, too |
| 310 ; | 310 ; |
| 311 movf TABLAT,W ; Get back code | 311 movf TABLAT,W ; get back code |
| 312 btfss aa_antialias ; Anti-aliased font ? | 312 btfss aa_antialias ; anti-aliased font? |
| 313 bra aa_decode_13 ; NO: 1bit case | 313 bra aa_decode_13 ; NO - 1 bit case |
| 314 | 314 |
| 315 ; Asymmetry test: 1xx code is another case for 1bit color. | 315 ; Asymmetry test: 1xx code is another case for 1bit color. |
| 316 ; This have to be done before inverse video, because | 316 ; This have to be done before inverse video, because |
| 317 ; of the asymmetric processing ! | 317 ; of the asymmetric processing! |
| 318 bn aa_decode_13 ; decode as not-aa | 318 bn aa_decode_13 ; decode as none-aa |
| 319 | 319 |
| 320 ; Manage 000 special case too: | 320 ; Manage 000 special case too: |
| 321 andlw 0xE0 ; Select color bits | 321 andlw 0xE0 ; select color bits |
| 322 bz aa_decode_13 ; That's a 000 ! | 322 bz aa_decode_13 ; that's a 000 ! |
| 323 | 323 |
| 324 ; Apply reverse video, in a reversed way | 324 ; Apply reverse video, in a reversed way |
| 325 btfss win_invert ; Inverse video mode ? | 325 btfss win_invert ; inverse video mode? |
| 326 sublw 0x80 | 326 sublw 0x80 ; NO |
| 327 | 327 |
| 328 ; Move the two bits to aa_color_half and aa_color_quarter: | 328 ; Move the two bits to aa_color_half and aa_color_quarter: |
| 329 swapf WREG ; --> 0000.0LL0 byte | 329 swapf WREG ; --> 0000.0LL0 byte |
| 330 iorlw b'001' ; We are in AA mode, don't forget it ! | 330 iorlw b'001' ; we are in AA mode, don't forget it! |
| 331 movwf aa_flags ; save that to aa_color_(half/quad)/AA flags | 331 movwf aa_flags ; save that to aa_color_(half/quad)/AA flags |
| 332 | 332 |
| 333 ;---- 2 bit x RGB(16bits) computation -------------------------------- | 333 ;---- 2 bit x RGB(16bits) computation -------------------------------- |
| 334 clrf PRODL ; We will accumulate result here... | 334 clrf PRODL ; we will accumulate result here... |
| 335 clrf PRODH | 335 clrf PRODH |
| 336 | 336 |
| 337 ; Take color div 2 into aa_temp. Max red = 15/31 | 337 ; Take color div 2 into aa_temp. Max red = 15/31 |
| 338 rrcf win_color1,W,BANKED ; xRRRRxGG | 338 rrcf win_color1,W ; xRRRRxGG |
| 339 andlw b'01111011' ; 0RRRR0GG (don't change C) | 339 andlw b'01111011' ; 0RRRR0GG (don't change C) |
| 340 movwf aa_temp+0 | 340 movwf aa_temp+0 |
| 341 rrcf win_color2,W,BANKED ; GGGxBBBB | 341 rrcf win_color2,W ; GGGxBBBB |
| 342 andlw b'11101111' ; GGG0BBBB | 342 andlw b'11101111' ; GGG0BBBB |
| 343 movwf aa_temp+1 | 343 movwf aa_temp+1 |
| 344 | 344 |
| 345 btfss aa_color_half | 345 btfss aa_color_half |
| 346 bra aa_decode_12 | 346 bra aa_decode_12 |
| 347 | 347 |
| 348 movff aa_temp+0,PRODH ; Add color/2 if bit set | 348 movff aa_temp+0,PRODH ; add color/2 if bit set |
| 349 movff aa_temp+1,PRODL ; TFT is big endian, so swap here | 349 movff aa_temp+1,PRODL ; TFT is big endian, so swap here |
| 350 aa_decode_12: | 350 aa_decode_12: |
| 351 btfss aa_color_quart | 351 btfss aa_color_quart |
| 352 bra aa_decode_3 | 352 bra aa_decode_3 |
| 353 | 353 |
| 357 movwf aa_temp+0 | 357 movwf aa_temp+0 |
| 358 rrcf aa_temp+1,W ; GGGxxBBB | 358 rrcf aa_temp+1,W ; GGGxxBBB |
| 359 andlw b'11100111' ; GGG00BBB | 359 andlw b'11100111' ; GGG00BBB |
| 360 movwf aa_temp+1 | 360 movwf aa_temp+1 |
| 361 | 361 |
| 362 movf aa_temp+1,W ; Add color/4 | 362 movf aa_temp+1,W ; add color/4 |
| 363 addwf PRODL,F ; NOTE: 7/31+15/31=22/31, | 363 addwf PRODL,F ; NOTE: 7/31+15/31=22/31, |
| 364 movf aa_temp+0,W ; hence components won't overlap | 364 movf aa_temp+0,W ; hence components won't overlap |
| 365 addwfc PRODH,F ; In right order, to propagate carry | 365 addwfc PRODH,F ; in right order, to propagate carry |
| 366 | 366 |
| 367 bra aa_decode_3 ; Done | 367 bra aa_decode_3 ; done |
| 368 | 368 |
| 369 ; ---- Simple BLACK and WHITE cases ------------------------------ | 369 ; ---- Simple BLACK and WHITE cases ------------------------------ |
| 370 aa_decode_13: ; Got a 1xx or a 000 code... | 370 aa_decode_13: ; got a 1xx or a 000 code... |
| 371 btfsc win_invert ; Inverse video mode ? | 371 btfsc win_invert ; inverse video mode? |
| 372 xorlw 0x80 ; YES: invert levels | 372 xorlw 0x80 ; YES - invert levels |
| 373 bn aa_decode_2 ; Then test high bit | 373 bn aa_decode_2 ; then test high bit |
| 374 | 374 |
| 375 ; WHITE pixel (i.e. full color) | 375 ; WHITE pixel (i.e. full color) |
| 376 bsf tft_rs,0 ; RS_H Data | 376 bsf tft_rs ; RS_H Data |
| 377 movff win_color1,PORTA ; current draw color | 377 movff win_color1,PORTA ; current draw color |
| 378 movff win_color2,PORTH ; (rem: TFT is big endian) | 378 movff win_color2,PORTH ; (rem: TFT is big endian) |
| 379 bra aa_decode_4 | 379 bra aa_decode_4 |
| 380 | 380 |
| 381 aa_decode_2: | 381 aa_decode_2: |
| 382 bsf tft_rs,0 ; RS_H Data | 382 bsf tft_rs ; RS_H Data |
| 383 clrf PORTA ; BLACK pixel | 383 clrf PORTA ; BLACK pixel |
| 384 clrf PORTH | 384 clrf PORTH |
| 385 bra aa_decode_4 | 385 bra aa_decode_4 |
| 386 | 386 |
| 387 aa_decode_3: | 387 aa_decode_3: |
| 388 bsf tft_rs,0 ; RS_H Data | 388 bsf tft_rs ; RS_H Data |
| 389 movff PRODH,PORTA ; Move high byte to PORTA | 389 movff PRODH,PORTA ; move high byte to PORTA |
| 390 movff PRODL,PORTH ; Move low byte to PORTH | 390 movff PRODL,PORTH ; move low byte to PORTH |
| 391 aa_decode_4: | 391 aa_decode_4: |
| 392 bcf INTCON,GIE | 392 bcf INTCON,GIE |
| 393 aa_decode_4a: | 393 aa_decode_4a: |
| 394 ;---- PIXEL WRITE LOOP ----------------------------------------------- | 394 ;---- PIXEL WRITE LOOP ----------------------------------------------- |
| 395 bcf tft_nwr,0 ; WR_L | 395 bcf tft_nwr ; WR_L |
| 396 bsf tft_nwr,0 ; WR_H Tick | 396 bsf tft_nwr ; WR_H tick |
| 397 | 397 |
| 398 decf aa_bitlen,F | 398 decf aa_bitlen,F |
| 399 bnz aa_decode_4a | 399 bnz aa_decode_4a |
| 400 | 400 |
| 401 bsf INTCON,GIE | 401 bsf INTCON,GIE |
| 402 ;---- BYTE-CODE LOOP ------------------------------------------------- | 402 ;---- BYTE-CODE LOOP ------------------------------------------------- |
| 403 ; Are we done ? | 403 ; Are we done ? |
| 404 movf TBLPTRL,W ; Compare TBLPTR to aa_end | 404 movf TBLPTRL,W ; compare TBLPTR to aa_end |
| 405 cpfseq aa_end+0 | 405 cpfseq aa_end+0 |
| 406 bra aa_decode_1 ; Loop if LOW is different | 406 bra aa_decode_1 ; loop if LOW is different |
| 407 movf TBLPTRH,W | 407 movf TBLPTRH,W |
| 408 cpfseq aa_end+1 ; Loop too if HIGH is different | 408 cpfseq aa_end+1 ; loop too if HIGH is different |
| 409 bra aa_decode_1 | 409 bra aa_decode_1 |
| 410 return | 410 return |
| 411 | 411 |
| 412 ;------------------------------------------------------------------------------ | 412 ;------------------------------------------------------------------------------ |
| 413 ; Setup pointers for a char: | 413 ; Setup pointers for a char: |
| 414 ; Inputs : buffer : string to print (SHOULD BE NULL TERMINATED) | 414 ; Inputs : buffer : string to print (SHOULD BE NULL TERMINATED) |
| 415 ; Output : TFT commands on port D + clocks. | 415 ; Output : TFT commands on port D + clocks. |
| 416 ; | 416 ; |
| 417 global aa_wordprocessor ; Callable from C-code | 417 global aa_wordprocessor ; callable from C-code |
| 418 aa_wordprocessor: | 418 aa_wordprocessor: |
| 419 banksel win_font ; Bank1, just to be sure | 419 banksel win_font ; bank1, just to be sure |
| 420 rcall aa_string_width ; Set win_height, compute win_width:2 | 420 rcall aa_string_width ; set win_height, compute win_width:2 |
| 421 call TFT_box_write ; Use that for the box | 421 call TFT_box_write ; use that for the box |
| 422 | 422 |
| 423 ; Restart the loop for each char to print | 423 ; Restart the loop for each char to print |
| 424 lfsr FSR2, buffer ; FSR2 pointer to start of string | 424 lfsr FSR2, buffer ; FSR2 pointer to start of string |
| 425 | 425 |
| 426 ; DATA block command | 426 ; DATA block command |
| 427 Index_out 0x22 ; Index_out is a macro defined in tft.inc | 427 Index_out 0x22 ; index_out is a macro defined in tft.inc |
| 428 | 428 |
| 429 aa_wordprocessor_1: | 429 aa_wordprocessor_1: |
| 430 movf POSTINC2,W ; WREG = *FSR2++ | 430 movf POSTINC2,W ; WREG = *FSR2++ |
| 431 bz aa_wordprocessor_99 ; Exit if null byte encountered | 431 bz aa_wordprocessor_99 ; exit if null byte encountered |
| 432 | 432 |
| 433 rcall aa_char_setup ; setup aa_start / aa_end | 433 rcall aa_char_setup ; setup aa_start / aa_end |
| 434 rcall aa_decode_char ; write pixels to screen | 434 rcall aa_decode_char ; write pixels to screen |
| 435 bra aa_wordprocessor_1 ; and loop | 435 bra aa_wordprocessor_1 ; and loop |
| 436 | 436 |
