comparison src/color_processor.asm @ 634:4050675965ea

3.10 stable release
author heinrichsweikamp
date Tue, 28 Apr 2020 17:34:31 +0200
parents cd58f7fc86db
children aeca5717d9eb
comparison
equal deleted inserted replaced
633:690c48db7b5b 634:4050675965ea
1 ;============================================================================= 1 ;=============================================================================
2 ; 2 ;
3 ; File File color_processor.asm combined next generation V3.03.7 3 ; File File color_processor.asm * combined next generation V3.09.4l
4 ; 4 ;
5 ; Decompress and draw an image 5 ; Decompress and draw an image
6 ; 6 ;
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
8 ;============================================================================= 8 ;=============================================================================
57 #include "hwos.inc" 57 #include "hwos.inc"
58 #include "tft.inc" 58 #include "tft.inc"
59 59
60 extern convert_for_display2 60 extern convert_for_display2
61 61
62 62 ;=============================================================================
63 color_proc CODE 63 color_proc CODE
64 64 ;=============================================================================
65 ;----------------------------------------------------------------------------- 65
66 66 ;-----------------------------------------------------------------------------
67 ; Print a colored Bitmap Image
68 ;
67 global color_image 69 global color_image
68 color_image: 70 color_image:
69 tblrd*+ ; read image width (in true width / 2) 71 tblrd*+ ; read image width (in true width / 2)
70 movff TABLAT,win_width 72 movff TABLAT,win_width+0 ; store in win_width, low byte
73 clrf win_width+1 ; clear win_width, high byte
71 tblrd*+ ; read image height 74 tblrd*+ ; read image height
72 movff TABLAT,win_height 75 movff TABLAT,win_height ; store in win_height
73 rcall get_colors ; read the colors 76 rcall get_colors ; read the colors
74
75 tstfsz encoding_format ; image encoded in version 0 format? 77 tstfsz encoding_format ; image encoded in version 0 format?
76 bra color_image_1 ; NO 78 bra color_image_1 ; NO
77 79
78 ; image encoding version 0 format: compute the overall number of pixels - 1 to draw 80 ; image encoding version 0 format: compute overall number of pixels - 1
79 movf win_width,W ; get width into WREG 81 movf win_width,W ; get image width (/2) into WREG
80 mulwf win_height ; multiply by hight 82 mulwf win_height ; multiply with image hight
81 movff PRODL,overall_pixels+0 ; store product, low byte 83 movff PRODL,overall_pixels+0 ; store product, low byte
82 movff PRODH,overall_pixels+1 ; ... high byte 84 movff PRODH,overall_pixels+1 ; ... high byte
83 clrf overall_pixels+2 ; clear upper byte 85 clrf overall_pixels+2 ; clear product, upper byte
84 bcf STATUS,C ; clear carry flag 86 bcf STATUS,C ; clear carry flag
85 rlcf overall_pixels+0 ; multiply by 2 via shift left, low byte 87 rlcf overall_pixels+0 ; multiply by 2 via shift left, low byte
86 rlcf overall_pixels+1 ; ... high byte 88 rlcf overall_pixels+1 ; ... high byte
87 rlcf overall_pixels+2 ; ... upper byte 89 rlcf overall_pixels+2 ; ... upper byte
88 clrf WREG ; decrement by 1 to ease all pixel done detection 90 clrf WREG ; decrement by 1 to ease all pixel done detection
89 decf overall_pixels+0,F ; ... 91 decf overall_pixels+0,F ; ...
90 subwfb overall_pixels+1,F ; ... 92 subwfb overall_pixels+1,F ; ...
91 subwfb overall_pixels+2,F ; ... 93 subwfb overall_pixels+2,F ; ...
92 94
93 color_image_1: 95 color_image_1:
94 clrf win_width+1 ; clear width, high byte
95 bcf STATUS,C ; clear carry flag 96 bcf STATUS,C ; clear carry flag
96 rlcf win_width+0 ; multiply width x 2 to get the true box width 97 rlcf win_width+0 ; multiply width x 2 to get the true box width
97 rlcf win_width+1 ; ... 98 rlcf win_width+1 ; ...
98 call TFT_box_write ; set output box 99 call TFT_box_write ; set output box
99 Index_out 0x22 ; frame memory data write start 100 Index_out 0x22 ; frame memory data write start
102 ; prepare to read next pixel count and color 103 ; prepare to read next pixel count and color
103 clrf pixel_count+0 ; clear number of pixels 104 clrf pixel_count+0 ; clear number of pixels
104 clrf pixel_count+1 ; ... 105 clrf pixel_count+1 ; ...
105 106
106 color_image_read_byte: 107 color_image_read_byte:
107 tblrd*+ ; get next byte 108 tblrd*+ ; get next image data byte
108 btfss TABLAT,7 ; high bit cleared ? 109 btfss TABLAT,7 ; high bit cleared ?
109 bra color_image_decode_color; YES - this is a color byte 110 bra color_image_decode_color; YES - this is color data
110 ;bra color_image_decode_count; NO - this is a pixel count byte 111 ;bra color_image_decode_count; NO - this is pixel count data
111 112
112 color_image_decode_count: 113 color_image_decode_count:
113 ; decode pixel repetition count 114 ; decode pixel repetition count
114 rlcf TABLAT,F ; drop high bit 115 rlcf TABLAT,F ; drop high bit
115 movlw .7 ; move 7 bits 116 movlw .7 ; move 7 bits
116 color_image_decode_count_loop: 117 color_image_decode_count_loop:
117 rlcf TABLAT,F ; get upper bit into carry 118 rlcf TABLAT,F ; get upper bit into carry
118 rlcf pixel_count+0,F ; push bit into pixel count (16 bit operation) 119 rlcf pixel_count+0,F ; push bit into pixel count (16 bit operation)
119 rlcf pixel_count+1,F ; ... 120 rlcf pixel_count+1,F ; ...
120 decfsz WREG ; decrement loop counter, all bits done? 121 decfsz WREG ; decrement loop counter, all bits done?
121 bra color_image_decode_count_loop ; NO - loop 122 bra color_image_decode_count_loop ; NO - loop
122 bra color_image_read_byte ; YES - decode next byte 123 bra color_image_read_byte ; YES - decode next byte
123 124
124 color_image_decode_color: 125 color_image_decode_color:
125 ; check for end-of-image tag (color index = 0x7F) -- it is assumed that no version 0 image contains 127 colors... 126 ; check for end-of-image tag (color index = 0x7F) -- it is assumed that no version 0 image contains 127 colors...
126 movlw 0x7f ; encoding for end-of-image 127 movlw 0x7f ; encoding for end-of-image
127 cpfslt TABLAT ; color index < end-of-image tag? 128 cpfslt TABLAT ; color index < end-of-image tag?
128 return ; NO - done 129 return ; NO - done
129 130
130 ; get pixel color into PROD 131 ; translate color index into pixel color
131 lfsr FSR2,buffer ; set FSR2 pointer to base address of color table 132 lfsr FSR2,buffer ; set FSR2 pointer to base address of color table
132 rlncf TABLAT,W ; get color index * 2 into WREG 133 rlncf TABLAT,W ; get color index * 2 into WREG
133 movwf FSR2L ; adjust pointer to selected color 134 movwf FSR2L ; adjust pointer to selected color
134 movff POSTINC2,PRODL ; read color, low byte 135 movff POSTINC2,PRODL ; read color, low byte
135 movff POSTINC2,PRODH ; read color, high byte 136 movff POSTINC2,PRODH ; read color, high byte
136 137
137 tstfsz encoding_format ; image encoded in version 0 format? 138 tstfsz encoding_format ; image encoded in version 0 format?
138 bra color_image_pixel ; NO 139 bra color_image_pixel ; NO
140
139 ; image encoding version 0 format: subtract pixel count from the overall number of pixels to do 141 ; image encoding version 0 format: subtract pixel count from the overall number of pixels to do
140 movf pixel_count+0,W ; YES - 24 bit subtraction, low byte 142 movf pixel_count+0,W ; YES - 24 bit subtraction, low byte
141 subwf overall_pixels+0,F ; ... 143 subwf overall_pixels+0,F ; ...
142 movf pixel_count+1,W ; ... high byte 144 movf pixel_count+1,W ; ... high byte
143 subwfb overall_pixels+1,F ; ... 145 subwfb overall_pixels+1,F ; ...
144 movlw .0 ; ... upper byte 146 movlw .0 ; ... upper byte
145 subwfb overall_pixels+2,F ; ... 147 subwfb overall_pixels+2,F ; ...
146 148
147 color_image_pixel: 149 color_image_pixel:
148 ; prepare sending of pixels to display 150 ; prepare sending the pixels to display
149 infsnz pixel_count+0 ; increment pixel repetition count by 1 151 infsnz pixel_count+0 ; increment pixel repetition count by 1
150 incf pixel_count+1 ; ... 152 incf pixel_count+1 ; ...
151 incf pixel_count+1 ; because decrement is done first, increment high byte once more 153 incf pixel_count+1 ; because decrement is done first, increment high byte once more
152 bsf tft_rs,0 ; RS_H data 154 bsf tft_rs,0 ; RS_H data
153 bcf INTCON,GIE ; disable global interrupts 155 bcf INTCON,GIE ; disable all interrupts
154 156
155 btfsc screen_type2 ; display type 2 ? 157 btfsc screen_type2 ; display type 2 ?
156 bra color_image_display2 ; YES 158 bra color_image_display2 ; YES
157 btfsc screen_type3 ; display type 3 ? 159 btfsc screen_type3 ; display type 3 ?
158 bra color_image_display3 ; YES 160 bra color_image_display3 ; YES
200 decfsz pixel_count+1 ; decrement pixel counter, high byte 202 decfsz pixel_count+1 ; decrement pixel counter, high byte
201 bra color_image_display3 ; loop if not zero 203 bra color_image_display3 ; loop if not zero
202 ; bra color_image_pixel_com ; all pixels transmitted 204 ; bra color_image_pixel_com ; all pixels transmitted
203 205
204 color_image_pixel_com: 206 color_image_pixel_com:
205 bsf INTCON,GIE ; re-enable global interrupts 207 bsf INTCON,GIE ; re-enable all interrupts
206 208
207 tstfsz encoding_format ; image encoded in version 0 format? 209 tstfsz encoding_format ; image encoded in version 0 format?
208 bra color_image_loop_xy ; NO - loop to process next byte from image data 210 bra color_image_loop_xy ; NO - loop to process next byte from image data
209 211
210 ; image encoding version 0 format: step counter 212 ; image encoding version 0 format: step counter
214 subwfb overall_pixels+2,F ; ... 216 subwfb overall_pixels+2,F ; ...
215 bnn color_image_loop_xy ; all pixels done? NO - loop 217 bnn color_image_loop_xy ; all pixels done? NO - loop
216 return ; YES - done 218 return ; YES - done
217 219
218 220
221 ;-----------------------------------------------------------------------------
222 ; Helper Function - set up Pixel-Color Look-Up Table
223 ;
219 global get_colors 224 global get_colors
220 get_colors: 225 get_colors:
221 tblrd*+ ; read number of image colors 226 tblrd*+ ; read number of color indexes
222 movff TABLAT,lo ; store in lo 227 movf TABLAT,W ; store in lo
223 movf lo,W
224 tblrd*+ ; read image encoding format 228 tblrd*+ ; read image encoding format
225 movff TABLAT,encoding_format ; store encoding format 229 movff TABLAT,encoding_format ; store encoding format
226 lfsr FSR2,buffer ; set up buffer as storage for the colors 230 lfsr FSR2,buffer ; load base address of the look-up table
227 get_colors_loop: 231 get_colors_loop:
228 tblrd*+ ; read color from stored image, low byte 232 tblrd*+ ; read color from stored image, low byte
229 btfss use_custom_colors ; shall use custom colors? 233 btfss use_custom_colors ; shall use custom colors?
230 movff TABLAT,POSTINC2 ; NO - copy color read to buffer 234 movff TABLAT,POSTINC2 ; NO - copy color read to buffer
231 tblrd*+ ; read color from stored image, high byte 235 tblrd*+ ; read color from stored image, high byte
234 decfsz WREG ; decrement loop counter, done? 238 decfsz WREG ; decrement loop counter, done?
235 bra get_colors_loop ; NO - loop 239 bra get_colors_loop ; NO - loop
236 bcf use_custom_colors ; YES - clear custom colors request 240 bcf use_custom_colors ; YES - clear custom colors request
237 return ; - done 241 return ; - done
238 242
243 ;-----------------------------------------------------------------------------
244
239 END 245 END