comparison code_part1/OSTC_code_asm_part1/dump_screen.asm @ 336:9ee86a19f1fa ScreenDump

Beter compression for black/white pixels: ~1sec screen dumps.
author JeanDo
date Mon, 16 May 2011 23:52:38 +0200
parents 1828234369fc
children 1b09cead63a8
comparison
equal deleted inserted replaced
335:d36fe3651d56 336:9ee86a19f1fa
124 clrf TRISD ; Back to normal (PortD as output) 124 clrf TRISD ; Back to normal (PortD as output)
125 125
126 decfsz ds_column,F 126 decfsz ds_column,F
127 bra dump_screen_1 127 bra dump_screen_1
128 128
129 AA_CMD_WRITE 0x00 ; NOP, to stop Address Update Counter 129 AA_CMD_WRITE 0x00 ; NOP, to stop Address Update Counter
130 return 130 return
131 131
132 ;============================================================================= 132 ;=============================================================================
133 ; Pixel compression 133 ; Pixel compression
134 ; 134 ;
135 ; Input: PRODH:L = pixel. 135 ; Input: PRODH:L = pixel.
136 ; Output: Compressed stream on output. 136 ; Output: Compressed stream on output.
137 ; Compressed format:
138 ; 0ccccccc : BLACK pixel, repeated ccccccc+1 times (1..128).
139 ; 11cccccc : WHITE pixel, repeated cccccc+1 times (1..64).
140 ; 10cccccc HIGH LOW : color pixel (H:L) repeated ccccc+1 times (1..64).
137 ; 141 ;
138 dump_screen_pixel: 142 dump_screen_pixel:
139 movf PRODH,W ; Compare pixel-high 143 movf PRODH,W ; Compare pixel-high
140 xorwf ds_pixel+1,W 144 xorwf ds_pixel+1,W
141 bnz dump_screen_pixel_1 ; Different -> dump. 145 bnz dump_screen_pixel_1 ; Different -> dump.
149 153
150 dump_screen_pixel_1: ; Send (pixel,count) tuple 154 dump_screen_pixel_1: ; Send (pixel,count) tuple
151 movf ds_count,W ; Is count zero ? 155 movf ds_count,W ; Is count zero ?
152 bz dump_screen_pixel_2 ; Yes: skip sending. 156 bz dump_screen_pixel_2 ; Yes: skip sending.
153 157
158 movf ds_pixel+1,W ; This is a BLACK pixel ?
159 iorwf ds_pixel+0,W
160 bz dump_screen_pix_black ; YES.
161
162 movf ds_pixel+1,W ; This is a white pixel ?
163 andwf ds_pixel+0,W
164 incf WREG
165 bz dump_screen_pix_white ; YES.
166
167 ; No: write the pixel itself...
168 movlw .64 ; Max color pixel on a single byte.
169 cpfsgt ds_count ; Skip if count > 64
170 movf ds_count,W ; W <- min(64,count)
171 subwf ds_count,F ; ds_count <- ds_count-W
172 decf WREG ; Save as 0..63
173 iorlw b'10000000' ; MARK as a color pixel.
174
175 movwf TXREG
176 call rs232_wait_tx ; wait for UART
154 movff ds_pixel+1,TXREG 177 movff ds_pixel+1,TXREG
155 call rs232_wait_tx ; wait for UART 178 call rs232_wait_tx ; wait for UART
156 movff ds_pixel+0,TXREG 179 movff ds_pixel+0,TXREG
157 call rs232_wait_tx ; wait for UART 180 call rs232_wait_tx ; wait for UART
158 movff ds_count,TXREG 181 bra dump_screen_pixel_1
159 call rs232_wait_tx ; wait for UART
160 182
161 dump_screen_pixel_2: 183 dump_screen_pixel_2:
162 movff PRODH,ds_pixel+1 ; Save new pixel color 184 movff PRODH,ds_pixel+1 ; Save new pixel color
163 movff PRODL,ds_pixel+0 185 movff PRODL,ds_pixel+0
164 movlw 1 186 movlw 1
165 movwf ds_count ; And set count=1. 187 movwf ds_count ; And set count=1.
166 return 188 return
189
190 dump_screen_pix_black:
191 movlw .128 ; Max black pixel on a single byte.
192 cpfsgt ds_count ; Skip if count > 128
193 movf ds_count,W ; W <- min(128,count)
194 subwf ds_count,F ; ds_count <- ds_count-W
195 decf WREG ; Save as 0..127
196 dump_screen_pix_3:
197 movwf TXREG
198 call rs232_wait_tx
199 bra dump_screen_pixel_1 ; More to dump ?
200
201 dump_screen_pix_white:
202 movlw .64 ; Max white pixel on a single byte.
203 cpfsgt ds_count ; Skip if count > 64
204 movf ds_count,W ; W <- min(64,count)
205 subwf ds_count,F ; ds_count <- ds_count-W
206 decf WREG ; Save as 0..63
207 iorlw b'11000000' ; MARK as a compressed white.
208 bra dump_screen_pix_3
167 209
168 dump_screen_pixel_flush: 210 dump_screen_pixel_flush:
169 clrf PRODH 211 clrf PRODH
170 clrf PRODL 212 clrf PRODL
171 rcall dump_screen_pixel_1 ; Send it 213 rcall dump_screen_pixel_1 ; Send it