Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/dump_screen.asm @ 332:1828234369fc ScreenDump
Added dump_screen compression. From ~15 to ~2/3 secondes.
author | JeanDo |
---|---|
date | Wed, 11 May 2011 01:37:29 +0200 |
parents | 469f4861c7c1 |
children | 9ee86a19f1fa |
comparison
equal
deleted
inserted
replaced
331:469f4861c7c1 | 332:1828234369fc |
---|---|
22 ; HISTORY | 22 ; HISTORY |
23 ; 2011-05-08 : [jDG] Creation. | 23 ; 2011-05-08 : [jDG] Creation. |
24 ; | 24 ; |
25 ; BUGS : | 25 ; BUGS : |
26 ; * ... | 26 ; * ... |
27 ;============================================================================= | |
28 CBLOCK 0x000 | |
29 ds_line ; Current line (0..239). | |
30 ds_column ; Current columnx2 (0..159) | |
31 ds_pixel:2 ; Current pixel color. | |
32 ds_count ; Repetition count. | |
33 ENDC | |
27 ;============================================================================= | 34 ;============================================================================= |
28 | 35 |
29 ; Manage interface to the OSTC platform: | 36 ; Manage interface to the OSTC platform: |
30 dump_screen: | 37 dump_screen: |
31 bcf uart_dump_screen ; clear flag! | 38 bcf uart_dump_screen ; clear flag! |
74 AA_CMD_WRITE 0x22 ; Start reading. | 81 AA_CMD_WRITE 0x22 ; Start reading. |
75 rcall PLED_DataRead ; Dummy pixel to skip. | 82 rcall PLED_DataRead ; Dummy pixel to skip. |
76 rcall PLED_DataRead ; Dummy pixel to skip. | 83 rcall PLED_DataRead ; Dummy pixel to skip. |
77 | 84 |
78 movlw .160 ; 160x2 columns | 85 movlw .160 ; 160x2 columns |
79 movwf uart1_temp | 86 movwf ds_column |
87 rcall dump_screen_pixel_reset | |
88 | |
80 dump_screen_1: | 89 dump_screen_1: |
81 btg LED_red ; LEDactivity toggle | 90 btg LED_red ; LEDactivity toggle |
82 | 91 |
83 AA_CMD_WRITE 0x22 ; Re-sync data. | 92 AA_CMD_WRITE 0x22 ; Re-sync data. |
84 | 93 |
85 movlw .240 ; 240 lines | 94 setf TRISD ; PortD as input. |
86 movwf uart2_temp | |
87 | 95 |
88 setf TRISD ; PortD as input. | 96 ; Dump even column |
89 clrf PORTD | 97 movlw .240 ; 240 lines, once. |
98 movwf ds_line | |
99 dump_screen_2: | |
100 rcall PLED_DataRead ; read pixel-high byte | |
101 movwf PRODH | |
102 rcall PLED_DataRead ; read pixel-low byte | |
103 movwf PRODL | |
104 rcall dump_screen_pixel | |
90 | 105 |
91 dump_screen_2: | 106 decfsz ds_line,F |
107 bra dump_screen_2 | |
108 rcall dump_screen_pixel_flush | |
92 | 109 |
93 rcall PLED_DataRead ; read first pixel-low byte | 110 ; Dump odd column |
94 movwf TXREG ; send | 111 movlw .240 ; 240 lines, twice. |
95 call rs232_wait_tx ; wait for UART | 112 movwf ds_line |
113 dump_screen_3: | |
114 rcall PLED_DataRead ; read pixel-high byte | |
115 movwf PRODH | |
116 rcall PLED_DataRead ; read pixel-low byte | |
117 movwf PRODL | |
118 rcall dump_screen_pixel | |
96 | 119 |
97 rcall PLED_DataRead ; read first pixel-high byte | 120 decfsz ds_line,F |
98 movwf TXREG ; send | 121 bra dump_screen_3 |
99 call rs232_wait_tx ; wait for UART | 122 rcall dump_screen_pixel_flush |
100 | |
101 rcall PLED_DataRead ; read second pixel-low byte | |
102 movwf TXREG ; send | |
103 call rs232_wait_tx ; wait for UART | |
104 | |
105 rcall PLED_DataRead ; read second pixel-high byte | |
106 movwf TXREG ; send | |
107 call rs232_wait_tx ; wait for UART | |
108 | |
109 | |
110 decfsz uart2_temp,F | |
111 bra dump_screen_2 | |
112 | 123 |
113 clrf TRISD ; Back to normal (PortD as output) | 124 clrf TRISD ; Back to normal (PortD as output) |
114 | 125 |
115 decfsz uart1_temp,F | 126 decfsz ds_column,F |
116 bra dump_screen_1 | 127 bra dump_screen_1 |
117 | 128 |
118 AA_CMD_WRITE 0x00 ; NOP, to stop Address Update Counter | 129 AA_CMD_WRITE 0x00 ; NOP, to stop Address Update Counter |
119 return | 130 return |
120 | 131 |
132 ;============================================================================= | |
133 ; Pixel compression | |
134 ; | |
135 ; Input: PRODH:L = pixel. | |
136 ; Output: Compressed stream on output. | |
137 ; | |
138 dump_screen_pixel: | |
139 movf PRODH,W ; Compare pixel-high | |
140 xorwf ds_pixel+1,W | |
141 bnz dump_screen_pixel_1 ; Different -> dump. | |
142 | |
143 movf PRODL,W ; Compare pixel-low | |
144 xorwf ds_pixel+0,W | |
145 bnz dump_screen_pixel_1 ; Different -> dump. | |
146 | |
147 incf ds_count,F ; Same color: just increment. | |
148 return | |
149 | |
150 dump_screen_pixel_1: ; Send (pixel,count) tuple | |
151 movf ds_count,W ; Is count zero ? | |
152 bz dump_screen_pixel_2 ; Yes: skip sending. | |
153 | |
154 movff ds_pixel+1,TXREG | |
155 call rs232_wait_tx ; wait for UART | |
156 movff ds_pixel+0,TXREG | |
157 call rs232_wait_tx ; wait for UART | |
158 movff ds_count,TXREG | |
159 call rs232_wait_tx ; wait for UART | |
160 | |
161 dump_screen_pixel_2: | |
162 movff PRODH,ds_pixel+1 ; Save new pixel color | |
163 movff PRODL,ds_pixel+0 | |
164 movlw 1 | |
165 movwf ds_count ; And set count=1. | |
166 return | |
167 | |
168 dump_screen_pixel_flush: | |
169 clrf PRODH | |
170 clrf PRODL | |
171 rcall dump_screen_pixel_1 ; Send it | |
172 dump_screen_pixel_reset: | |
173 clrf ds_count ; But clear count. | |
174 return |