root / hw / vga_template.h @ 37952117
History | View | Annotate | Download (14.2 kB)
1 | e89f66ec | bellard | /*
|
---|---|---|---|
2 | e89f66ec | bellard | * QEMU VGA Emulator templates
|
3 | 5fafdf24 | ths | *
|
4 | e89f66ec | bellard | * Copyright (c) 2003 Fabrice Bellard
|
5 | 5fafdf24 | ths | *
|
6 | e89f66ec | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | e89f66ec | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | e89f66ec | bellard | * in the Software without restriction, including without limitation the rights
|
9 | e89f66ec | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | e89f66ec | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | e89f66ec | bellard | * furnished to do so, subject to the following conditions:
|
12 | e89f66ec | bellard | *
|
13 | e89f66ec | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | e89f66ec | bellard | * all copies or substantial portions of the Software.
|
15 | e89f66ec | bellard | *
|
16 | e89f66ec | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | e89f66ec | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | e89f66ec | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | e89f66ec | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | e89f66ec | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | e89f66ec | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | e89f66ec | bellard | * THE SOFTWARE.
|
23 | e89f66ec | bellard | */
|
24 | e89f66ec | bellard | |
25 | e89f66ec | bellard | #if DEPTH == 8 |
26 | e89f66ec | bellard | #define BPP 1 |
27 | 5fafdf24 | ths | #define PIXEL_TYPE uint8_t
|
28 | e89f66ec | bellard | #elif DEPTH == 15 || DEPTH == 16 |
29 | e89f66ec | bellard | #define BPP 2 |
30 | 5fafdf24 | ths | #define PIXEL_TYPE uint16_t
|
31 | e89f66ec | bellard | #elif DEPTH == 32 |
32 | e89f66ec | bellard | #define BPP 4 |
33 | 5fafdf24 | ths | #define PIXEL_TYPE uint32_t
|
34 | e89f66ec | bellard | #else
|
35 | e89f66ec | bellard | #error unsupport depth
|
36 | e89f66ec | bellard | #endif
|
37 | e89f66ec | bellard | |
38 | d3079cd2 | bellard | #ifdef BGR_FORMAT
|
39 | d3079cd2 | bellard | #define PIXEL_NAME glue(DEPTH, bgr)
|
40 | d3079cd2 | bellard | #else
|
41 | d3079cd2 | bellard | #define PIXEL_NAME DEPTH
|
42 | d3079cd2 | bellard | #endif /* BGR_FORMAT */ |
43 | d3079cd2 | bellard | |
44 | d3079cd2 | bellard | #if DEPTH != 15 && !defined(BGR_FORMAT) |
45 | e89f66ec | bellard | |
46 | 5fafdf24 | ths | static inline void glue(vga_draw_glyph_line_, DEPTH)(uint8_t *d, |
47 | 17b0018b | bellard | uint32_t font_data, |
48 | 5fafdf24 | ths | uint32_t xorcol, |
49 | 17b0018b | bellard | uint32_t bgcol) |
50 | e89f66ec | bellard | { |
51 | e89f66ec | bellard | #if BPP == 1 |
52 | e89f66ec | bellard | ((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol; |
53 | 188d8579 | bellard | ((uint32_t *)d)[1] = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol; |
54 | e89f66ec | bellard | #elif BPP == 2 |
55 | e89f66ec | bellard | ((uint32_t *)d)[0] = (dmask4[(font_data >> 6)] & xorcol) ^ bgcol; |
56 | e89f66ec | bellard | ((uint32_t *)d)[1] = (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol; |
57 | e89f66ec | bellard | ((uint32_t *)d)[2] = (dmask4[(font_data >> 2) & 3] & xorcol) ^ bgcol; |
58 | e89f66ec | bellard | ((uint32_t *)d)[3] = (dmask4[(font_data >> 0) & 3] & xorcol) ^ bgcol; |
59 | e89f66ec | bellard | #else
|
60 | b1ba6574 | bellard | ((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol; |
61 | b1ba6574 | bellard | ((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol; |
62 | b1ba6574 | bellard | ((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol; |
63 | b1ba6574 | bellard | ((uint32_t *)d)[3] = (-((font_data >> 4) & 1) & xorcol) ^ bgcol; |
64 | b1ba6574 | bellard | ((uint32_t *)d)[4] = (-((font_data >> 3) & 1) & xorcol) ^ bgcol; |
65 | b1ba6574 | bellard | ((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol; |
66 | b1ba6574 | bellard | ((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol; |
67 | b1ba6574 | bellard | ((uint32_t *)d)[7] = (-((font_data >> 0) & 1) & xorcol) ^ bgcol; |
68 | e89f66ec | bellard | #endif
|
69 | 17b0018b | bellard | } |
70 | 17b0018b | bellard | |
71 | 17b0018b | bellard | static void glue(vga_draw_glyph8_, DEPTH)(uint8_t *d, int linesize, |
72 | 17b0018b | bellard | const uint8_t *font_ptr, int h, |
73 | 17b0018b | bellard | uint32_t fgcol, uint32_t bgcol) |
74 | 17b0018b | bellard | { |
75 | 17b0018b | bellard | uint32_t font_data, xorcol; |
76 | 3b46e624 | ths | |
77 | 17b0018b | bellard | xorcol = bgcol ^ fgcol; |
78 | 17b0018b | bellard | do {
|
79 | 17b0018b | bellard | font_data = font_ptr[0];
|
80 | 17b0018b | bellard | glue(vga_draw_glyph_line_, DEPTH)(d, font_data, xorcol, bgcol); |
81 | 17b0018b | bellard | font_ptr += 4;
|
82 | 17b0018b | bellard | d += linesize; |
83 | 17b0018b | bellard | } while (--h);
|
84 | 17b0018b | bellard | } |
85 | 17b0018b | bellard | |
86 | 17b0018b | bellard | static void glue(vga_draw_glyph16_, DEPTH)(uint8_t *d, int linesize, |
87 | 17b0018b | bellard | const uint8_t *font_ptr, int h, |
88 | 17b0018b | bellard | uint32_t fgcol, uint32_t bgcol) |
89 | 17b0018b | bellard | { |
90 | 17b0018b | bellard | uint32_t font_data, xorcol; |
91 | 3b46e624 | ths | |
92 | 17b0018b | bellard | xorcol = bgcol ^ fgcol; |
93 | 17b0018b | bellard | do {
|
94 | 17b0018b | bellard | font_data = font_ptr[0];
|
95 | 5fafdf24 | ths | glue(vga_draw_glyph_line_, DEPTH)(d, |
96 | 5fafdf24 | ths | expand4to8[font_data >> 4],
|
97 | 17b0018b | bellard | xorcol, bgcol); |
98 | 5fafdf24 | ths | glue(vga_draw_glyph_line_, DEPTH)(d + 8 * BPP,
|
99 | 5fafdf24 | ths | expand4to8[font_data & 0x0f],
|
100 | 17b0018b | bellard | xorcol, bgcol); |
101 | e89f66ec | bellard | font_ptr += 4;
|
102 | e89f66ec | bellard | d += linesize; |
103 | e89f66ec | bellard | } while (--h);
|
104 | e89f66ec | bellard | } |
105 | e89f66ec | bellard | |
106 | e89f66ec | bellard | static void glue(vga_draw_glyph9_, DEPTH)(uint8_t *d, int linesize, |
107 | 5fafdf24 | ths | const uint8_t *font_ptr, int h, |
108 | e89f66ec | bellard | uint32_t fgcol, uint32_t bgcol, int dup9)
|
109 | e89f66ec | bellard | { |
110 | e89f66ec | bellard | uint32_t font_data, xorcol, v; |
111 | 3b46e624 | ths | |
112 | e89f66ec | bellard | xorcol = bgcol ^ fgcol; |
113 | e89f66ec | bellard | do {
|
114 | e89f66ec | bellard | font_data = font_ptr[0];
|
115 | e89f66ec | bellard | #if BPP == 1 |
116 | 188d8579 | bellard | cpu_to_32wu((uint32_t *)d, (dmask16[(font_data >> 4)] & xorcol) ^ bgcol);
|
117 | e89f66ec | bellard | v = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol; |
118 | 188d8579 | bellard | cpu_to_32wu(((uint32_t *)d)+1, v);
|
119 | e89f66ec | bellard | if (dup9)
|
120 | 39cf7803 | bellard | ((uint8_t *)d)[8] = v >> (24 * (1 - BIG)); |
121 | e89f66ec | bellard | else
|
122 | 39cf7803 | bellard | ((uint8_t *)d)[8] = bgcol;
|
123 | 3b46e624 | ths | |
124 | e89f66ec | bellard | #elif BPP == 2 |
125 | 188d8579 | bellard | cpu_to_32wu(((uint32_t *)d)+0, (dmask4[(font_data >> 6)] & xorcol) ^ bgcol); |
126 | 188d8579 | bellard | cpu_to_32wu(((uint32_t *)d)+1, (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol); |
127 | 188d8579 | bellard | cpu_to_32wu(((uint32_t *)d)+2, (dmask4[(font_data >> 2) & 3] & xorcol) ^ bgcol); |
128 | e89f66ec | bellard | v = (dmask4[(font_data >> 0) & 3] & xorcol) ^ bgcol; |
129 | 188d8579 | bellard | cpu_to_32wu(((uint32_t *)d)+3, v);
|
130 | e89f66ec | bellard | if (dup9)
|
131 | 39cf7803 | bellard | ((uint16_t *)d)[8] = v >> (16 * (1 - BIG)); |
132 | e89f66ec | bellard | else
|
133 | 39cf7803 | bellard | ((uint16_t *)d)[8] = bgcol;
|
134 | e89f66ec | bellard | #else
|
135 | eccabc6e | bellard | ((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol; |
136 | eccabc6e | bellard | ((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol; |
137 | eccabc6e | bellard | ((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol; |
138 | eccabc6e | bellard | ((uint32_t *)d)[3] = (-((font_data >> 4) & 1) & xorcol) ^ bgcol; |
139 | eccabc6e | bellard | ((uint32_t *)d)[4] = (-((font_data >> 3) & 1) & xorcol) ^ bgcol; |
140 | eccabc6e | bellard | ((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol; |
141 | eccabc6e | bellard | ((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol; |
142 | eccabc6e | bellard | v = (-((font_data >> 0) & 1) & xorcol) ^ bgcol; |
143 | e89f66ec | bellard | ((uint32_t *)d)[7] = v;
|
144 | e89f66ec | bellard | if (dup9)
|
145 | 39cf7803 | bellard | ((uint32_t *)d)[8] = v;
|
146 | e89f66ec | bellard | else
|
147 | 39cf7803 | bellard | ((uint32_t *)d)[8] = bgcol;
|
148 | e89f66ec | bellard | #endif
|
149 | e89f66ec | bellard | font_ptr += 4;
|
150 | e89f66ec | bellard | d += linesize; |
151 | e89f66ec | bellard | } while (--h);
|
152 | e89f66ec | bellard | } |
153 | e89f66ec | bellard | |
154 | 5fafdf24 | ths | /*
|
155 | e89f66ec | bellard | * 4 color mode
|
156 | e89f66ec | bellard | */
|
157 | cedd91d2 | Juan Quintela | static void glue(vga_draw_line2_, DEPTH)(VGACommonState *s1, uint8_t *d, |
158 | e89f66ec | bellard | const uint8_t *s, int width) |
159 | e89f66ec | bellard | { |
160 | e89f66ec | bellard | uint32_t plane_mask, *palette, data, v; |
161 | e89f66ec | bellard | int x;
|
162 | e89f66ec | bellard | |
163 | e89f66ec | bellard | palette = s1->last_palette; |
164 | 5e55efc9 | Blue Swirl | plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
|
165 | e89f66ec | bellard | width >>= 3;
|
166 | e89f66ec | bellard | for(x = 0; x < width; x++) { |
167 | e89f66ec | bellard | data = ((uint32_t *)s)[0];
|
168 | e89f66ec | bellard | data &= plane_mask; |
169 | e89f66ec | bellard | v = expand2[GET_PLANE(data, 0)];
|
170 | e89f66ec | bellard | v |= expand2[GET_PLANE(data, 2)] << 2; |
171 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[0] = palette[v >> 12]; |
172 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[1] = palette[(v >> 8) & 0xf]; |
173 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[2] = palette[(v >> 4) & 0xf]; |
174 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[3] = palette[(v >> 0) & 0xf]; |
175 | e89f66ec | bellard | |
176 | e89f66ec | bellard | v = expand2[GET_PLANE(data, 1)];
|
177 | e89f66ec | bellard | v |= expand2[GET_PLANE(data, 3)] << 2; |
178 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[4] = palette[v >> 12]; |
179 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[5] = palette[(v >> 8) & 0xf]; |
180 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[6] = palette[(v >> 4) & 0xf]; |
181 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[7] = palette[(v >> 0) & 0xf]; |
182 | e89f66ec | bellard | d += BPP * 8;
|
183 | e89f66ec | bellard | s += 4;
|
184 | e89f66ec | bellard | } |
185 | e89f66ec | bellard | } |
186 | e89f66ec | bellard | |
187 | 17b0018b | bellard | #if BPP == 1 |
188 | 17b0018b | bellard | #define PUT_PIXEL2(d, n, v) ((uint16_t *)d)[(n)] = (v)
|
189 | 17b0018b | bellard | #elif BPP == 2 |
190 | 17b0018b | bellard | #define PUT_PIXEL2(d, n, v) ((uint32_t *)d)[(n)] = (v)
|
191 | 17b0018b | bellard | #else
|
192 | 17b0018b | bellard | #define PUT_PIXEL2(d, n, v) \
|
193 | 17b0018b | bellard | ((uint32_t *)d)[2*(n)] = ((uint32_t *)d)[2*(n)+1] = (v) |
194 | 17b0018b | bellard | #endif
|
195 | 17b0018b | bellard | |
196 | 5fafdf24 | ths | /*
|
197 | 17b0018b | bellard | * 4 color mode, dup2 horizontal
|
198 | 17b0018b | bellard | */
|
199 | cedd91d2 | Juan Quintela | static void glue(vga_draw_line2d2_, DEPTH)(VGACommonState *s1, uint8_t *d, |
200 | 17b0018b | bellard | const uint8_t *s, int width) |
201 | 17b0018b | bellard | { |
202 | 17b0018b | bellard | uint32_t plane_mask, *palette, data, v; |
203 | 17b0018b | bellard | int x;
|
204 | 17b0018b | bellard | |
205 | 17b0018b | bellard | palette = s1->last_palette; |
206 | 5e55efc9 | Blue Swirl | plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
|
207 | 17b0018b | bellard | width >>= 3;
|
208 | 17b0018b | bellard | for(x = 0; x < width; x++) { |
209 | 17b0018b | bellard | data = ((uint32_t *)s)[0];
|
210 | 17b0018b | bellard | data &= plane_mask; |
211 | 17b0018b | bellard | v = expand2[GET_PLANE(data, 0)];
|
212 | 17b0018b | bellard | v |= expand2[GET_PLANE(data, 2)] << 2; |
213 | 17b0018b | bellard | PUT_PIXEL2(d, 0, palette[v >> 12]); |
214 | 17b0018b | bellard | PUT_PIXEL2(d, 1, palette[(v >> 8) & 0xf]); |
215 | 17b0018b | bellard | PUT_PIXEL2(d, 2, palette[(v >> 4) & 0xf]); |
216 | 17b0018b | bellard | PUT_PIXEL2(d, 3, palette[(v >> 0) & 0xf]); |
217 | 17b0018b | bellard | |
218 | 17b0018b | bellard | v = expand2[GET_PLANE(data, 1)];
|
219 | 17b0018b | bellard | v |= expand2[GET_PLANE(data, 3)] << 2; |
220 | 17b0018b | bellard | PUT_PIXEL2(d, 4, palette[v >> 12]); |
221 | 17b0018b | bellard | PUT_PIXEL2(d, 5, palette[(v >> 8) & 0xf]); |
222 | 17b0018b | bellard | PUT_PIXEL2(d, 6, palette[(v >> 4) & 0xf]); |
223 | 17b0018b | bellard | PUT_PIXEL2(d, 7, palette[(v >> 0) & 0xf]); |
224 | 17b0018b | bellard | d += BPP * 16;
|
225 | 17b0018b | bellard | s += 4;
|
226 | 17b0018b | bellard | } |
227 | 17b0018b | bellard | } |
228 | 17b0018b | bellard | |
229 | 5fafdf24 | ths | /*
|
230 | e89f66ec | bellard | * 16 color mode
|
231 | e89f66ec | bellard | */
|
232 | cedd91d2 | Juan Quintela | static void glue(vga_draw_line4_, DEPTH)(VGACommonState *s1, uint8_t *d, |
233 | e89f66ec | bellard | const uint8_t *s, int width) |
234 | e89f66ec | bellard | { |
235 | e89f66ec | bellard | uint32_t plane_mask, data, v, *palette; |
236 | e89f66ec | bellard | int x;
|
237 | e89f66ec | bellard | |
238 | e89f66ec | bellard | palette = s1->last_palette; |
239 | 5e55efc9 | Blue Swirl | plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
|
240 | e89f66ec | bellard | width >>= 3;
|
241 | e89f66ec | bellard | for(x = 0; x < width; x++) { |
242 | e89f66ec | bellard | data = ((uint32_t *)s)[0];
|
243 | e89f66ec | bellard | data &= plane_mask; |
244 | e89f66ec | bellard | v = expand4[GET_PLANE(data, 0)];
|
245 | e89f66ec | bellard | v |= expand4[GET_PLANE(data, 1)] << 1; |
246 | e89f66ec | bellard | v |= expand4[GET_PLANE(data, 2)] << 2; |
247 | e89f66ec | bellard | v |= expand4[GET_PLANE(data, 3)] << 3; |
248 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[0] = palette[v >> 28]; |
249 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[1] = palette[(v >> 24) & 0xf]; |
250 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[2] = palette[(v >> 20) & 0xf]; |
251 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[3] = palette[(v >> 16) & 0xf]; |
252 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[4] = palette[(v >> 12) & 0xf]; |
253 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[5] = palette[(v >> 8) & 0xf]; |
254 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[6] = palette[(v >> 4) & 0xf]; |
255 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[7] = palette[(v >> 0) & 0xf]; |
256 | e89f66ec | bellard | d += BPP * 8;
|
257 | e89f66ec | bellard | s += 4;
|
258 | e89f66ec | bellard | } |
259 | e89f66ec | bellard | } |
260 | e89f66ec | bellard | |
261 | 5fafdf24 | ths | /*
|
262 | 17b0018b | bellard | * 16 color mode, dup2 horizontal
|
263 | 17b0018b | bellard | */
|
264 | cedd91d2 | Juan Quintela | static void glue(vga_draw_line4d2_, DEPTH)(VGACommonState *s1, uint8_t *d, |
265 | 17b0018b | bellard | const uint8_t *s, int width) |
266 | 17b0018b | bellard | { |
267 | 17b0018b | bellard | uint32_t plane_mask, data, v, *palette; |
268 | 17b0018b | bellard | int x;
|
269 | 17b0018b | bellard | |
270 | 17b0018b | bellard | palette = s1->last_palette; |
271 | 5e55efc9 | Blue Swirl | plane_mask = mask16[s1->ar[VGA_ATC_PLANE_ENABLE] & 0xf];
|
272 | 17b0018b | bellard | width >>= 3;
|
273 | 17b0018b | bellard | for(x = 0; x < width; x++) { |
274 | 17b0018b | bellard | data = ((uint32_t *)s)[0];
|
275 | 17b0018b | bellard | data &= plane_mask; |
276 | 17b0018b | bellard | v = expand4[GET_PLANE(data, 0)];
|
277 | 17b0018b | bellard | v |= expand4[GET_PLANE(data, 1)] << 1; |
278 | 17b0018b | bellard | v |= expand4[GET_PLANE(data, 2)] << 2; |
279 | 17b0018b | bellard | v |= expand4[GET_PLANE(data, 3)] << 3; |
280 | 17b0018b | bellard | PUT_PIXEL2(d, 0, palette[v >> 28]); |
281 | 17b0018b | bellard | PUT_PIXEL2(d, 1, palette[(v >> 24) & 0xf]); |
282 | 17b0018b | bellard | PUT_PIXEL2(d, 2, palette[(v >> 20) & 0xf]); |
283 | 17b0018b | bellard | PUT_PIXEL2(d, 3, palette[(v >> 16) & 0xf]); |
284 | 17b0018b | bellard | PUT_PIXEL2(d, 4, palette[(v >> 12) & 0xf]); |
285 | 17b0018b | bellard | PUT_PIXEL2(d, 5, palette[(v >> 8) & 0xf]); |
286 | 17b0018b | bellard | PUT_PIXEL2(d, 6, palette[(v >> 4) & 0xf]); |
287 | 17b0018b | bellard | PUT_PIXEL2(d, 7, palette[(v >> 0) & 0xf]); |
288 | 17b0018b | bellard | d += BPP * 16;
|
289 | 17b0018b | bellard | s += 4;
|
290 | 17b0018b | bellard | } |
291 | 17b0018b | bellard | } |
292 | 17b0018b | bellard | |
293 | 5fafdf24 | ths | /*
|
294 | 17b0018b | bellard | * 256 color mode, double pixels
|
295 | 17b0018b | bellard | *
|
296 | 17b0018b | bellard | * XXX: add plane_mask support (never used in standard VGA modes)
|
297 | 17b0018b | bellard | */
|
298 | cedd91d2 | Juan Quintela | static void glue(vga_draw_line8d2_, DEPTH)(VGACommonState *s1, uint8_t *d, |
299 | 17b0018b | bellard | const uint8_t *s, int width) |
300 | 17b0018b | bellard | { |
301 | 17b0018b | bellard | uint32_t *palette; |
302 | 17b0018b | bellard | int x;
|
303 | 17b0018b | bellard | |
304 | 17b0018b | bellard | palette = s1->last_palette; |
305 | 17b0018b | bellard | width >>= 3;
|
306 | 17b0018b | bellard | for(x = 0; x < width; x++) { |
307 | 17b0018b | bellard | PUT_PIXEL2(d, 0, palette[s[0]]); |
308 | 17b0018b | bellard | PUT_PIXEL2(d, 1, palette[s[1]]); |
309 | 17b0018b | bellard | PUT_PIXEL2(d, 2, palette[s[2]]); |
310 | 17b0018b | bellard | PUT_PIXEL2(d, 3, palette[s[3]]); |
311 | 17b0018b | bellard | d += BPP * 8;
|
312 | 17b0018b | bellard | s += 4;
|
313 | 17b0018b | bellard | } |
314 | 17b0018b | bellard | } |
315 | 17b0018b | bellard | |
316 | 5fafdf24 | ths | /*
|
317 | 17b0018b | bellard | * standard 256 color mode
|
318 | e89f66ec | bellard | *
|
319 | e89f66ec | bellard | * XXX: add plane_mask support (never used in standard VGA modes)
|
320 | e89f66ec | bellard | */
|
321 | cedd91d2 | Juan Quintela | static void glue(vga_draw_line8_, DEPTH)(VGACommonState *s1, uint8_t *d, |
322 | e89f66ec | bellard | const uint8_t *s, int width) |
323 | e89f66ec | bellard | { |
324 | e89f66ec | bellard | uint32_t *palette; |
325 | e89f66ec | bellard | int x;
|
326 | e89f66ec | bellard | |
327 | e89f66ec | bellard | palette = s1->last_palette; |
328 | e89f66ec | bellard | width >>= 3;
|
329 | e89f66ec | bellard | for(x = 0; x < width; x++) { |
330 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[0] = palette[s[0]]; |
331 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[1] = palette[s[1]]; |
332 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[2] = palette[s[2]]; |
333 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[3] = palette[s[3]]; |
334 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[4] = palette[s[4]]; |
335 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[5] = palette[s[5]]; |
336 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[6] = palette[s[6]]; |
337 | e89f66ec | bellard | ((PIXEL_TYPE *)d)[7] = palette[s[7]]; |
338 | e89f66ec | bellard | d += BPP * 8;
|
339 | e89f66ec | bellard | s += 8;
|
340 | e89f66ec | bellard | } |
341 | e89f66ec | bellard | } |
342 | e89f66ec | bellard | |
343 | e89f66ec | bellard | #endif /* DEPTH != 15 */ |
344 | e89f66ec | bellard | |
345 | e89f66ec | bellard | |
346 | e89f66ec | bellard | /* XXX: optimize */
|
347 | e89f66ec | bellard | |
348 | 5fafdf24 | ths | /*
|
349 | e89f66ec | bellard | * 15 bit color
|
350 | e89f66ec | bellard | */
|
351 | cedd91d2 | Juan Quintela | static void glue(vga_draw_line15_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d, |
352 | e89f66ec | bellard | const uint8_t *s, int width) |
353 | e89f66ec | bellard | { |
354 | e2542fe2 | Juan Quintela | #if DEPTH == 15 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) |
355 | e89f66ec | bellard | memcpy(d, s, width * 2);
|
356 | e89f66ec | bellard | #else
|
357 | e89f66ec | bellard | int w;
|
358 | e89f66ec | bellard | uint32_t v, r, g, b; |
359 | e89f66ec | bellard | |
360 | e89f66ec | bellard | w = width; |
361 | e89f66ec | bellard | do {
|
362 | 61382a50 | bellard | v = lduw_raw((void *)s);
|
363 | e89f66ec | bellard | r = (v >> 7) & 0xf8; |
364 | e89f66ec | bellard | g = (v >> 2) & 0xf8; |
365 | e89f66ec | bellard | b = (v << 3) & 0xf8; |
366 | d3079cd2 | bellard | ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
|
367 | e89f66ec | bellard | s += 2;
|
368 | e89f66ec | bellard | d += BPP; |
369 | e89f66ec | bellard | } while (--w != 0); |
370 | 3b46e624 | ths | #endif
|
371 | e89f66ec | bellard | } |
372 | e89f66ec | bellard | |
373 | 5fafdf24 | ths | /*
|
374 | e89f66ec | bellard | * 16 bit color
|
375 | e89f66ec | bellard | */
|
376 | cedd91d2 | Juan Quintela | static void glue(vga_draw_line16_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d, |
377 | e89f66ec | bellard | const uint8_t *s, int width) |
378 | e89f66ec | bellard | { |
379 | e2542fe2 | Juan Quintela | #if DEPTH == 16 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) |
380 | e89f66ec | bellard | memcpy(d, s, width * 2);
|
381 | e89f66ec | bellard | #else
|
382 | e89f66ec | bellard | int w;
|
383 | e89f66ec | bellard | uint32_t v, r, g, b; |
384 | e89f66ec | bellard | |
385 | e89f66ec | bellard | w = width; |
386 | e89f66ec | bellard | do {
|
387 | 61382a50 | bellard | v = lduw_raw((void *)s);
|
388 | e89f66ec | bellard | r = (v >> 8) & 0xf8; |
389 | e89f66ec | bellard | g = (v >> 3) & 0xfc; |
390 | e89f66ec | bellard | b = (v << 3) & 0xf8; |
391 | d3079cd2 | bellard | ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
|
392 | e89f66ec | bellard | s += 2;
|
393 | e89f66ec | bellard | d += BPP; |
394 | e89f66ec | bellard | } while (--w != 0); |
395 | 3b46e624 | ths | #endif
|
396 | e89f66ec | bellard | } |
397 | e89f66ec | bellard | |
398 | 5fafdf24 | ths | /*
|
399 | 4fa0f5d2 | bellard | * 24 bit color
|
400 | 4fa0f5d2 | bellard | */
|
401 | cedd91d2 | Juan Quintela | static void glue(vga_draw_line24_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d, |
402 | 4fa0f5d2 | bellard | const uint8_t *s, int width) |
403 | 4fa0f5d2 | bellard | { |
404 | 4fa0f5d2 | bellard | int w;
|
405 | 4fa0f5d2 | bellard | uint32_t r, g, b; |
406 | 4fa0f5d2 | bellard | |
407 | 4fa0f5d2 | bellard | w = width; |
408 | 4fa0f5d2 | bellard | do {
|
409 | 53c862a8 | bellard | #if defined(TARGET_WORDS_BIGENDIAN)
|
410 | 53c862a8 | bellard | r = s[0];
|
411 | 53c862a8 | bellard | g = s[1];
|
412 | 53c862a8 | bellard | b = s[2];
|
413 | 53c862a8 | bellard | #else
|
414 | 4fa0f5d2 | bellard | b = s[0];
|
415 | 4fa0f5d2 | bellard | g = s[1];
|
416 | 4fa0f5d2 | bellard | r = s[2];
|
417 | 53c862a8 | bellard | #endif
|
418 | d3079cd2 | bellard | ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
|
419 | 4fa0f5d2 | bellard | s += 3;
|
420 | 4fa0f5d2 | bellard | d += BPP; |
421 | 4fa0f5d2 | bellard | } while (--w != 0); |
422 | 4fa0f5d2 | bellard | } |
423 | 4fa0f5d2 | bellard | |
424 | 5fafdf24 | ths | /*
|
425 | e89f66ec | bellard | * 32 bit color
|
426 | e89f66ec | bellard | */
|
427 | cedd91d2 | Juan Quintela | static void glue(vga_draw_line32_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d, |
428 | e89f66ec | bellard | const uint8_t *s, int width) |
429 | e89f66ec | bellard | { |
430 | e2542fe2 | Juan Quintela | #if DEPTH == 32 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) && !defined(BGR_FORMAT) |
431 | e89f66ec | bellard | memcpy(d, s, width * 4);
|
432 | e89f66ec | bellard | #else
|
433 | e89f66ec | bellard | int w;
|
434 | e89f66ec | bellard | uint32_t r, g, b; |
435 | e89f66ec | bellard | |
436 | e89f66ec | bellard | w = width; |
437 | e89f66ec | bellard | do {
|
438 | 53c862a8 | bellard | #if defined(TARGET_WORDS_BIGENDIAN)
|
439 | 53c862a8 | bellard | r = s[1];
|
440 | 53c862a8 | bellard | g = s[2];
|
441 | 53c862a8 | bellard | b = s[3];
|
442 | 53c862a8 | bellard | #else
|
443 | e89f66ec | bellard | b = s[0];
|
444 | e89f66ec | bellard | g = s[1];
|
445 | e89f66ec | bellard | r = s[2];
|
446 | 53c862a8 | bellard | #endif
|
447 | d3079cd2 | bellard | ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
|
448 | e89f66ec | bellard | s += 4;
|
449 | e89f66ec | bellard | d += BPP; |
450 | e89f66ec | bellard | } while (--w != 0); |
451 | e89f66ec | bellard | #endif
|
452 | e89f66ec | bellard | } |
453 | e89f66ec | bellard | |
454 | 17b0018b | bellard | #undef PUT_PIXEL2
|
455 | e89f66ec | bellard | #undef DEPTH
|
456 | e89f66ec | bellard | #undef BPP
|
457 | e89f66ec | bellard | #undef PIXEL_TYPE
|
458 | d3079cd2 | bellard | #undef PIXEL_NAME
|
459 | d3079cd2 | bellard | #undef BGR_FORMAT |