root / hw / cirrus_vga_template.h @ 3871481c
History | View | Annotate | Download (2.9 kB)
1 | 94d7b483 | Blue Swirl | /*
|
---|---|---|---|
2 | 94d7b483 | Blue Swirl | * QEMU Cirrus VGA Emulator templates
|
3 | 94d7b483 | Blue Swirl | *
|
4 | 94d7b483 | Blue Swirl | * Copyright (c) 2003 Fabrice Bellard
|
5 | 94d7b483 | Blue Swirl | *
|
6 | 94d7b483 | Blue Swirl | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 94d7b483 | Blue Swirl | * of this software and associated documentation files (the "Software"), to deal
|
8 | 94d7b483 | Blue Swirl | * in the Software without restriction, including without limitation the rights
|
9 | 94d7b483 | Blue Swirl | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 94d7b483 | Blue Swirl | * copies of the Software, and to permit persons to whom the Software is
|
11 | 94d7b483 | Blue Swirl | * furnished to do so, subject to the following conditions:
|
12 | 94d7b483 | Blue Swirl | *
|
13 | 94d7b483 | Blue Swirl | * The above copyright notice and this permission notice shall be included in
|
14 | 94d7b483 | Blue Swirl | * all copies or substantial portions of the Software.
|
15 | 94d7b483 | Blue Swirl | *
|
16 | 94d7b483 | Blue Swirl | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 94d7b483 | Blue Swirl | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 94d7b483 | Blue Swirl | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 94d7b483 | Blue Swirl | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 94d7b483 | Blue Swirl | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 94d7b483 | Blue Swirl | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 94d7b483 | Blue Swirl | * THE SOFTWARE.
|
23 | 94d7b483 | Blue Swirl | */
|
24 | 94d7b483 | Blue Swirl | |
25 | 94d7b483 | Blue Swirl | #if DEPTH == 8 |
26 | 94d7b483 | Blue Swirl | #define BPP 1 |
27 | 94d7b483 | Blue Swirl | #elif DEPTH == 15 || DEPTH == 16 |
28 | 94d7b483 | Blue Swirl | #define BPP 2 |
29 | 94d7b483 | Blue Swirl | #elif DEPTH == 32 |
30 | 94d7b483 | Blue Swirl | #define BPP 4 |
31 | 94d7b483 | Blue Swirl | #else
|
32 | 94d7b483 | Blue Swirl | #error unsupported depth
|
33 | 94d7b483 | Blue Swirl | #endif
|
34 | 94d7b483 | Blue Swirl | |
35 | 94d7b483 | Blue Swirl | static void glue(vga_draw_cursor_line_, DEPTH)(uint8_t *d1, |
36 | 94d7b483 | Blue Swirl | const uint8_t *src1,
|
37 | 94d7b483 | Blue Swirl | int poffset, int w, |
38 | 94d7b483 | Blue Swirl | unsigned int color0, |
39 | 94d7b483 | Blue Swirl | unsigned int color1, |
40 | 94d7b483 | Blue Swirl | unsigned int color_xor) |
41 | 94d7b483 | Blue Swirl | { |
42 | 94d7b483 | Blue Swirl | const uint8_t *plane0, *plane1;
|
43 | 94d7b483 | Blue Swirl | int x, b0, b1;
|
44 | 94d7b483 | Blue Swirl | uint8_t *d; |
45 | 94d7b483 | Blue Swirl | |
46 | 94d7b483 | Blue Swirl | d = d1; |
47 | 94d7b483 | Blue Swirl | plane0 = src1; |
48 | 94d7b483 | Blue Swirl | plane1 = src1 + poffset; |
49 | 94d7b483 | Blue Swirl | for (x = 0; x < w; x++) { |
50 | 94d7b483 | Blue Swirl | b0 = (plane0[x >> 3] >> (7 - (x & 7))) & 1; |
51 | 94d7b483 | Blue Swirl | b1 = (plane1[x >> 3] >> (7 - (x & 7))) & 1; |
52 | 94d7b483 | Blue Swirl | #if DEPTH == 8 |
53 | 94d7b483 | Blue Swirl | switch (b0 | (b1 << 1)) { |
54 | 94d7b483 | Blue Swirl | case 0: |
55 | 94d7b483 | Blue Swirl | break;
|
56 | 94d7b483 | Blue Swirl | case 1: |
57 | 94d7b483 | Blue Swirl | d[0] ^= color_xor;
|
58 | 94d7b483 | Blue Swirl | break;
|
59 | 94d7b483 | Blue Swirl | case 2: |
60 | 94d7b483 | Blue Swirl | d[0] = color0;
|
61 | 94d7b483 | Blue Swirl | break;
|
62 | 94d7b483 | Blue Swirl | case 3: |
63 | 94d7b483 | Blue Swirl | d[0] = color1;
|
64 | 94d7b483 | Blue Swirl | break;
|
65 | 94d7b483 | Blue Swirl | } |
66 | 94d7b483 | Blue Swirl | #elif DEPTH == 16 |
67 | 94d7b483 | Blue Swirl | switch (b0 | (b1 << 1)) { |
68 | 94d7b483 | Blue Swirl | case 0: |
69 | 94d7b483 | Blue Swirl | break;
|
70 | 94d7b483 | Blue Swirl | case 1: |
71 | 94d7b483 | Blue Swirl | ((uint16_t *)d)[0] ^= color_xor;
|
72 | 94d7b483 | Blue Swirl | break;
|
73 | 94d7b483 | Blue Swirl | case 2: |
74 | 94d7b483 | Blue Swirl | ((uint16_t *)d)[0] = color0;
|
75 | 94d7b483 | Blue Swirl | break;
|
76 | 94d7b483 | Blue Swirl | case 3: |
77 | 94d7b483 | Blue Swirl | ((uint16_t *)d)[0] = color1;
|
78 | 94d7b483 | Blue Swirl | break;
|
79 | 94d7b483 | Blue Swirl | } |
80 | 94d7b483 | Blue Swirl | #elif DEPTH == 32 |
81 | 94d7b483 | Blue Swirl | switch (b0 | (b1 << 1)) { |
82 | 94d7b483 | Blue Swirl | case 0: |
83 | 94d7b483 | Blue Swirl | break;
|
84 | 94d7b483 | Blue Swirl | case 1: |
85 | 94d7b483 | Blue Swirl | ((uint32_t *)d)[0] ^= color_xor;
|
86 | 94d7b483 | Blue Swirl | break;
|
87 | 94d7b483 | Blue Swirl | case 2: |
88 | 94d7b483 | Blue Swirl | ((uint32_t *)d)[0] = color0;
|
89 | 94d7b483 | Blue Swirl | break;
|
90 | 94d7b483 | Blue Swirl | case 3: |
91 | 94d7b483 | Blue Swirl | ((uint32_t *)d)[0] = color1;
|
92 | 94d7b483 | Blue Swirl | break;
|
93 | 94d7b483 | Blue Swirl | } |
94 | 94d7b483 | Blue Swirl | #else
|
95 | 94d7b483 | Blue Swirl | #error unsupported depth
|
96 | 94d7b483 | Blue Swirl | #endif
|
97 | 94d7b483 | Blue Swirl | d += BPP; |
98 | 94d7b483 | Blue Swirl | } |
99 | 94d7b483 | Blue Swirl | } |
100 | 94d7b483 | Blue Swirl | |
101 | 94d7b483 | Blue Swirl | #undef DEPTH
|
102 | 94d7b483 | Blue Swirl | #undef BPP |