comparison code_part1/OSTC_code_asm_part1/color_processor.asm @ 102:b13ace8d052f

Scribble_15 at wakeup...
author JeanDo
date Mon, 13 Dec 2010 23:49:52 +0100
parents
children
comparison
equal deleted inserted replaced
101:526d2c016645 102:b13ace8d052f
1 ;=============================================================================
2 ;
3 ; File color_processor.asm
4 ;
5 ; Decompress and draw an image.
6 ;
7 ; This program is free software: you can redistribute it and/or modify
8 ; it under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation, either version 3 of the License, or
10 ; (at your option) any later version.
11 ;
12 ; This program is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ; GNU General Public License for more details.
16 ;
17 ; You should have received a copy of the GNU General Public License
18 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
19 ;
20 ; Copyright (c) 2010, JD Gascuel.
21 ;=============================================================================
22 ; HISTORY
23 ; 2010-12-13 : [jDG] Creation
24 ;
25 ; RATIONALS: The OSTC have a nice color screen, and a std geek attitude impose
26 ; to show off ... ;-)
27 ;
28 ; Inputs: TBLPTR points to the image description block.
29 ; win_top, win_leftx2 the Top/Leftx2 corner here to put the image.
30 ; Ouputs: None.
31 ; Trashed: TBLPTR, TABLAT, FSR2, PROD, aa_width, aa_height
32 ;
33 ; ImageBloc:
34 ; db widthx2, height
35 ; db nbColors, 0
36 ; dw color0, color1, color2, color3, ...
37 ; db ...packed pixels...
38 ;
39 ; Limitations:
40 ; * nbColors should be <= 15.
41 ; * image width should be even.
42 ; * image left border should be on even position too.
43 ;
44 ;Temporary overlay (in bank 0)
45 img_width equ aa_width
46 img_height equ aa_height
47 img_top equ win_top
48 img_left equ win_leftx2
49 img_pixelsL equ aa_start+0
50 img_pixelsH equ aa_start+1
51 img_pixelsU equ aa_end+0
52 img_countL equ aa_end+1
53 img_countH equ aa_colorDiv+0
54 img_colors equ aa_colorDiv+1
55 colorTable equ letter
56
57 ;-----------------------------------------------------------------------------
58 ; Make an entry in the link map.
59 color_processor code
60
61 ;-----------------------------------------------------------------------------
62 color_image:
63 movlb HIGH(img_width)
64
65 ;---- Get image parameters -------------------------------------------
66 tblrd*+
67 movff TABLAT,img_width
68 tblrd*+
69 movff TABLAT,img_height
70 tblrd*+
71 movff TABLAT,img_colors
72 tblrd*+
73 ;---- Copy color table -----------------------------------------------
74 movf img_colors,W
75 lfsr FSR2,colorTable
76 get_colors_loop:
77 tblrd*+
78 movff TABLAT,POSTINC2
79 tblrd*+
80 movff TABLAT,POSTINC2
81 decfsz WREG
82 bra get_colors_loop
83
84 ; Compute width * height * 2 : the number of pixels to write.
85 clrf img_pixelsU
86 movf img_width,W ; Compute number of pixels to draw
87 mulwf img_height ; 0 .. 160x240
88 rlcf PRODL ; x2 --> 0 .. 320x240, might by > 0xFFFF
89 rlcf PRODH
90 movff PRODL, img_pixelsL
91 movff PRODH, img_pixelsH
92 rlcf img_pixelsU ; Get the upper bit in place.
93
94 ;---- Send window command --------------------------------------------
95 clrf img_width+1 ; x2 on width, for the true box size.
96 rlcf img_width+0
97 rlcf img_width+1
98 call aa_box_cmd
99 AA_CMD_WRITE 0x22
100
101 ;---- Decode pixels --------------------------------------------------
102 color_image_loop_xy:
103 ; Get pixel count
104 clrf img_countL
105 clrf img_countH
106
107 color_image_loop_count:
108 tblrd*+ ; Get one byte
109
110 movlw 0x0F ; Get count bits
111 andwf TABLAT,W
112 swapf WREG ; On top-4 bits of W
113 rlcf WREG ; Push topmost bit into img_count:2
114 rlcf img_countL
115 rlcf img_countH
116 rlcf WREG ; Push topmost bit into img_count:2
117 rlcf img_countL
118 rlcf img_countH
119 rlcf WREG ; Push topmost bit into img_count:2
120 rlcf img_countL
121 rlcf img_countH
122 rlcf WREG ; Push topmost bit into img_count:2
123 rlcf img_countL
124 rlcf img_countH
125
126 movf TABLAT,W ; Does the color-bits mark a big-count ?
127 andlw 0xF0
128 xorlw 0xF0
129 bz color_image_loop_count ; YES: loop for more count bits.
130
131 ; Get pixel color into PROD
132 xorlw 0xF0 ; Get back index.
133 swapf WREG ; Get color index to lower bits.
134 addwf WREG ; x2
135 addlw LOW(letter) ; 0x60 + 2 * .15 < 0x80.
136 movff WREG,FSR2L
137 movff POSTINC2,PRODL
138 movff POSTINC2,PRODH
139
140 ; Substract count-1 from the number of pixel we should do.
141 movf img_countL,W ; Make a 24bit substraction.
142 subwf img_pixelsL,F
143 movf img_countH,W
144 subwfb img_pixelsH,F
145 movlw 0
146 subwfb img_pixelsU,F
147
148 incf img_countL ; Get back the true count.
149 addwfc img_countH
150
151 ; Loop sending pixel color
152 incf img_countH ; Because we decrement first, should add one here !
153 color_image_loop_pixel:
154 AA_DATA_WRITE_PROD
155 decfsz img_countL
156 bra color_image_loop_pixel
157 decfsz img_countH
158 bra color_image_loop_pixel
159
160 ; And count (on a 17bit counter)
161 clrf WREG ; Make a 24bit decrement.
162 decf img_pixelsL
163 subwfb img_pixelsH,F
164 subwfb img_pixelsU,F
165
166 movf img_pixelsL,W ; Test if img_pixels == 0
167 iorwf img_pixelsH,W
168 iorwf img_pixelsU,W
169 bnz color_image_loop_xy ; NO: loop...
170
171 ;---- Closeup --------------------------------------------------------
172 AA_CMD_WRITE 0x00
173 return