comparison code_part1/OSTC_code_asm_part1/color_processor.asm @ 773:9e82de8dc12d

update color processor to latest format
author heinrichsweikamp
date Sat, 08 Mar 2014 14:06:09 +0100
parents 6e456a6398e0
children
comparison
equal deleted inserted replaced
772:5d6da9ddde27 773:9e82de8dc12d
65 ;----------------------------------------------------------------------------- 65 ;-----------------------------------------------------------------------------
66 color_image: 66 color_image:
67 movlb HIGH(win_height) ; Switch to bank 0. 67 movlb HIGH(win_height) ; Switch to bank 0.
68 68
69 ;---- Get image parameters ------------------------------------------- 69 ;---- Get image parameters -------------------------------------------
70 tblrd*+ 70 tblrd*+
71 movff TABLAT,img_width 71 movff TABLAT,img_width
72 tblrd*+ 72 tblrd*+
73 movff TABLAT,win_height 73 movff TABLAT,win_height
74 tblrd*+ 74 tblrd*+
75 movff TABLAT,img_colors 75 movff TABLAT,img_colors
76 tblrd*+ 76 tblrd*+
77 ;---- Copy color table ----------------------------------------------- 77 ;---- Copy color table -----------------------------------------------
78 movf img_colors,W 78 movf img_colors,W
79 lfsr FSR2,colorTable 79 lfsr FSR2,colorTable
80 get_colors_loop: 80 get_colors_loop:
81 tblrd*+ 81 tblrd*+
82 movff TABLAT,POSTINC2 82 movff TABLAT,POSTINC2
83 tblrd*+ 83 tblrd*+
84 movff TABLAT,POSTINC2 84 movff TABLAT,POSTINC2
85 decfsz WREG 85 decfsz WREG
94 rlcf PRODH 94 rlcf PRODH
95 movff PRODL, img_pixelsL 95 movff PRODL, img_pixelsL
96 movff PRODH, img_pixelsH 96 movff PRODH, img_pixelsH
97 rlcf img_pixelsU ; Get the upper bit in place. 97 rlcf img_pixelsU ; Get the upper bit in place.
98 98
99 clrf WREG ; Decrement count to ease end detection.
100 decf img_pixelsL,F
101 subwfb img_pixelsH,F
102 subwfb img_pixelsU,F
103
99 ;---- Send window command -------------------------------------------- 104 ;---- Send window command --------------------------------------------
100 clrf img_width+1 ; x2 on width, for the true box size. 105 clrf img_width+1 ; x2 on width, for the true box size.
101 rlcf img_width+0 106 rlcf img_width+0
102 rlcf img_width+1 107 rlcf img_width+1
103 call DISP_box_write 108 call DISP_box_write
107 color_image_loop_xy: 112 color_image_loop_xy:
108 ; Get pixel count 113 ; Get pixel count
109 clrf img_countL 114 clrf img_countL
110 clrf img_countH 115 clrf img_countH
111 116
112 color_image_loop_count: 117 ;---- Decode repetition count
118 color_image_decode_1:
113 tblrd*+ ; Get one byte 119 tblrd*+ ; Get one byte
114 120
115 movlw 0x0F ; Get count bits 121 btfss TABLAT,7 ; High bit cleared ?
116 andwf TABLAT,W 122 bra color_image_decode_2 ; YES: this is a color byte.
117 swapf WREG ; On top-4 bits of W
118 rlcf WREG ; Push topmost bit into img_count:2
119 rlcf img_countL
120 rlcf img_countH
121 rlcf WREG ; Push topmost bit into img_count:2
122 rlcf img_countL
123 rlcf img_countH
124 rlcf WREG ; Push topmost bit into img_count:2
125 rlcf img_countL
126 rlcf img_countH
127 rlcf WREG ; Push topmost bit into img_count:2
128 rlcf img_countL
129 rlcf img_countH
130 123
131 movf TABLAT,W ; Does the color-bits mark a big-count ? 124 rlcf TABLAT,F ; Drop high bit.
132 andlw 0xF0 125 movlw .7 ; Move 7 bits
133 xorlw 0xF0 126 color_image_decode_3:
134 bz color_image_loop_count ; YES: loop for more count bits. 127 rlcf TABLAT,F ; Get bit into carry
128 rlcf img_countL,F ; Push into pixel count
129 rlcf img_countH,F
130 decfsz WREG
131 bra color_image_decode_3 ; and loop foreach 7 bits.
135 132
136 ; Get pixel color into PROD 133 bra color_image_decode_1 ; Decode next byte.
137 xorlw 0xF0 ; Get back index. 134
138 swapf WREG ; Get color index to lower bits. 135 color_image_decode_2:
139 addwf WREG ; x2 136 ;---- Get pixel color into PROD
140 addlw LOW(colorTable) ; 0x60 + 2 * .15 < 0x80. 137 movf TABLAT,W ; Get color index.
141 movff WREG,FSR2L 138 addwf WREG ; *2
139 lfsr FSR2,colorTable ; Reinitialize color table.
140 movff WREG,FSR2L ; LOW(buffer) == 0
142 movff POSTINC2,PRODL 141 movff POSTINC2,PRODL
143 movff POSTINC2,PRODH 142 movff POSTINC2,PRODH
144 143
145 ; Substract count-1 from the number of pixel we should do. 144 ; Substract count-1 from the number of pixel we should do.
146 movf img_countL,W ; Make a 24bit substraction. 145 movf img_countL,W ; Make a 24bit substraction.
147 subwf img_pixelsL,F 146 subwf img_pixelsL,F
148 movf img_countH,W 147 movf img_countH,W
149 subwfb img_pixelsH,F 148 subwfb img_pixelsH,F
150 movlw 0 149 movlw 0
151 subwfb img_pixelsU,F 150 subwfb img_pixelsU,F
152 151
153 incf img_countL ; Get back the true count. 152 color_image_not_over:
154 addwfc img_countH 153 infsnz img_countL ; Increment count.
154 incf img_countH
155 155
156 ; Loop sending pixel color 156 ; Loop sending pixel color
157 incf img_countH ; Because we decrement first, should add one here ! 157 incf img_countH ; Because we decrement first, should add one here !
158 color_image_loop_pixel: 158 color_image_loop_pixel:
159 AA_DATA_WRITE_PROD 159 AA_DATA_WRITE_PROD
160 decfsz img_countL 160 decfsz img_countL
161 bra color_image_loop_pixel 161 bra color_image_loop_pixel
162 decfsz img_countH 162 decfsz img_countH
163 bra color_image_loop_pixel 163 bra color_image_loop_pixel
164 164
165 ; And count (on a 17bit counter) 165 ; And count (on a 24bit counter)
166 clrf WREG ; Make a 24bit decrement. 166 clrf WREG ; Make a 24bit decrement.
167 decf img_pixelsL 167 decf img_pixelsL
168 subwfb img_pixelsH,F 168 subwfb img_pixelsH,F
169 subwfb img_pixelsU,F 169 subwfb img_pixelsU,F
170 170
171 movf img_pixelsL,W ; Test if img_pixels == 0 171 bnn color_image_loop_xy ; Not finished ? loop...
172 iorwf img_pixelsH,W
173 iorwf img_pixelsU,W
174 bnz color_image_loop_xy ; NO: loop...
175 172
176 ;---- Closeup -------------------------------------------------------- 173 ;---- Closeup --------------------------------------------------------
177 AA_CMD_WRITE 0x00 174 AA_CMD_WRITE 0x00
178 return 175 return