Mercurial > sdl-ios-xcode
comparison src/video/windx5/SDL_dx5video.c @ 1895:c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 10 Jul 2006 21:04:37 +0000 |
parents | 339d733e3699 |
children |
comparison
equal
deleted
inserted
replaced
1894:c69cee13dd76 | 1895:c121d94672cb |
---|---|
54 #define PC_NOCOLLAPSE 0 | 54 #define PC_NOCOLLAPSE 0 |
55 #endif | 55 #endif |
56 | 56 |
57 | 57 |
58 /* DirectX function pointers for video and events */ | 58 /* DirectX function pointers for video and events */ |
59 HRESULT (WINAPI *DDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter ); | 59 HRESULT(WINAPI * DDrawCreate) (GUID FAR * lpGUID, LPDIRECTDRAW FAR * lplpDD, |
60 HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT *ppDI, LPUNKNOWN punkOuter); | 60 IUnknown FAR * pUnkOuter); |
61 HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion, | |
62 LPDIRECTINPUT * ppDI, LPUNKNOWN punkOuter); | |
61 | 63 |
62 /* This is the rect EnumModes2 uses */ | 64 /* This is the rect EnumModes2 uses */ |
63 struct DX5EnumRect { | 65 struct DX5EnumRect |
64 SDL_Rect r; | 66 { |
65 int refreshRate; | 67 SDL_Rect r; |
66 struct DX5EnumRect* next; | 68 int refreshRate; |
69 struct DX5EnumRect *next; | |
67 }; | 70 }; |
68 static struct DX5EnumRect *enumlists[NUM_MODELISTS]; | 71 static struct DX5EnumRect *enumlists[NUM_MODELISTS]; |
69 | 72 |
70 /* | 73 /* |
71 * Experimentally determined values for c_cfDI* constants used in DirectX 5.0 | 74 * Experimentally determined values for c_cfDI* constants used in DirectX 5.0 |
72 */ | 75 */ |
73 | 76 |
74 /* Keyboard */ | 77 /* Keyboard */ |
75 | 78 |
76 static DIOBJECTDATAFORMAT KBD_fmt[] = { | 79 static DIOBJECTDATAFORMAT KBD_fmt[] = { |
77 { &GUID_Key, 0, 0x8000000C, 0x00000000 }, | 80 {&GUID_Key, 0, 0x8000000C, 0x00000000}, |
78 { &GUID_Key, 1, 0x8000010C, 0x00000000 }, | 81 {&GUID_Key, 1, 0x8000010C, 0x00000000}, |
79 { &GUID_Key, 2, 0x8000020C, 0x00000000 }, | 82 {&GUID_Key, 2, 0x8000020C, 0x00000000}, |
80 { &GUID_Key, 3, 0x8000030C, 0x00000000 }, | 83 {&GUID_Key, 3, 0x8000030C, 0x00000000}, |
81 { &GUID_Key, 4, 0x8000040C, 0x00000000 }, | 84 {&GUID_Key, 4, 0x8000040C, 0x00000000}, |
82 { &GUID_Key, 5, 0x8000050C, 0x00000000 }, | 85 {&GUID_Key, 5, 0x8000050C, 0x00000000}, |
83 { &GUID_Key, 6, 0x8000060C, 0x00000000 }, | 86 {&GUID_Key, 6, 0x8000060C, 0x00000000}, |
84 { &GUID_Key, 7, 0x8000070C, 0x00000000 }, | 87 {&GUID_Key, 7, 0x8000070C, 0x00000000}, |
85 { &GUID_Key, 8, 0x8000080C, 0x00000000 }, | 88 {&GUID_Key, 8, 0x8000080C, 0x00000000}, |
86 { &GUID_Key, 9, 0x8000090C, 0x00000000 }, | 89 {&GUID_Key, 9, 0x8000090C, 0x00000000}, |
87 { &GUID_Key, 10, 0x80000A0C, 0x00000000 }, | 90 {&GUID_Key, 10, 0x80000A0C, 0x00000000}, |
88 { &GUID_Key, 11, 0x80000B0C, 0x00000000 }, | 91 {&GUID_Key, 11, 0x80000B0C, 0x00000000}, |
89 { &GUID_Key, 12, 0x80000C0C, 0x00000000 }, | 92 {&GUID_Key, 12, 0x80000C0C, 0x00000000}, |
90 { &GUID_Key, 13, 0x80000D0C, 0x00000000 }, | 93 {&GUID_Key, 13, 0x80000D0C, 0x00000000}, |
91 { &GUID_Key, 14, 0x80000E0C, 0x00000000 }, | 94 {&GUID_Key, 14, 0x80000E0C, 0x00000000}, |
92 { &GUID_Key, 15, 0x80000F0C, 0x00000000 }, | 95 {&GUID_Key, 15, 0x80000F0C, 0x00000000}, |
93 { &GUID_Key, 16, 0x8000100C, 0x00000000 }, | 96 {&GUID_Key, 16, 0x8000100C, 0x00000000}, |
94 { &GUID_Key, 17, 0x8000110C, 0x00000000 }, | 97 {&GUID_Key, 17, 0x8000110C, 0x00000000}, |
95 { &GUID_Key, 18, 0x8000120C, 0x00000000 }, | 98 {&GUID_Key, 18, 0x8000120C, 0x00000000}, |
96 { &GUID_Key, 19, 0x8000130C, 0x00000000 }, | 99 {&GUID_Key, 19, 0x8000130C, 0x00000000}, |
97 { &GUID_Key, 20, 0x8000140C, 0x00000000 }, | 100 {&GUID_Key, 20, 0x8000140C, 0x00000000}, |
98 { &GUID_Key, 21, 0x8000150C, 0x00000000 }, | 101 {&GUID_Key, 21, 0x8000150C, 0x00000000}, |
99 { &GUID_Key, 22, 0x8000160C, 0x00000000 }, | 102 {&GUID_Key, 22, 0x8000160C, 0x00000000}, |
100 { &GUID_Key, 23, 0x8000170C, 0x00000000 }, | 103 {&GUID_Key, 23, 0x8000170C, 0x00000000}, |
101 { &GUID_Key, 24, 0x8000180C, 0x00000000 }, | 104 {&GUID_Key, 24, 0x8000180C, 0x00000000}, |
102 { &GUID_Key, 25, 0x8000190C, 0x00000000 }, | 105 {&GUID_Key, 25, 0x8000190C, 0x00000000}, |
103 { &GUID_Key, 26, 0x80001A0C, 0x00000000 }, | 106 {&GUID_Key, 26, 0x80001A0C, 0x00000000}, |
104 { &GUID_Key, 27, 0x80001B0C, 0x00000000 }, | 107 {&GUID_Key, 27, 0x80001B0C, 0x00000000}, |
105 { &GUID_Key, 28, 0x80001C0C, 0x00000000 }, | 108 {&GUID_Key, 28, 0x80001C0C, 0x00000000}, |
106 { &GUID_Key, 29, 0x80001D0C, 0x00000000 }, | 109 {&GUID_Key, 29, 0x80001D0C, 0x00000000}, |
107 { &GUID_Key, 30, 0x80001E0C, 0x00000000 }, | 110 {&GUID_Key, 30, 0x80001E0C, 0x00000000}, |
108 { &GUID_Key, 31, 0x80001F0C, 0x00000000 }, | 111 {&GUID_Key, 31, 0x80001F0C, 0x00000000}, |
109 { &GUID_Key, 32, 0x8000200C, 0x00000000 }, | 112 {&GUID_Key, 32, 0x8000200C, 0x00000000}, |
110 { &GUID_Key, 33, 0x8000210C, 0x00000000 }, | 113 {&GUID_Key, 33, 0x8000210C, 0x00000000}, |
111 { &GUID_Key, 34, 0x8000220C, 0x00000000 }, | 114 {&GUID_Key, 34, 0x8000220C, 0x00000000}, |
112 { &GUID_Key, 35, 0x8000230C, 0x00000000 }, | 115 {&GUID_Key, 35, 0x8000230C, 0x00000000}, |
113 { &GUID_Key, 36, 0x8000240C, 0x00000000 }, | 116 {&GUID_Key, 36, 0x8000240C, 0x00000000}, |
114 { &GUID_Key, 37, 0x8000250C, 0x00000000 }, | 117 {&GUID_Key, 37, 0x8000250C, 0x00000000}, |
115 { &GUID_Key, 38, 0x8000260C, 0x00000000 }, | 118 {&GUID_Key, 38, 0x8000260C, 0x00000000}, |
116 { &GUID_Key, 39, 0x8000270C, 0x00000000 }, | 119 {&GUID_Key, 39, 0x8000270C, 0x00000000}, |
117 { &GUID_Key, 40, 0x8000280C, 0x00000000 }, | 120 {&GUID_Key, 40, 0x8000280C, 0x00000000}, |
118 { &GUID_Key, 41, 0x8000290C, 0x00000000 }, | 121 {&GUID_Key, 41, 0x8000290C, 0x00000000}, |
119 { &GUID_Key, 42, 0x80002A0C, 0x00000000 }, | 122 {&GUID_Key, 42, 0x80002A0C, 0x00000000}, |
120 { &GUID_Key, 43, 0x80002B0C, 0x00000000 }, | 123 {&GUID_Key, 43, 0x80002B0C, 0x00000000}, |
121 { &GUID_Key, 44, 0x80002C0C, 0x00000000 }, | 124 {&GUID_Key, 44, 0x80002C0C, 0x00000000}, |
122 { &GUID_Key, 45, 0x80002D0C, 0x00000000 }, | 125 {&GUID_Key, 45, 0x80002D0C, 0x00000000}, |
123 { &GUID_Key, 46, 0x80002E0C, 0x00000000 }, | 126 {&GUID_Key, 46, 0x80002E0C, 0x00000000}, |
124 { &GUID_Key, 47, 0x80002F0C, 0x00000000 }, | 127 {&GUID_Key, 47, 0x80002F0C, 0x00000000}, |
125 { &GUID_Key, 48, 0x8000300C, 0x00000000 }, | 128 {&GUID_Key, 48, 0x8000300C, 0x00000000}, |
126 { &GUID_Key, 49, 0x8000310C, 0x00000000 }, | 129 {&GUID_Key, 49, 0x8000310C, 0x00000000}, |
127 { &GUID_Key, 50, 0x8000320C, 0x00000000 }, | 130 {&GUID_Key, 50, 0x8000320C, 0x00000000}, |
128 { &GUID_Key, 51, 0x8000330C, 0x00000000 }, | 131 {&GUID_Key, 51, 0x8000330C, 0x00000000}, |
129 { &GUID_Key, 52, 0x8000340C, 0x00000000 }, | 132 {&GUID_Key, 52, 0x8000340C, 0x00000000}, |
130 { &GUID_Key, 53, 0x8000350C, 0x00000000 }, | 133 {&GUID_Key, 53, 0x8000350C, 0x00000000}, |
131 { &GUID_Key, 54, 0x8000360C, 0x00000000 }, | 134 {&GUID_Key, 54, 0x8000360C, 0x00000000}, |
132 { &GUID_Key, 55, 0x8000370C, 0x00000000 }, | 135 {&GUID_Key, 55, 0x8000370C, 0x00000000}, |
133 { &GUID_Key, 56, 0x8000380C, 0x00000000 }, | 136 {&GUID_Key, 56, 0x8000380C, 0x00000000}, |
134 { &GUID_Key, 57, 0x8000390C, 0x00000000 }, | 137 {&GUID_Key, 57, 0x8000390C, 0x00000000}, |
135 { &GUID_Key, 58, 0x80003A0C, 0x00000000 }, | 138 {&GUID_Key, 58, 0x80003A0C, 0x00000000}, |
136 { &GUID_Key, 59, 0x80003B0C, 0x00000000 }, | 139 {&GUID_Key, 59, 0x80003B0C, 0x00000000}, |
137 { &GUID_Key, 60, 0x80003C0C, 0x00000000 }, | 140 {&GUID_Key, 60, 0x80003C0C, 0x00000000}, |
138 { &GUID_Key, 61, 0x80003D0C, 0x00000000 }, | 141 {&GUID_Key, 61, 0x80003D0C, 0x00000000}, |
139 { &GUID_Key, 62, 0x80003E0C, 0x00000000 }, | 142 {&GUID_Key, 62, 0x80003E0C, 0x00000000}, |
140 { &GUID_Key, 63, 0x80003F0C, 0x00000000 }, | 143 {&GUID_Key, 63, 0x80003F0C, 0x00000000}, |
141 { &GUID_Key, 64, 0x8000400C, 0x00000000 }, | 144 {&GUID_Key, 64, 0x8000400C, 0x00000000}, |
142 { &GUID_Key, 65, 0x8000410C, 0x00000000 }, | 145 {&GUID_Key, 65, 0x8000410C, 0x00000000}, |
143 { &GUID_Key, 66, 0x8000420C, 0x00000000 }, | 146 {&GUID_Key, 66, 0x8000420C, 0x00000000}, |
144 { &GUID_Key, 67, 0x8000430C, 0x00000000 }, | 147 {&GUID_Key, 67, 0x8000430C, 0x00000000}, |
145 { &GUID_Key, 68, 0x8000440C, 0x00000000 }, | 148 {&GUID_Key, 68, 0x8000440C, 0x00000000}, |
146 { &GUID_Key, 69, 0x8000450C, 0x00000000 }, | 149 {&GUID_Key, 69, 0x8000450C, 0x00000000}, |
147 { &GUID_Key, 70, 0x8000460C, 0x00000000 }, | 150 {&GUID_Key, 70, 0x8000460C, 0x00000000}, |
148 { &GUID_Key, 71, 0x8000470C, 0x00000000 }, | 151 {&GUID_Key, 71, 0x8000470C, 0x00000000}, |
149 { &GUID_Key, 72, 0x8000480C, 0x00000000 }, | 152 {&GUID_Key, 72, 0x8000480C, 0x00000000}, |
150 { &GUID_Key, 73, 0x8000490C, 0x00000000 }, | 153 {&GUID_Key, 73, 0x8000490C, 0x00000000}, |
151 { &GUID_Key, 74, 0x80004A0C, 0x00000000 }, | 154 {&GUID_Key, 74, 0x80004A0C, 0x00000000}, |
152 { &GUID_Key, 75, 0x80004B0C, 0x00000000 }, | 155 {&GUID_Key, 75, 0x80004B0C, 0x00000000}, |
153 { &GUID_Key, 76, 0x80004C0C, 0x00000000 }, | 156 {&GUID_Key, 76, 0x80004C0C, 0x00000000}, |
154 { &GUID_Key, 77, 0x80004D0C, 0x00000000 }, | 157 {&GUID_Key, 77, 0x80004D0C, 0x00000000}, |
155 { &GUID_Key, 78, 0x80004E0C, 0x00000000 }, | 158 {&GUID_Key, 78, 0x80004E0C, 0x00000000}, |
156 { &GUID_Key, 79, 0x80004F0C, 0x00000000 }, | 159 {&GUID_Key, 79, 0x80004F0C, 0x00000000}, |
157 { &GUID_Key, 80, 0x8000500C, 0x00000000 }, | 160 {&GUID_Key, 80, 0x8000500C, 0x00000000}, |
158 { &GUID_Key, 81, 0x8000510C, 0x00000000 }, | 161 {&GUID_Key, 81, 0x8000510C, 0x00000000}, |
159 { &GUID_Key, 82, 0x8000520C, 0x00000000 }, | 162 {&GUID_Key, 82, 0x8000520C, 0x00000000}, |
160 { &GUID_Key, 83, 0x8000530C, 0x00000000 }, | 163 {&GUID_Key, 83, 0x8000530C, 0x00000000}, |
161 { &GUID_Key, 84, 0x8000540C, 0x00000000 }, | 164 {&GUID_Key, 84, 0x8000540C, 0x00000000}, |
162 { &GUID_Key, 85, 0x8000550C, 0x00000000 }, | 165 {&GUID_Key, 85, 0x8000550C, 0x00000000}, |
163 { &GUID_Key, 86, 0x8000560C, 0x00000000 }, | 166 {&GUID_Key, 86, 0x8000560C, 0x00000000}, |
164 { &GUID_Key, 87, 0x8000570C, 0x00000000 }, | 167 {&GUID_Key, 87, 0x8000570C, 0x00000000}, |
165 { &GUID_Key, 88, 0x8000580C, 0x00000000 }, | 168 {&GUID_Key, 88, 0x8000580C, 0x00000000}, |
166 { &GUID_Key, 89, 0x8000590C, 0x00000000 }, | 169 {&GUID_Key, 89, 0x8000590C, 0x00000000}, |
167 { &GUID_Key, 90, 0x80005A0C, 0x00000000 }, | 170 {&GUID_Key, 90, 0x80005A0C, 0x00000000}, |
168 { &GUID_Key, 91, 0x80005B0C, 0x00000000 }, | 171 {&GUID_Key, 91, 0x80005B0C, 0x00000000}, |
169 { &GUID_Key, 92, 0x80005C0C, 0x00000000 }, | 172 {&GUID_Key, 92, 0x80005C0C, 0x00000000}, |
170 { &GUID_Key, 93, 0x80005D0C, 0x00000000 }, | 173 {&GUID_Key, 93, 0x80005D0C, 0x00000000}, |
171 { &GUID_Key, 94, 0x80005E0C, 0x00000000 }, | 174 {&GUID_Key, 94, 0x80005E0C, 0x00000000}, |
172 { &GUID_Key, 95, 0x80005F0C, 0x00000000 }, | 175 {&GUID_Key, 95, 0x80005F0C, 0x00000000}, |
173 { &GUID_Key, 96, 0x8000600C, 0x00000000 }, | 176 {&GUID_Key, 96, 0x8000600C, 0x00000000}, |
174 { &GUID_Key, 97, 0x8000610C, 0x00000000 }, | 177 {&GUID_Key, 97, 0x8000610C, 0x00000000}, |
175 { &GUID_Key, 98, 0x8000620C, 0x00000000 }, | 178 {&GUID_Key, 98, 0x8000620C, 0x00000000}, |
176 { &GUID_Key, 99, 0x8000630C, 0x00000000 }, | 179 {&GUID_Key, 99, 0x8000630C, 0x00000000}, |
177 { &GUID_Key, 100, 0x8000640C, 0x00000000 }, | 180 {&GUID_Key, 100, 0x8000640C, 0x00000000}, |
178 { &GUID_Key, 101, 0x8000650C, 0x00000000 }, | 181 {&GUID_Key, 101, 0x8000650C, 0x00000000}, |
179 { &GUID_Key, 102, 0x8000660C, 0x00000000 }, | 182 {&GUID_Key, 102, 0x8000660C, 0x00000000}, |
180 { &GUID_Key, 103, 0x8000670C, 0x00000000 }, | 183 {&GUID_Key, 103, 0x8000670C, 0x00000000}, |
181 { &GUID_Key, 104, 0x8000680C, 0x00000000 }, | 184 {&GUID_Key, 104, 0x8000680C, 0x00000000}, |
182 { &GUID_Key, 105, 0x8000690C, 0x00000000 }, | 185 {&GUID_Key, 105, 0x8000690C, 0x00000000}, |
183 { &GUID_Key, 106, 0x80006A0C, 0x00000000 }, | 186 {&GUID_Key, 106, 0x80006A0C, 0x00000000}, |
184 { &GUID_Key, 107, 0x80006B0C, 0x00000000 }, | 187 {&GUID_Key, 107, 0x80006B0C, 0x00000000}, |
185 { &GUID_Key, 108, 0x80006C0C, 0x00000000 }, | 188 {&GUID_Key, 108, 0x80006C0C, 0x00000000}, |
186 { &GUID_Key, 109, 0x80006D0C, 0x00000000 }, | 189 {&GUID_Key, 109, 0x80006D0C, 0x00000000}, |
187 { &GUID_Key, 110, 0x80006E0C, 0x00000000 }, | 190 {&GUID_Key, 110, 0x80006E0C, 0x00000000}, |
188 { &GUID_Key, 111, 0x80006F0C, 0x00000000 }, | 191 {&GUID_Key, 111, 0x80006F0C, 0x00000000}, |
189 { &GUID_Key, 112, 0x8000700C, 0x00000000 }, | 192 {&GUID_Key, 112, 0x8000700C, 0x00000000}, |
190 { &GUID_Key, 113, 0x8000710C, 0x00000000 }, | 193 {&GUID_Key, 113, 0x8000710C, 0x00000000}, |
191 { &GUID_Key, 114, 0x8000720C, 0x00000000 }, | 194 {&GUID_Key, 114, 0x8000720C, 0x00000000}, |
192 { &GUID_Key, 115, 0x8000730C, 0x00000000 }, | 195 {&GUID_Key, 115, 0x8000730C, 0x00000000}, |
193 { &GUID_Key, 116, 0x8000740C, 0x00000000 }, | 196 {&GUID_Key, 116, 0x8000740C, 0x00000000}, |
194 { &GUID_Key, 117, 0x8000750C, 0x00000000 }, | 197 {&GUID_Key, 117, 0x8000750C, 0x00000000}, |
195 { &GUID_Key, 118, 0x8000760C, 0x00000000 }, | 198 {&GUID_Key, 118, 0x8000760C, 0x00000000}, |
196 { &GUID_Key, 119, 0x8000770C, 0x00000000 }, | 199 {&GUID_Key, 119, 0x8000770C, 0x00000000}, |
197 { &GUID_Key, 120, 0x8000780C, 0x00000000 }, | 200 {&GUID_Key, 120, 0x8000780C, 0x00000000}, |
198 { &GUID_Key, 121, 0x8000790C, 0x00000000 }, | 201 {&GUID_Key, 121, 0x8000790C, 0x00000000}, |
199 { &GUID_Key, 122, 0x80007A0C, 0x00000000 }, | 202 {&GUID_Key, 122, 0x80007A0C, 0x00000000}, |
200 { &GUID_Key, 123, 0x80007B0C, 0x00000000 }, | 203 {&GUID_Key, 123, 0x80007B0C, 0x00000000}, |
201 { &GUID_Key, 124, 0x80007C0C, 0x00000000 }, | 204 {&GUID_Key, 124, 0x80007C0C, 0x00000000}, |
202 { &GUID_Key, 125, 0x80007D0C, 0x00000000 }, | 205 {&GUID_Key, 125, 0x80007D0C, 0x00000000}, |
203 { &GUID_Key, 126, 0x80007E0C, 0x00000000 }, | 206 {&GUID_Key, 126, 0x80007E0C, 0x00000000}, |
204 { &GUID_Key, 127, 0x80007F0C, 0x00000000 }, | 207 {&GUID_Key, 127, 0x80007F0C, 0x00000000}, |
205 { &GUID_Key, 128, 0x8000800C, 0x00000000 }, | 208 {&GUID_Key, 128, 0x8000800C, 0x00000000}, |
206 { &GUID_Key, 129, 0x8000810C, 0x00000000 }, | 209 {&GUID_Key, 129, 0x8000810C, 0x00000000}, |
207 { &GUID_Key, 130, 0x8000820C, 0x00000000 }, | 210 {&GUID_Key, 130, 0x8000820C, 0x00000000}, |
208 { &GUID_Key, 131, 0x8000830C, 0x00000000 }, | 211 {&GUID_Key, 131, 0x8000830C, 0x00000000}, |
209 { &GUID_Key, 132, 0x8000840C, 0x00000000 }, | 212 {&GUID_Key, 132, 0x8000840C, 0x00000000}, |
210 { &GUID_Key, 133, 0x8000850C, 0x00000000 }, | 213 {&GUID_Key, 133, 0x8000850C, 0x00000000}, |
211 { &GUID_Key, 134, 0x8000860C, 0x00000000 }, | 214 {&GUID_Key, 134, 0x8000860C, 0x00000000}, |
212 { &GUID_Key, 135, 0x8000870C, 0x00000000 }, | 215 {&GUID_Key, 135, 0x8000870C, 0x00000000}, |
213 { &GUID_Key, 136, 0x8000880C, 0x00000000 }, | 216 {&GUID_Key, 136, 0x8000880C, 0x00000000}, |
214 { &GUID_Key, 137, 0x8000890C, 0x00000000 }, | 217 {&GUID_Key, 137, 0x8000890C, 0x00000000}, |
215 { &GUID_Key, 138, 0x80008A0C, 0x00000000 }, | 218 {&GUID_Key, 138, 0x80008A0C, 0x00000000}, |
216 { &GUID_Key, 139, 0x80008B0C, 0x00000000 }, | 219 {&GUID_Key, 139, 0x80008B0C, 0x00000000}, |
217 { &GUID_Key, 140, 0x80008C0C, 0x00000000 }, | 220 {&GUID_Key, 140, 0x80008C0C, 0x00000000}, |
218 { &GUID_Key, 141, 0x80008D0C, 0x00000000 }, | 221 {&GUID_Key, 141, 0x80008D0C, 0x00000000}, |
219 { &GUID_Key, 142, 0x80008E0C, 0x00000000 }, | 222 {&GUID_Key, 142, 0x80008E0C, 0x00000000}, |
220 { &GUID_Key, 143, 0x80008F0C, 0x00000000 }, | 223 {&GUID_Key, 143, 0x80008F0C, 0x00000000}, |
221 { &GUID_Key, 144, 0x8000900C, 0x00000000 }, | 224 {&GUID_Key, 144, 0x8000900C, 0x00000000}, |
222 { &GUID_Key, 145, 0x8000910C, 0x00000000 }, | 225 {&GUID_Key, 145, 0x8000910C, 0x00000000}, |
223 { &GUID_Key, 146, 0x8000920C, 0x00000000 }, | 226 {&GUID_Key, 146, 0x8000920C, 0x00000000}, |
224 { &GUID_Key, 147, 0x8000930C, 0x00000000 }, | 227 {&GUID_Key, 147, 0x8000930C, 0x00000000}, |
225 { &GUID_Key, 148, 0x8000940C, 0x00000000 }, | 228 {&GUID_Key, 148, 0x8000940C, 0x00000000}, |
226 { &GUID_Key, 149, 0x8000950C, 0x00000000 }, | 229 {&GUID_Key, 149, 0x8000950C, 0x00000000}, |
227 { &GUID_Key, 150, 0x8000960C, 0x00000000 }, | 230 {&GUID_Key, 150, 0x8000960C, 0x00000000}, |
228 { &GUID_Key, 151, 0x8000970C, 0x00000000 }, | 231 {&GUID_Key, 151, 0x8000970C, 0x00000000}, |
229 { &GUID_Key, 152, 0x8000980C, 0x00000000 }, | 232 {&GUID_Key, 152, 0x8000980C, 0x00000000}, |
230 { &GUID_Key, 153, 0x8000990C, 0x00000000 }, | 233 {&GUID_Key, 153, 0x8000990C, 0x00000000}, |
231 { &GUID_Key, 154, 0x80009A0C, 0x00000000 }, | 234 {&GUID_Key, 154, 0x80009A0C, 0x00000000}, |
232 { &GUID_Key, 155, 0x80009B0C, 0x00000000 }, | 235 {&GUID_Key, 155, 0x80009B0C, 0x00000000}, |
233 { &GUID_Key, 156, 0x80009C0C, 0x00000000 }, | 236 {&GUID_Key, 156, 0x80009C0C, 0x00000000}, |
234 { &GUID_Key, 157, 0x80009D0C, 0x00000000 }, | 237 {&GUID_Key, 157, 0x80009D0C, 0x00000000}, |
235 { &GUID_Key, 158, 0x80009E0C, 0x00000000 }, | 238 {&GUID_Key, 158, 0x80009E0C, 0x00000000}, |
236 { &GUID_Key, 159, 0x80009F0C, 0x00000000 }, | 239 {&GUID_Key, 159, 0x80009F0C, 0x00000000}, |
237 { &GUID_Key, 160, 0x8000A00C, 0x00000000 }, | 240 {&GUID_Key, 160, 0x8000A00C, 0x00000000}, |
238 { &GUID_Key, 161, 0x8000A10C, 0x00000000 }, | 241 {&GUID_Key, 161, 0x8000A10C, 0x00000000}, |
239 { &GUID_Key, 162, 0x8000A20C, 0x00000000 }, | 242 {&GUID_Key, 162, 0x8000A20C, 0x00000000}, |
240 { &GUID_Key, 163, 0x8000A30C, 0x00000000 }, | 243 {&GUID_Key, 163, 0x8000A30C, 0x00000000}, |
241 { &GUID_Key, 164, 0x8000A40C, 0x00000000 }, | 244 {&GUID_Key, 164, 0x8000A40C, 0x00000000}, |
242 { &GUID_Key, 165, 0x8000A50C, 0x00000000 }, | 245 {&GUID_Key, 165, 0x8000A50C, 0x00000000}, |
243 { &GUID_Key, 166, 0x8000A60C, 0x00000000 }, | 246 {&GUID_Key, 166, 0x8000A60C, 0x00000000}, |
244 { &GUID_Key, 167, 0x8000A70C, 0x00000000 }, | 247 {&GUID_Key, 167, 0x8000A70C, 0x00000000}, |
245 { &GUID_Key, 168, 0x8000A80C, 0x00000000 }, | 248 {&GUID_Key, 168, 0x8000A80C, 0x00000000}, |
246 { &GUID_Key, 169, 0x8000A90C, 0x00000000 }, | 249 {&GUID_Key, 169, 0x8000A90C, 0x00000000}, |
247 { &GUID_Key, 170, 0x8000AA0C, 0x00000000 }, | 250 {&GUID_Key, 170, 0x8000AA0C, 0x00000000}, |
248 { &GUID_Key, 171, 0x8000AB0C, 0x00000000 }, | 251 {&GUID_Key, 171, 0x8000AB0C, 0x00000000}, |
249 { &GUID_Key, 172, 0x8000AC0C, 0x00000000 }, | 252 {&GUID_Key, 172, 0x8000AC0C, 0x00000000}, |
250 { &GUID_Key, 173, 0x8000AD0C, 0x00000000 }, | 253 {&GUID_Key, 173, 0x8000AD0C, 0x00000000}, |
251 { &GUID_Key, 174, 0x8000AE0C, 0x00000000 }, | 254 {&GUID_Key, 174, 0x8000AE0C, 0x00000000}, |
252 { &GUID_Key, 175, 0x8000AF0C, 0x00000000 }, | 255 {&GUID_Key, 175, 0x8000AF0C, 0x00000000}, |
253 { &GUID_Key, 176, 0x8000B00C, 0x00000000 }, | 256 {&GUID_Key, 176, 0x8000B00C, 0x00000000}, |
254 { &GUID_Key, 177, 0x8000B10C, 0x00000000 }, | 257 {&GUID_Key, 177, 0x8000B10C, 0x00000000}, |
255 { &GUID_Key, 178, 0x8000B20C, 0x00000000 }, | 258 {&GUID_Key, 178, 0x8000B20C, 0x00000000}, |
256 { &GUID_Key, 179, 0x8000B30C, 0x00000000 }, | 259 {&GUID_Key, 179, 0x8000B30C, 0x00000000}, |
257 { &GUID_Key, 180, 0x8000B40C, 0x00000000 }, | 260 {&GUID_Key, 180, 0x8000B40C, 0x00000000}, |
258 { &GUID_Key, 181, 0x8000B50C, 0x00000000 }, | 261 {&GUID_Key, 181, 0x8000B50C, 0x00000000}, |
259 { &GUID_Key, 182, 0x8000B60C, 0x00000000 }, | 262 {&GUID_Key, 182, 0x8000B60C, 0x00000000}, |
260 { &GUID_Key, 183, 0x8000B70C, 0x00000000 }, | 263 {&GUID_Key, 183, 0x8000B70C, 0x00000000}, |
261 { &GUID_Key, 184, 0x8000B80C, 0x00000000 }, | 264 {&GUID_Key, 184, 0x8000B80C, 0x00000000}, |
262 { &GUID_Key, 185, 0x8000B90C, 0x00000000 }, | 265 {&GUID_Key, 185, 0x8000B90C, 0x00000000}, |
263 { &GUID_Key, 186, 0x8000BA0C, 0x00000000 }, | 266 {&GUID_Key, 186, 0x8000BA0C, 0x00000000}, |
264 { &GUID_Key, 187, 0x8000BB0C, 0x00000000 }, | 267 {&GUID_Key, 187, 0x8000BB0C, 0x00000000}, |
265 { &GUID_Key, 188, 0x8000BC0C, 0x00000000 }, | 268 {&GUID_Key, 188, 0x8000BC0C, 0x00000000}, |
266 { &GUID_Key, 189, 0x8000BD0C, 0x00000000 }, | 269 {&GUID_Key, 189, 0x8000BD0C, 0x00000000}, |
267 { &GUID_Key, 190, 0x8000BE0C, 0x00000000 }, | 270 {&GUID_Key, 190, 0x8000BE0C, 0x00000000}, |
268 { &GUID_Key, 191, 0x8000BF0C, 0x00000000 }, | 271 {&GUID_Key, 191, 0x8000BF0C, 0x00000000}, |
269 { &GUID_Key, 192, 0x8000C00C, 0x00000000 }, | 272 {&GUID_Key, 192, 0x8000C00C, 0x00000000}, |
270 { &GUID_Key, 193, 0x8000C10C, 0x00000000 }, | 273 {&GUID_Key, 193, 0x8000C10C, 0x00000000}, |
271 { &GUID_Key, 194, 0x8000C20C, 0x00000000 }, | 274 {&GUID_Key, 194, 0x8000C20C, 0x00000000}, |
272 { &GUID_Key, 195, 0x8000C30C, 0x00000000 }, | 275 {&GUID_Key, 195, 0x8000C30C, 0x00000000}, |
273 { &GUID_Key, 196, 0x8000C40C, 0x00000000 }, | 276 {&GUID_Key, 196, 0x8000C40C, 0x00000000}, |
274 { &GUID_Key, 197, 0x8000C50C, 0x00000000 }, | 277 {&GUID_Key, 197, 0x8000C50C, 0x00000000}, |
275 { &GUID_Key, 198, 0x8000C60C, 0x00000000 }, | 278 {&GUID_Key, 198, 0x8000C60C, 0x00000000}, |
276 { &GUID_Key, 199, 0x8000C70C, 0x00000000 }, | 279 {&GUID_Key, 199, 0x8000C70C, 0x00000000}, |
277 { &GUID_Key, 200, 0x8000C80C, 0x00000000 }, | 280 {&GUID_Key, 200, 0x8000C80C, 0x00000000}, |
278 { &GUID_Key, 201, 0x8000C90C, 0x00000000 }, | 281 {&GUID_Key, 201, 0x8000C90C, 0x00000000}, |
279 { &GUID_Key, 202, 0x8000CA0C, 0x00000000 }, | 282 {&GUID_Key, 202, 0x8000CA0C, 0x00000000}, |
280 { &GUID_Key, 203, 0x8000CB0C, 0x00000000 }, | 283 {&GUID_Key, 203, 0x8000CB0C, 0x00000000}, |
281 { &GUID_Key, 204, 0x8000CC0C, 0x00000000 }, | 284 {&GUID_Key, 204, 0x8000CC0C, 0x00000000}, |
282 { &GUID_Key, 205, 0x8000CD0C, 0x00000000 }, | 285 {&GUID_Key, 205, 0x8000CD0C, 0x00000000}, |
283 { &GUID_Key, 206, 0x8000CE0C, 0x00000000 }, | 286 {&GUID_Key, 206, 0x8000CE0C, 0x00000000}, |
284 { &GUID_Key, 207, 0x8000CF0C, 0x00000000 }, | 287 {&GUID_Key, 207, 0x8000CF0C, 0x00000000}, |
285 { &GUID_Key, 208, 0x8000D00C, 0x00000000 }, | 288 {&GUID_Key, 208, 0x8000D00C, 0x00000000}, |
286 { &GUID_Key, 209, 0x8000D10C, 0x00000000 }, | 289 {&GUID_Key, 209, 0x8000D10C, 0x00000000}, |
287 { &GUID_Key, 210, 0x8000D20C, 0x00000000 }, | 290 {&GUID_Key, 210, 0x8000D20C, 0x00000000}, |
288 { &GUID_Key, 211, 0x8000D30C, 0x00000000 }, | 291 {&GUID_Key, 211, 0x8000D30C, 0x00000000}, |
289 { &GUID_Key, 212, 0x8000D40C, 0x00000000 }, | 292 {&GUID_Key, 212, 0x8000D40C, 0x00000000}, |
290 { &GUID_Key, 213, 0x8000D50C, 0x00000000 }, | 293 {&GUID_Key, 213, 0x8000D50C, 0x00000000}, |
291 { &GUID_Key, 214, 0x8000D60C, 0x00000000 }, | 294 {&GUID_Key, 214, 0x8000D60C, 0x00000000}, |
292 { &GUID_Key, 215, 0x8000D70C, 0x00000000 }, | 295 {&GUID_Key, 215, 0x8000D70C, 0x00000000}, |
293 { &GUID_Key, 216, 0x8000D80C, 0x00000000 }, | 296 {&GUID_Key, 216, 0x8000D80C, 0x00000000}, |
294 { &GUID_Key, 217, 0x8000D90C, 0x00000000 }, | 297 {&GUID_Key, 217, 0x8000D90C, 0x00000000}, |
295 { &GUID_Key, 218, 0x8000DA0C, 0x00000000 }, | 298 {&GUID_Key, 218, 0x8000DA0C, 0x00000000}, |
296 { &GUID_Key, 219, 0x8000DB0C, 0x00000000 }, | 299 {&GUID_Key, 219, 0x8000DB0C, 0x00000000}, |
297 { &GUID_Key, 220, 0x8000DC0C, 0x00000000 }, | 300 {&GUID_Key, 220, 0x8000DC0C, 0x00000000}, |
298 { &GUID_Key, 221, 0x8000DD0C, 0x00000000 }, | 301 {&GUID_Key, 221, 0x8000DD0C, 0x00000000}, |
299 { &GUID_Key, 222, 0x8000DE0C, 0x00000000 }, | 302 {&GUID_Key, 222, 0x8000DE0C, 0x00000000}, |
300 { &GUID_Key, 223, 0x8000DF0C, 0x00000000 }, | 303 {&GUID_Key, 223, 0x8000DF0C, 0x00000000}, |
301 { &GUID_Key, 224, 0x8000E00C, 0x00000000 }, | 304 {&GUID_Key, 224, 0x8000E00C, 0x00000000}, |
302 { &GUID_Key, 225, 0x8000E10C, 0x00000000 }, | 305 {&GUID_Key, 225, 0x8000E10C, 0x00000000}, |
303 { &GUID_Key, 226, 0x8000E20C, 0x00000000 }, | 306 {&GUID_Key, 226, 0x8000E20C, 0x00000000}, |
304 { &GUID_Key, 227, 0x8000E30C, 0x00000000 }, | 307 {&GUID_Key, 227, 0x8000E30C, 0x00000000}, |
305 { &GUID_Key, 228, 0x8000E40C, 0x00000000 }, | 308 {&GUID_Key, 228, 0x8000E40C, 0x00000000}, |
306 { &GUID_Key, 229, 0x8000E50C, 0x00000000 }, | 309 {&GUID_Key, 229, 0x8000E50C, 0x00000000}, |
307 { &GUID_Key, 230, 0x8000E60C, 0x00000000 }, | 310 {&GUID_Key, 230, 0x8000E60C, 0x00000000}, |
308 { &GUID_Key, 231, 0x8000E70C, 0x00000000 }, | 311 {&GUID_Key, 231, 0x8000E70C, 0x00000000}, |
309 { &GUID_Key, 232, 0x8000E80C, 0x00000000 }, | 312 {&GUID_Key, 232, 0x8000E80C, 0x00000000}, |
310 { &GUID_Key, 233, 0x8000E90C, 0x00000000 }, | 313 {&GUID_Key, 233, 0x8000E90C, 0x00000000}, |
311 { &GUID_Key, 234, 0x8000EA0C, 0x00000000 }, | 314 {&GUID_Key, 234, 0x8000EA0C, 0x00000000}, |
312 { &GUID_Key, 235, 0x8000EB0C, 0x00000000 }, | 315 {&GUID_Key, 235, 0x8000EB0C, 0x00000000}, |
313 { &GUID_Key, 236, 0x8000EC0C, 0x00000000 }, | 316 {&GUID_Key, 236, 0x8000EC0C, 0x00000000}, |
314 { &GUID_Key, 237, 0x8000ED0C, 0x00000000 }, | 317 {&GUID_Key, 237, 0x8000ED0C, 0x00000000}, |
315 { &GUID_Key, 238, 0x8000EE0C, 0x00000000 }, | 318 {&GUID_Key, 238, 0x8000EE0C, 0x00000000}, |
316 { &GUID_Key, 239, 0x8000EF0C, 0x00000000 }, | 319 {&GUID_Key, 239, 0x8000EF0C, 0x00000000}, |
317 { &GUID_Key, 240, 0x8000F00C, 0x00000000 }, | 320 {&GUID_Key, 240, 0x8000F00C, 0x00000000}, |
318 { &GUID_Key, 241, 0x8000F10C, 0x00000000 }, | 321 {&GUID_Key, 241, 0x8000F10C, 0x00000000}, |
319 { &GUID_Key, 242, 0x8000F20C, 0x00000000 }, | 322 {&GUID_Key, 242, 0x8000F20C, 0x00000000}, |
320 { &GUID_Key, 243, 0x8000F30C, 0x00000000 }, | 323 {&GUID_Key, 243, 0x8000F30C, 0x00000000}, |
321 { &GUID_Key, 244, 0x8000F40C, 0x00000000 }, | 324 {&GUID_Key, 244, 0x8000F40C, 0x00000000}, |
322 { &GUID_Key, 245, 0x8000F50C, 0x00000000 }, | 325 {&GUID_Key, 245, 0x8000F50C, 0x00000000}, |
323 { &GUID_Key, 246, 0x8000F60C, 0x00000000 }, | 326 {&GUID_Key, 246, 0x8000F60C, 0x00000000}, |
324 { &GUID_Key, 247, 0x8000F70C, 0x00000000 }, | 327 {&GUID_Key, 247, 0x8000F70C, 0x00000000}, |
325 { &GUID_Key, 248, 0x8000F80C, 0x00000000 }, | 328 {&GUID_Key, 248, 0x8000F80C, 0x00000000}, |
326 { &GUID_Key, 249, 0x8000F90C, 0x00000000 }, | 329 {&GUID_Key, 249, 0x8000F90C, 0x00000000}, |
327 { &GUID_Key, 250, 0x8000FA0C, 0x00000000 }, | 330 {&GUID_Key, 250, 0x8000FA0C, 0x00000000}, |
328 { &GUID_Key, 251, 0x8000FB0C, 0x00000000 }, | 331 {&GUID_Key, 251, 0x8000FB0C, 0x00000000}, |
329 { &GUID_Key, 252, 0x8000FC0C, 0x00000000 }, | 332 {&GUID_Key, 252, 0x8000FC0C, 0x00000000}, |
330 { &GUID_Key, 253, 0x8000FD0C, 0x00000000 }, | 333 {&GUID_Key, 253, 0x8000FD0C, 0x00000000}, |
331 { &GUID_Key, 254, 0x8000FE0C, 0x00000000 }, | 334 {&GUID_Key, 254, 0x8000FE0C, 0x00000000}, |
332 { &GUID_Key, 255, 0x8000FF0C, 0x00000000 }, | 335 {&GUID_Key, 255, 0x8000FF0C, 0x00000000}, |
333 }; | 336 }; |
334 | 337 |
335 const DIDATAFORMAT c_dfDIKeyboard = { 24, 16, 0x00000002, 256, 256, KBD_fmt }; | 338 const DIDATAFORMAT c_dfDIKeyboard = { 24, 16, 0x00000002, 256, 256, KBD_fmt }; |
336 | 339 |
337 | 340 |
338 /* Mouse */ | 341 /* Mouse */ |
339 | 342 |
340 static DIOBJECTDATAFORMAT PTR_fmt[] = { | 343 static DIOBJECTDATAFORMAT PTR_fmt[] = { |
341 { &GUID_XAxis, 0, 0x00FFFF03, 0x00000000 }, | 344 {&GUID_XAxis, 0, 0x00FFFF03, 0x00000000}, |
342 { &GUID_YAxis, 4, 0x00FFFF03, 0x00000000 }, | 345 {&GUID_YAxis, 4, 0x00FFFF03, 0x00000000}, |
343 { &GUID_ZAxis, 8, 0x80FFFF03, 0x00000000 }, | 346 {&GUID_ZAxis, 8, 0x80FFFF03, 0x00000000}, |
344 { NULL, 12, 0x00FFFF0C, 0x00000000 }, | 347 {NULL, 12, 0x00FFFF0C, 0x00000000}, |
345 { NULL, 13, 0x00FFFF0C, 0x00000000 }, | 348 {NULL, 13, 0x00FFFF0C, 0x00000000}, |
346 { NULL, 14, 0x80FFFF0C, 0x00000000 }, | 349 {NULL, 14, 0x80FFFF0C, 0x00000000}, |
347 { NULL, 15, 0x80FFFF0C, 0x00000000 }, | 350 {NULL, 15, 0x80FFFF0C, 0x00000000}, |
348 }; | 351 }; |
349 | 352 |
350 const DIDATAFORMAT c_dfDIMouse = { 24, 16, 0x00000002, 16, 7, PTR_fmt }; | 353 const DIDATAFORMAT c_dfDIMouse = { 24, 16, 0x00000002, 16, 7, PTR_fmt }; |
351 | 354 |
352 | 355 |
353 /* Joystick */ | 356 /* Joystick */ |
354 | 357 |
355 static DIOBJECTDATAFORMAT JOY_fmt[] = { | 358 static DIOBJECTDATAFORMAT JOY_fmt[] = { |
356 { &GUID_XAxis, 0, 0x80FFFF03, 0x00000100 }, | 359 {&GUID_XAxis, 0, 0x80FFFF03, 0x00000100}, |
357 { &GUID_YAxis, 4, 0x80FFFF03, 0x00000100 }, | 360 {&GUID_YAxis, 4, 0x80FFFF03, 0x00000100}, |
358 { &GUID_ZAxis, 8, 0x80FFFF03, 0x00000100 }, | 361 {&GUID_ZAxis, 8, 0x80FFFF03, 0x00000100}, |
359 { &GUID_RxAxis, 12, 0x80FFFF03, 0x00000100 }, | 362 {&GUID_RxAxis, 12, 0x80FFFF03, 0x00000100}, |
360 { &GUID_RyAxis, 16, 0x80FFFF03, 0x00000100 }, | 363 {&GUID_RyAxis, 16, 0x80FFFF03, 0x00000100}, |
361 { &GUID_RzAxis, 20, 0x80FFFF03, 0x00000100 }, | 364 {&GUID_RzAxis, 20, 0x80FFFF03, 0x00000100}, |
362 { &GUID_Slider, 24, 0x80FFFF03, 0x00000100 }, | 365 {&GUID_Slider, 24, 0x80FFFF03, 0x00000100}, |
363 { &GUID_Slider, 28, 0x80FFFF03, 0x00000100 }, | 366 {&GUID_Slider, 28, 0x80FFFF03, 0x00000100}, |
364 { &GUID_POV, 32, 0x80FFFF10, 0x00000000 }, | 367 {&GUID_POV, 32, 0x80FFFF10, 0x00000000}, |
365 { &GUID_POV, 36, 0x80FFFF10, 0x00000000 }, | 368 {&GUID_POV, 36, 0x80FFFF10, 0x00000000}, |
366 { &GUID_POV, 40, 0x80FFFF10, 0x00000000 }, | 369 {&GUID_POV, 40, 0x80FFFF10, 0x00000000}, |
367 { &GUID_POV, 44, 0x80FFFF10, 0x00000000 }, | 370 {&GUID_POV, 44, 0x80FFFF10, 0x00000000}, |
368 { NULL, 48, 0x80FFFF0C, 0x00000000 }, | 371 {NULL, 48, 0x80FFFF0C, 0x00000000}, |
369 { NULL, 49, 0x80FFFF0C, 0x00000000 }, | 372 {NULL, 49, 0x80FFFF0C, 0x00000000}, |
370 { NULL, 50, 0x80FFFF0C, 0x00000000 }, | 373 {NULL, 50, 0x80FFFF0C, 0x00000000}, |
371 { NULL, 51, 0x80FFFF0C, 0x00000000 }, | 374 {NULL, 51, 0x80FFFF0C, 0x00000000}, |
372 { NULL, 52, 0x80FFFF0C, 0x00000000 }, | 375 {NULL, 52, 0x80FFFF0C, 0x00000000}, |
373 { NULL, 53, 0x80FFFF0C, 0x00000000 }, | 376 {NULL, 53, 0x80FFFF0C, 0x00000000}, |
374 { NULL, 54, 0x80FFFF0C, 0x00000000 }, | 377 {NULL, 54, 0x80FFFF0C, 0x00000000}, |
375 { NULL, 55, 0x80FFFF0C, 0x00000000 }, | 378 {NULL, 55, 0x80FFFF0C, 0x00000000}, |
376 { NULL, 56, 0x80FFFF0C, 0x00000000 }, | 379 {NULL, 56, 0x80FFFF0C, 0x00000000}, |
377 { NULL, 57, 0x80FFFF0C, 0x00000000 }, | 380 {NULL, 57, 0x80FFFF0C, 0x00000000}, |
378 { NULL, 58, 0x80FFFF0C, 0x00000000 }, | 381 {NULL, 58, 0x80FFFF0C, 0x00000000}, |
379 { NULL, 59, 0x80FFFF0C, 0x00000000 }, | 382 {NULL, 59, 0x80FFFF0C, 0x00000000}, |
380 { NULL, 60, 0x80FFFF0C, 0x00000000 }, | 383 {NULL, 60, 0x80FFFF0C, 0x00000000}, |
381 { NULL, 61, 0x80FFFF0C, 0x00000000 }, | 384 {NULL, 61, 0x80FFFF0C, 0x00000000}, |
382 { NULL, 62, 0x80FFFF0C, 0x00000000 }, | 385 {NULL, 62, 0x80FFFF0C, 0x00000000}, |
383 { NULL, 63, 0x80FFFF0C, 0x00000000 }, | 386 {NULL, 63, 0x80FFFF0C, 0x00000000}, |
384 { NULL, 64, 0x80FFFF0C, 0x00000000 }, | 387 {NULL, 64, 0x80FFFF0C, 0x00000000}, |
385 { NULL, 65, 0x80FFFF0C, 0x00000000 }, | 388 {NULL, 65, 0x80FFFF0C, 0x00000000}, |
386 { NULL, 66, 0x80FFFF0C, 0x00000000 }, | 389 {NULL, 66, 0x80FFFF0C, 0x00000000}, |
387 { NULL, 67, 0x80FFFF0C, 0x00000000 }, | 390 {NULL, 67, 0x80FFFF0C, 0x00000000}, |
388 { NULL, 68, 0x80FFFF0C, 0x00000000 }, | 391 {NULL, 68, 0x80FFFF0C, 0x00000000}, |
389 { NULL, 69, 0x80FFFF0C, 0x00000000 }, | 392 {NULL, 69, 0x80FFFF0C, 0x00000000}, |
390 { NULL, 70, 0x80FFFF0C, 0x00000000 }, | 393 {NULL, 70, 0x80FFFF0C, 0x00000000}, |
391 { NULL, 71, 0x80FFFF0C, 0x00000000 }, | 394 {NULL, 71, 0x80FFFF0C, 0x00000000}, |
392 { NULL, 72, 0x80FFFF0C, 0x00000000 }, | 395 {NULL, 72, 0x80FFFF0C, 0x00000000}, |
393 { NULL, 73, 0x80FFFF0C, 0x00000000 }, | 396 {NULL, 73, 0x80FFFF0C, 0x00000000}, |
394 { NULL, 74, 0x80FFFF0C, 0x00000000 }, | 397 {NULL, 74, 0x80FFFF0C, 0x00000000}, |
395 { NULL, 75, 0x80FFFF0C, 0x00000000 }, | 398 {NULL, 75, 0x80FFFF0C, 0x00000000}, |
396 { NULL, 76, 0x80FFFF0C, 0x00000000 }, | 399 {NULL, 76, 0x80FFFF0C, 0x00000000}, |
397 { NULL, 77, 0x80FFFF0C, 0x00000000 }, | 400 {NULL, 77, 0x80FFFF0C, 0x00000000}, |
398 { NULL, 78, 0x80FFFF0C, 0x00000000 }, | 401 {NULL, 78, 0x80FFFF0C, 0x00000000}, |
399 { NULL, 79, 0x80FFFF0C, 0x00000000 }, | 402 {NULL, 79, 0x80FFFF0C, 0x00000000}, |
400 }; | 403 }; |
401 | 404 |
402 const DIDATAFORMAT c_dfDIJoystick = { 24, 16, 0x00000001, 80, 44, JOY_fmt }; | 405 const DIDATAFORMAT c_dfDIJoystick = { 24, 16, 0x00000001, 80, 44, JOY_fmt }; |
403 | 406 |
404 | 407 |
405 /* Initialization/Query functions */ | 408 /* Initialization/Query functions */ |
406 static int DX5_VideoInit(_THIS, SDL_PixelFormat *vformat); | 409 static int DX5_VideoInit(_THIS, SDL_PixelFormat * vformat); |
407 static SDL_Rect **DX5_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | 410 static SDL_Rect **DX5_ListModes(_THIS, SDL_PixelFormat * format, |
408 static SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | 411 Uint32 flags); |
412 static SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface * current, int width, | |
413 int height, int bpp, Uint32 flags); | |
409 static int DX5_SetColors(_THIS, int firstcolor, int ncolors, | 414 static int DX5_SetColors(_THIS, int firstcolor, int ncolors, |
410 SDL_Color *colors); | 415 SDL_Color * colors); |
411 static int DX5_SetGammaRamp(_THIS, Uint16 *ramp); | 416 static int DX5_SetGammaRamp(_THIS, Uint16 * ramp); |
412 static int DX5_GetGammaRamp(_THIS, Uint16 *ramp); | 417 static int DX5_GetGammaRamp(_THIS, Uint16 * ramp); |
413 static void DX5_VideoQuit(_THIS); | 418 static void DX5_VideoQuit(_THIS); |
414 | 419 |
415 /* Hardware surface functions */ | 420 /* Hardware surface functions */ |
416 static int DX5_AllocHWSurface(_THIS, SDL_Surface *surface); | 421 static int DX5_AllocHWSurface(_THIS, SDL_Surface * surface); |
417 static int DX5_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst); | 422 static int DX5_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst); |
418 static int DX5_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color); | 423 static int DX5_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect, |
419 static int DX5_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key); | 424 Uint32 color); |
420 static int DX5_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha); | 425 static int DX5_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key); |
421 static int DX5_LockHWSurface(_THIS, SDL_Surface *surface); | 426 static int DX5_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha); |
422 static void DX5_UnlockHWSurface(_THIS, SDL_Surface *surface); | 427 static int DX5_LockHWSurface(_THIS, SDL_Surface * surface); |
423 static int DX5_FlipHWSurface(_THIS, SDL_Surface *surface); | 428 static void DX5_UnlockHWSurface(_THIS, SDL_Surface * surface); |
424 static void DX5_FreeHWSurface(_THIS, SDL_Surface *surface); | 429 static int DX5_FlipHWSurface(_THIS, SDL_Surface * surface); |
425 | 430 static void DX5_FreeHWSurface(_THIS, SDL_Surface * surface); |
426 static int DX5_AllocDDSurface(_THIS, SDL_Surface *surface, | 431 |
427 LPDIRECTDRAWSURFACE3 requested, Uint32 flag); | 432 static int DX5_AllocDDSurface(_THIS, SDL_Surface * surface, |
433 LPDIRECTDRAWSURFACE3 requested, Uint32 flag); | |
428 | 434 |
429 /* Windows message handling functions */ | 435 /* Windows message handling functions */ |
430 static void DX5_RealizePalette(_THIS); | 436 static void DX5_RealizePalette(_THIS); |
431 static void DX5_PaletteChanged(_THIS, HWND window); | 437 static void DX5_PaletteChanged(_THIS, HWND window); |
432 static void DX5_WinPAINT(_THIS, HDC hdc); | 438 static void DX5_WinPAINT(_THIS, HDC hdc); |
433 | 439 |
434 /* WinDIB driver functions for manipulating gamma ramps */ | 440 /* WinDIB driver functions for manipulating gamma ramps */ |
435 extern int DIB_SetGammaRamp(_THIS, Uint16 *ramp); | 441 extern int DIB_SetGammaRamp(_THIS, Uint16 * ramp); |
436 extern int DIB_GetGammaRamp(_THIS, Uint16 *ramp); | 442 extern int DIB_GetGammaRamp(_THIS, Uint16 * ramp); |
437 extern void DIB_QuitGamma(_THIS); | 443 extern void DIB_QuitGamma(_THIS); |
438 | 444 |
439 /* DX5 driver bootstrap functions */ | |
440 | |
441 static int DX5_Available(void) | |
442 { | |
443 HINSTANCE DInputDLL; | |
444 HINSTANCE DDrawDLL; | |
445 int dinput_ok; | |
446 int ddraw_ok; | |
447 | |
448 /* Version check DINPUT.DLL and DDRAW.DLL (Is DirectX okay?) */ | |
449 dinput_ok = 0; | |
450 DInputDLL = LoadLibrary(TEXT("DINPUT.DLL")); | |
451 if ( DInputDLL != NULL ) { | |
452 dinput_ok = 1; | |
453 FreeLibrary(DInputDLL); | |
454 } | |
455 ddraw_ok = 0; | |
456 DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL")); | |
457 if ( DDrawDLL != NULL ) { | |
458 HRESULT (WINAPI *DDrawCreate)(GUID *,LPDIRECTDRAW *,IUnknown *); | |
459 LPDIRECTDRAW DDraw; | |
460 | |
461 /* Try to create a valid DirectDraw object */ | |
462 DDrawCreate = (void *)GetProcAddress(DDrawDLL, TEXT("DirectDrawCreate")); | |
463 if ( (DDrawCreate != NULL) | |
464 && !FAILED(DDrawCreate(NULL, &DDraw, NULL)) ) { | |
465 if ( !FAILED(IDirectDraw_SetCooperativeLevel(DDraw, | |
466 NULL, DDSCL_NORMAL)) ) { | |
467 DDSURFACEDESC desc; | |
468 LPDIRECTDRAWSURFACE DDrawSurf; | |
469 LPDIRECTDRAWSURFACE3 DDrawSurf3; | |
470 | |
471 /* Try to create a DirectDrawSurface3 object */ | |
472 SDL_memset(&desc, 0, sizeof(desc)); | |
473 desc.dwSize = sizeof(desc); | |
474 desc.dwFlags = DDSD_CAPS; | |
475 desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE|DDSCAPS_VIDEOMEMORY; | |
476 if ( !FAILED(IDirectDraw_CreateSurface(DDraw, &desc, | |
477 &DDrawSurf, NULL)) ) { | |
478 if ( !FAILED(IDirectDrawSurface_QueryInterface(DDrawSurf, | |
479 &IID_IDirectDrawSurface3, (LPVOID *)&DDrawSurf3)) ) { | |
480 /* Yay! */ | |
481 ddraw_ok = 1; | |
482 | |
483 /* Clean up.. */ | |
484 IDirectDrawSurface3_Release(DDrawSurf3); | |
485 } | |
486 IDirectDrawSurface_Release(DDrawSurf); | |
487 } | |
488 } | |
489 IDirectDraw_Release(DDraw); | |
490 } | |
491 FreeLibrary(DDrawDLL); | |
492 } | |
493 return(dinput_ok && ddraw_ok); | |
494 } | |
495 | |
496 /* Functions for loading the DirectX functions dynamically */ | 445 /* Functions for loading the DirectX functions dynamically */ |
446 static int DX5_loaded = 0; | |
497 static HINSTANCE DDrawDLL = NULL; | 447 static HINSTANCE DDrawDLL = NULL; |
498 static HINSTANCE DInputDLL = NULL; | 448 static HINSTANCE DInputDLL = NULL; |
499 | 449 |
500 static void DX5_Unload(void) | 450 void |
501 { | 451 DX5_Unload(void) |
502 if ( DDrawDLL != NULL ) { | 452 { |
503 FreeLibrary(DDrawDLL); | 453 if (--DX5_loaded == 0) { |
504 DDrawCreate = NULL; | 454 if (DDrawDLL != NULL) { |
505 DDrawDLL = NULL; | 455 FreeLibrary(DDrawDLL); |
506 } | 456 DDrawCreate = NULL; |
507 if ( DInputDLL != NULL ) { | 457 DDrawDLL = NULL; |
508 FreeLibrary(DInputDLL); | 458 } |
509 DInputCreate = NULL; | 459 if (DInputDLL != NULL) { |
510 DInputDLL = NULL; | 460 FreeLibrary(DInputDLL); |
511 } | 461 DInputCreate = NULL; |
512 } | 462 DInputDLL = NULL; |
513 static int DX5_Load(void) | 463 } |
514 { | 464 } |
515 int status; | 465 } |
516 | 466 int |
517 DX5_Unload(); | 467 DX5_Load(void) |
518 DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL")); | 468 { |
519 if ( DDrawDLL != NULL ) { | 469 int status = 0; |
520 DDrawCreate = (void *)GetProcAddress(DDrawDLL, | 470 |
521 TEXT("DirectDrawCreate")); | 471 if (++DX5_loaded == 1) { |
522 } | 472 DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL")); |
523 DInputDLL = LoadLibrary(TEXT("DINPUT.DLL")); | 473 if (DDrawDLL != NULL) { |
524 if ( DInputDLL != NULL ) { | 474 DDrawCreate = (void *) GetProcAddress(DDrawDLL, |
525 DInputCreate = (void *)GetProcAddress(DInputDLL, | 475 TEXT("DirectDrawCreate")); |
526 TEXT("DirectInputCreateA")); | 476 } |
527 } | 477 DInputDLL = LoadLibrary(TEXT("DINPUT.DLL")); |
528 if ( DDrawDLL && DDrawCreate && DInputDLL && DInputCreate ) { | 478 if (DInputDLL != NULL) { |
529 status = 0; | 479 DInputCreate = (void *) GetProcAddress(DInputDLL, |
530 } else { | 480 TEXT |
531 DX5_Unload(); | 481 ("DirectInputCreateA")); |
532 status = -1; | 482 } |
533 } | 483 if (DDrawDLL && DDrawCreate && DInputDLL && DInputCreate) { |
534 return status; | 484 status = 0; |
535 } | 485 } else { |
536 | 486 DX5_Unload(); |
537 static void DX5_DeleteDevice(SDL_VideoDevice *this) | 487 status = -1; |
538 { | 488 } |
539 /* Free DirectDraw object */ | 489 } |
540 if ( ddraw2 != NULL ) { | 490 return status; |
541 IDirectDraw2_Release(ddraw2); | 491 } |
542 } | 492 |
543 DX5_Unload(); | 493 /* DX5 driver bootstrap functions */ |
544 if ( this ) { | 494 |
545 if ( this->hidden ) { | 495 static int |
546 SDL_free(this->hidden); | 496 DX5_Available(void) |
547 } | 497 { |
548 if ( this->gl_data ) { | 498 int ddraw_ok = 0; |
549 SDL_free(this->gl_data); | 499 HRESULT(WINAPI * DDrawCreate) (GUID *, LPDIRECTDRAW *, IUnknown *); |
550 } | 500 LPDIRECTDRAW DDraw; |
551 SDL_free(this); | 501 |
552 } | 502 /* Version check DINPUT.DLL and DDRAW.DLL (Is DirectX okay?) */ |
553 } | 503 if (DX5_Load() < 0) { |
554 | 504 return -1; |
555 static SDL_VideoDevice *DX5_CreateDevice(int devindex) | 505 } |
556 { | 506 |
557 SDL_VideoDevice *device; | 507 /* Try to create a valid DirectDraw object */ |
558 | 508 DDrawCreate = (void *) GetProcAddress(DDrawDLL, TEXT("DirectDrawCreate")); |
559 /* Load DirectX */ | 509 if ((DDrawCreate != NULL) && !FAILED(DDrawCreate(NULL, &DDraw, NULL))) { |
560 if ( DX5_Load() < 0 ) { | 510 if (!FAILED(IDirectDraw_SetCooperativeLevel(DDraw, |
561 return(NULL); | 511 NULL, DDSCL_NORMAL))) { |
562 } | 512 DDSURFACEDESC desc; |
563 | 513 LPDIRECTDRAWSURFACE DDrawSurf; |
564 /* Initialize all variables that we clean on shutdown */ | 514 LPDIRECTDRAWSURFACE3 DDrawSurf3; |
565 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); | 515 |
566 if ( device ) { | 516 /* Try to create a DirectDrawSurface3 object */ |
567 SDL_memset(device, 0, (sizeof *device)); | 517 SDL_memset(&desc, 0, sizeof(desc)); |
568 device->hidden = (struct SDL_PrivateVideoData *) | 518 desc.dwSize = sizeof(desc); |
569 SDL_malloc((sizeof *device->hidden)); | 519 desc.dwFlags = DDSD_CAPS; |
570 device->gl_data = (struct SDL_PrivateGLData *) | 520 desc.ddsCaps.dwCaps = |
571 SDL_malloc((sizeof *device->gl_data)); | 521 DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY; |
572 } | 522 if (!FAILED |
573 if ( (device == NULL) || (device->hidden == NULL) || | 523 (IDirectDraw_CreateSurface(DDraw, &desc, &DDrawSurf, NULL))) { |
574 (device->gl_data == NULL) ) { | 524 if (!FAILED |
575 SDL_OutOfMemory(); | 525 (IDirectDrawSurface_QueryInterface |
576 DX5_DeleteDevice(device); | 526 (DDrawSurf, &IID_IDirectDrawSurface3, |
577 return(NULL); | 527 (LPVOID *) & DDrawSurf3))) { |
578 } | 528 /* Yay! */ |
579 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); | 529 ddraw_ok = 1; |
580 SDL_memset(device->gl_data, 0, (sizeof *device->gl_data)); | 530 |
581 | 531 /* Clean up.. */ |
582 /* Set the function pointers */ | 532 IDirectDrawSurface3_Release(DDrawSurf3); |
583 device->VideoInit = DX5_VideoInit; | 533 } |
584 device->ListModes = DX5_ListModes; | 534 IDirectDrawSurface_Release(DDrawSurf); |
585 device->SetVideoMode = DX5_SetVideoMode; | 535 } |
586 device->UpdateMouse = WIN_UpdateMouse; | 536 } |
587 device->CreateYUVOverlay = DX5_CreateYUVOverlay; | 537 IDirectDraw_Release(DDraw); |
588 device->SetColors = DX5_SetColors; | 538 } |
589 device->UpdateRects = NULL; | 539 |
590 device->VideoQuit = DX5_VideoQuit; | 540 DX5_Unload(); |
591 device->AllocHWSurface = DX5_AllocHWSurface; | 541 |
592 device->CheckHWBlit = DX5_CheckHWBlit; | 542 return ddraw_ok; |
593 device->FillHWRect = DX5_FillHWRect; | 543 } |
594 device->SetHWColorKey = DX5_SetHWColorKey; | 544 |
595 device->SetHWAlpha = DX5_SetHWAlpha; | 545 static void |
596 device->LockHWSurface = DX5_LockHWSurface; | 546 DX5_DeleteDevice(SDL_VideoDevice * this) |
597 device->UnlockHWSurface = DX5_UnlockHWSurface; | 547 { |
598 device->FlipHWSurface = DX5_FlipHWSurface; | 548 /* Free DirectDraw object */ |
599 device->FreeHWSurface = DX5_FreeHWSurface; | 549 if (ddraw2 != NULL) { |
600 device->SetGammaRamp = DX5_SetGammaRamp; | 550 IDirectDraw2_Release(ddraw2); |
601 device->GetGammaRamp = DX5_GetGammaRamp; | 551 } |
552 DX5_Unload(); | |
553 | |
554 if (this) { | |
555 if (this->hidden) { | |
556 SDL_free(this->hidden); | |
557 } | |
558 if (this->gl_data) { | |
559 SDL_free(this->gl_data); | |
560 } | |
561 SDL_free(this); | |
562 } | |
563 } | |
564 | |
565 static SDL_VideoDevice * | |
566 DX5_CreateDevice(int devindex) | |
567 { | |
568 SDL_VideoDevice *device; | |
569 | |
570 /* Load DirectX */ | |
571 if (DX5_Load() < 0) { | |
572 return (NULL); | |
573 } | |
574 | |
575 /* Initialize all variables that we clean on shutdown */ | |
576 device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); | |
577 if (device) { | |
578 SDL_memset(device, 0, (sizeof *device)); | |
579 device->hidden = (struct SDL_PrivateVideoData *) | |
580 SDL_malloc((sizeof *device->hidden)); | |
581 device->gl_data = (struct SDL_PrivateGLData *) | |
582 SDL_malloc((sizeof *device->gl_data)); | |
583 } | |
584 if ((device == NULL) || (device->hidden == NULL) || | |
585 (device->gl_data == NULL)) { | |
586 SDL_OutOfMemory(); | |
587 DX5_DeleteDevice(device); | |
588 return (NULL); | |
589 } | |
590 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); | |
591 SDL_memset(device->gl_data, 0, (sizeof *device->gl_data)); | |
592 | |
593 /* Set the function pointers */ | |
594 device->VideoInit = DX5_VideoInit; | |
595 device->ListModes = DX5_ListModes; | |
596 device->SetVideoMode = DX5_SetVideoMode; | |
597 device->UpdateMouse = WIN_UpdateMouse; | |
598 device->CreateYUVOverlay = DX5_CreateYUVOverlay; | |
599 device->SetColors = DX5_SetColors; | |
600 device->UpdateRects = NULL; | |
601 device->VideoQuit = DX5_VideoQuit; | |
602 device->AllocHWSurface = DX5_AllocHWSurface; | |
603 device->CheckHWBlit = DX5_CheckHWBlit; | |
604 device->FillHWRect = DX5_FillHWRect; | |
605 device->SetHWColorKey = DX5_SetHWColorKey; | |
606 device->SetHWAlpha = DX5_SetHWAlpha; | |
607 device->LockHWSurface = DX5_LockHWSurface; | |
608 device->UnlockHWSurface = DX5_UnlockHWSurface; | |
609 device->FlipHWSurface = DX5_FlipHWSurface; | |
610 device->FreeHWSurface = DX5_FreeHWSurface; | |
611 device->SetGammaRamp = DX5_SetGammaRamp; | |
612 device->GetGammaRamp = DX5_GetGammaRamp; | |
602 #if SDL_VIDEO_OPENGL | 613 #if SDL_VIDEO_OPENGL |
603 device->GL_LoadLibrary = WIN_GL_LoadLibrary; | 614 device->GL_LoadLibrary = WIN_GL_LoadLibrary; |
604 device->GL_GetProcAddress = WIN_GL_GetProcAddress; | 615 device->GL_GetProcAddress = WIN_GL_GetProcAddress; |
605 device->GL_GetAttribute = WIN_GL_GetAttribute; | 616 device->GL_GetAttribute = WIN_GL_GetAttribute; |
606 device->GL_MakeCurrent = WIN_GL_MakeCurrent; | 617 device->GL_MakeCurrent = WIN_GL_MakeCurrent; |
607 device->GL_SwapBuffers = WIN_GL_SwapBuffers; | 618 device->GL_SwapBuffers = WIN_GL_SwapBuffers; |
608 #endif | 619 #endif |
609 device->SetCaption = WIN_SetWMCaption; | 620 device->SetCaption = WIN_SetWMCaption; |
610 device->SetIcon = WIN_SetWMIcon; | 621 device->SetIcon = WIN_SetWMIcon; |
611 device->IconifyWindow = WIN_IconifyWindow; | 622 device->IconifyWindow = WIN_IconifyWindow; |
612 device->GrabInput = WIN_GrabInput; | 623 device->GrabInput = WIN_GrabInput; |
613 device->GetWMInfo = WIN_GetWMInfo; | 624 device->GetWMInfo = WIN_GetWMInfo; |
614 device->FreeWMCursor = WIN_FreeWMCursor; | 625 device->FreeWMCursor = WIN_FreeWMCursor; |
615 device->CreateWMCursor = WIN_CreateWMCursor; | 626 device->CreateWMCursor = WIN_CreateWMCursor; |
616 device->ShowWMCursor = WIN_ShowWMCursor; | 627 device->ShowWMCursor = WIN_ShowWMCursor; |
617 device->WarpWMCursor = WIN_WarpWMCursor; | 628 device->WarpWMCursor = WIN_WarpWMCursor; |
618 device->CheckMouseMode = WIN_CheckMouseMode; | 629 device->CheckMouseMode = WIN_CheckMouseMode; |
619 device->InitOSKeymap = DX5_InitOSKeymap; | 630 device->InitOSKeymap = DX5_InitOSKeymap; |
620 device->PumpEvents = DX5_PumpEvents; | 631 device->PumpEvents = DX5_PumpEvents; |
621 | 632 |
622 /* Set up the windows message handling functions */ | 633 /* Set up the windows message handling functions */ |
623 WIN_RealizePalette = DX5_RealizePalette; | 634 WIN_RealizePalette = DX5_RealizePalette; |
624 WIN_PaletteChanged = DX5_PaletteChanged; | 635 WIN_PaletteChanged = DX5_PaletteChanged; |
625 WIN_WinPAINT = DX5_WinPAINT; | 636 WIN_WinPAINT = DX5_WinPAINT; |
626 HandleMessage = DX5_HandleMessage; | 637 HandleMessage = DX5_HandleMessage; |
627 | 638 |
628 device->free = DX5_DeleteDevice; | 639 device->free = DX5_DeleteDevice; |
629 | 640 |
630 /* We're finally ready */ | 641 /* We're finally ready */ |
631 return device; | 642 return device; |
632 } | 643 } |
633 | 644 |
634 VideoBootStrap DIRECTX_bootstrap = { | 645 VideoBootStrap DIRECTX_bootstrap = { |
635 "directx", "Win95/98/2000 DirectX", | 646 "directx", "Win95/98/2000 DirectX", |
636 DX5_Available, DX5_CreateDevice | 647 DX5_Available, DX5_CreateDevice |
637 }; | 648 }; |
638 | 649 |
639 static int cmpmodes(const void *va, const void *vb) | 650 static int |
640 { | 651 cmpmodes(const void *va, const void *vb) |
641 SDL_Rect *a = *(SDL_Rect **)va; | 652 { |
642 SDL_Rect *b = *(SDL_Rect **)vb; | 653 SDL_Rect *a = *(SDL_Rect **) va; |
643 if ( a->w == b->w ) | 654 SDL_Rect *b = *(SDL_Rect **) vb; |
655 if (a->w == b->w) | |
644 return b->h - a->h; | 656 return b->h - a->h; |
645 else | 657 else |
646 return b->w - a->w; | 658 return b->w - a->w; |
647 } | 659 } |
648 | 660 |
649 static HRESULT WINAPI EnumModes2(DDSURFACEDESC *desc, VOID *udata) | 661 static HRESULT WINAPI |
650 { | 662 EnumModes2(DDSURFACEDESC * desc, VOID * udata) |
651 SDL_VideoDevice *this = (SDL_VideoDevice *)udata; | 663 { |
652 struct DX5EnumRect *enumrect; | 664 SDL_VideoDevice *this = (SDL_VideoDevice *) udata; |
665 struct DX5EnumRect *enumrect; | |
653 #if defined(NONAMELESSUNION) | 666 #if defined(NONAMELESSUNION) |
654 int bpp = desc->ddpfPixelFormat.u1.dwRGBBitCount; | 667 int bpp = desc->ddpfPixelFormat.u1.dwRGBBitCount; |
655 int refreshRate = desc->u2.dwRefreshRate; | 668 int refreshRate = desc->u2.dwRefreshRate; |
656 #else | 669 #else |
657 int bpp = desc->ddpfPixelFormat.dwRGBBitCount; | 670 int bpp = desc->ddpfPixelFormat.dwRGBBitCount; |
658 int refreshRate = desc->dwRefreshRate; | 671 int refreshRate = desc->dwRefreshRate; |
659 #endif | 672 #endif |
660 int maxRefreshRate; | 673 int maxRefreshRate; |
661 | 674 |
662 if ( desc->dwWidth <= SDL_desktop_mode.dmPelsWidth && | 675 if (desc->dwWidth <= SDL_desktop_mode.dmPelsWidth && |
663 desc->dwHeight <= SDL_desktop_mode.dmPelsHeight ) { | 676 desc->dwHeight <= SDL_desktop_mode.dmPelsHeight) { |
664 maxRefreshRate = SDL_desktop_mode.dmDisplayFrequency; | 677 maxRefreshRate = SDL_desktop_mode.dmDisplayFrequency; |
665 } else { | 678 } else { |
666 maxRefreshRate = 85; /* safe value? */ | 679 maxRefreshRate = 85; /* safe value? */ |
667 } | 680 } |
668 | 681 |
669 switch (bpp) { | 682 switch (bpp) { |
670 case 8: | 683 case 8: |
671 case 16: | 684 case 16: |
672 case 24: | 685 case 24: |
673 case 32: | 686 case 32: |
674 bpp /= 8; --bpp; | 687 bpp /= 8; |
675 if ( enumlists[bpp] && | 688 --bpp; |
676 enumlists[bpp]->r.w == (Uint16)desc->dwWidth && | 689 if (enumlists[bpp] && |
677 enumlists[bpp]->r.h == (Uint16)desc->dwHeight ) { | 690 enumlists[bpp]->r.w == (Uint16) desc->dwWidth && |
678 if ( refreshRate > enumlists[bpp]->refreshRate && | 691 enumlists[bpp]->r.h == (Uint16) desc->dwHeight) { |
679 refreshRate <= maxRefreshRate ) { | 692 if (refreshRate > enumlists[bpp]->refreshRate && |
680 enumlists[bpp]->refreshRate = refreshRate; | 693 refreshRate <= maxRefreshRate) { |
694 enumlists[bpp]->refreshRate = refreshRate; | |
681 #ifdef DDRAW_DEBUG | 695 #ifdef DDRAW_DEBUG |
682 fprintf(stderr, "New refresh rate for %d bpp: %dx%d at %d Hz\n", (bpp+1)*8, (int)desc->dwWidth, (int)desc->dwHeight, refreshRate); | 696 fprintf(stderr, |
683 #endif | 697 "New refresh rate for %d bpp: %dx%d at %d Hz\n", |
684 } | 698 (bpp + 1) * 8, (int) desc->dwWidth, |
685 break; | 699 (int) desc->dwHeight, refreshRate); |
686 } | 700 #endif |
687 ++SDL_nummodes[bpp]; | 701 } |
688 enumrect = (struct DX5EnumRect*)SDL_malloc(sizeof(struct DX5EnumRect)); | 702 break; |
689 if ( !enumrect ) { | 703 } |
690 SDL_OutOfMemory(); | 704 ++SDL_nummodes[bpp]; |
691 return(DDENUMRET_CANCEL); | 705 enumrect = |
692 } | 706 (struct DX5EnumRect *) SDL_malloc(sizeof(struct DX5EnumRect)); |
693 enumrect->refreshRate = refreshRate; | 707 if (!enumrect) { |
694 enumrect->r.x = 0; | 708 SDL_OutOfMemory(); |
695 enumrect->r.y = 0; | 709 return (DDENUMRET_CANCEL); |
696 enumrect->r.w = (Uint16)desc->dwWidth; | 710 } |
697 enumrect->r.h = (Uint16)desc->dwHeight; | 711 enumrect->refreshRate = refreshRate; |
698 enumrect->next = enumlists[bpp]; | 712 enumrect->r.x = 0; |
699 enumlists[bpp] = enumrect; | 713 enumrect->r.y = 0; |
714 enumrect->r.w = (Uint16) desc->dwWidth; | |
715 enumrect->r.h = (Uint16) desc->dwHeight; | |
716 enumrect->next = enumlists[bpp]; | |
717 enumlists[bpp] = enumrect; | |
700 #ifdef DDRAW_DEBUG | 718 #ifdef DDRAW_DEBUG |
701 fprintf(stderr, "New mode for %d bpp: %dx%d at %d Hz\n", (bpp+1)*8, (int)desc->dwWidth, (int)desc->dwHeight, refreshRate); | 719 fprintf(stderr, "New mode for %d bpp: %dx%d at %d Hz\n", |
702 #endif | 720 (bpp + 1) * 8, (int) desc->dwWidth, (int) desc->dwHeight, |
703 break; | 721 refreshRate); |
704 } | 722 #endif |
705 | 723 break; |
706 return(DDENUMRET_OK); | 724 } |
707 } | 725 |
708 | 726 return (DDENUMRET_OK); |
709 void SetDDerror(const char *function, int code) | 727 } |
710 { | 728 |
711 static char *error; | 729 void |
712 static char errbuf[1024]; | 730 SetDDerror(const char *function, int code) |
713 | 731 { |
714 errbuf[0] = 0; | 732 static char *error; |
715 switch (code) { | 733 static char errbuf[1024]; |
716 case DDERR_GENERIC: | 734 |
717 error = "Undefined error!"; | 735 errbuf[0] = 0; |
718 break; | 736 switch (code) { |
719 case DDERR_EXCEPTION: | 737 case DDERR_GENERIC: |
720 error = "Exception encountered"; | 738 error = "Undefined error!"; |
721 break; | 739 break; |
722 case DDERR_INVALIDOBJECT: | 740 case DDERR_EXCEPTION: |
723 error = "Invalid object"; | 741 error = "Exception encountered"; |
724 break; | 742 break; |
725 case DDERR_INVALIDPARAMS: | 743 case DDERR_INVALIDOBJECT: |
726 error = "Invalid parameters"; | 744 error = "Invalid object"; |
727 break; | 745 break; |
728 case DDERR_NOTFOUND: | 746 case DDERR_INVALIDPARAMS: |
729 error = "Object not found"; | 747 error = "Invalid parameters"; |
730 break; | 748 break; |
731 case DDERR_INVALIDRECT: | 749 case DDERR_NOTFOUND: |
732 error = "Invalid rectangle"; | 750 error = "Object not found"; |
733 break; | 751 break; |
734 case DDERR_INVALIDCAPS: | 752 case DDERR_INVALIDRECT: |
735 error = "Invalid caps member"; | 753 error = "Invalid rectangle"; |
736 break; | 754 break; |
737 case DDERR_INVALIDPIXELFORMAT: | 755 case DDERR_INVALIDCAPS: |
738 error = "Invalid pixel format"; | 756 error = "Invalid caps member"; |
739 break; | 757 break; |
740 case DDERR_OUTOFMEMORY: | 758 case DDERR_INVALIDPIXELFORMAT: |
741 error = "Out of memory"; | 759 error = "Invalid pixel format"; |
742 break; | 760 break; |
743 case DDERR_OUTOFVIDEOMEMORY: | 761 case DDERR_OUTOFMEMORY: |
744 error = "Out of video memory"; | 762 error = "Out of memory"; |
745 break; | 763 break; |
746 case DDERR_SURFACEBUSY: | 764 case DDERR_OUTOFVIDEOMEMORY: |
747 error = "Surface busy"; | 765 error = "Out of video memory"; |
748 break; | 766 break; |
749 case DDERR_SURFACELOST: | 767 case DDERR_SURFACEBUSY: |
750 error = "Surface was lost"; | 768 error = "Surface busy"; |
751 break; | 769 break; |
752 case DDERR_WASSTILLDRAWING: | 770 case DDERR_SURFACELOST: |
753 error = "DirectDraw is still drawing"; | 771 error = "Surface was lost"; |
754 break; | 772 break; |
755 case DDERR_INVALIDSURFACETYPE: | 773 case DDERR_WASSTILLDRAWING: |
756 error = "Invalid surface type"; | 774 error = "DirectDraw is still drawing"; |
757 break; | 775 break; |
758 case DDERR_NOEXCLUSIVEMODE: | 776 case DDERR_INVALIDSURFACETYPE: |
759 error = "Not in exclusive access mode"; | 777 error = "Invalid surface type"; |
760 break; | 778 break; |
761 case DDERR_NOPALETTEATTACHED: | 779 case DDERR_NOEXCLUSIVEMODE: |
762 error = "No palette attached"; | 780 error = "Not in exclusive access mode"; |
763 break; | 781 break; |
764 case DDERR_NOPALETTEHW: | 782 case DDERR_NOPALETTEATTACHED: |
765 error = "No palette hardware"; | 783 error = "No palette attached"; |
766 break; | 784 break; |
767 case DDERR_NOT8BITCOLOR: | 785 case DDERR_NOPALETTEHW: |
768 error = "Not 8-bit color"; | 786 error = "No palette hardware"; |
769 break; | 787 break; |
770 case DDERR_EXCLUSIVEMODEALREADYSET: | 788 case DDERR_NOT8BITCOLOR: |
771 error = "Exclusive mode was already set"; | 789 error = "Not 8-bit color"; |
772 break; | 790 break; |
773 case DDERR_HWNDALREADYSET: | 791 case DDERR_EXCLUSIVEMODEALREADYSET: |
774 error = "Window handle already set"; | 792 error = "Exclusive mode was already set"; |
775 break; | 793 break; |
776 case DDERR_HWNDSUBCLASSED: | 794 case DDERR_HWNDALREADYSET: |
777 error = "Window handle is subclassed"; | 795 error = "Window handle already set"; |
778 break; | 796 break; |
779 case DDERR_NOBLTHW: | 797 case DDERR_HWNDSUBCLASSED: |
780 error = "No blit hardware"; | 798 error = "Window handle is subclassed"; |
781 break; | 799 break; |
782 case DDERR_IMPLICITLYCREATED: | 800 case DDERR_NOBLTHW: |
783 error = "Surface was implicitly created"; | 801 error = "No blit hardware"; |
784 break; | 802 break; |
785 case DDERR_INCOMPATIBLEPRIMARY: | 803 case DDERR_IMPLICITLYCREATED: |
786 error = "Incompatible primary surface"; | 804 error = "Surface was implicitly created"; |
787 break; | 805 break; |
788 case DDERR_NOCOOPERATIVELEVELSET: | 806 case DDERR_INCOMPATIBLEPRIMARY: |
789 error = "No cooperative level set"; | 807 error = "Incompatible primary surface"; |
790 break; | 808 break; |
791 case DDERR_NODIRECTDRAWHW: | 809 case DDERR_NOCOOPERATIVELEVELSET: |
792 error = "No DirectDraw hardware"; | 810 error = "No cooperative level set"; |
793 break; | 811 break; |
794 case DDERR_NOEMULATION: | 812 case DDERR_NODIRECTDRAWHW: |
795 error = "No emulation available"; | 813 error = "No DirectDraw hardware"; |
796 break; | 814 break; |
797 case DDERR_NOFLIPHW: | 815 case DDERR_NOEMULATION: |
798 error = "No flip hardware"; | 816 error = "No emulation available"; |
799 break; | 817 break; |
800 case DDERR_NOTFLIPPABLE: | 818 case DDERR_NOFLIPHW: |
801 error = "Surface not flippable"; | 819 error = "No flip hardware"; |
802 break; | 820 break; |
803 case DDERR_PRIMARYSURFACEALREADYEXISTS: | 821 case DDERR_NOTFLIPPABLE: |
804 error = "Primary surface already exists"; | 822 error = "Surface not flippable"; |
805 break; | 823 break; |
806 case DDERR_UNSUPPORTEDMODE: | 824 case DDERR_PRIMARYSURFACEALREADYEXISTS: |
807 error = "Unsupported mode"; | 825 error = "Primary surface already exists"; |
808 break; | 826 break; |
809 case DDERR_WRONGMODE: | 827 case DDERR_UNSUPPORTEDMODE: |
810 error = "Surface created in different mode"; | 828 error = "Unsupported mode"; |
811 break; | 829 break; |
812 case DDERR_UNSUPPORTED: | 830 case DDERR_WRONGMODE: |
813 error = "Operation not supported"; | 831 error = "Surface created in different mode"; |
814 break; | 832 break; |
815 case E_NOINTERFACE: | 833 case DDERR_UNSUPPORTED: |
816 error = "Interface not present"; | 834 error = "Operation not supported"; |
817 break; | 835 break; |
818 default: | 836 case E_NOINTERFACE: |
819 SDL_snprintf(errbuf, SDL_arraysize(errbuf), | 837 error = "Interface not present"; |
820 "%s: Unknown DirectDraw error: 0x%x", | 838 break; |
821 function, code); | 839 default: |
822 break; | 840 SDL_snprintf(errbuf, SDL_arraysize(errbuf), |
823 } | 841 "%s: Unknown DirectDraw error: 0x%x", function, code); |
824 if ( ! errbuf[0] ) { | 842 break; |
825 SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, error); | 843 } |
826 } | 844 if (!errbuf[0]) { |
827 SDL_SetError("%s", errbuf); | 845 SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, |
828 return; | 846 error); |
829 } | 847 } |
830 | 848 SDL_SetError("%s", errbuf); |
831 | 849 return; |
832 static int DX5_UpdateVideoInfo(_THIS) | 850 } |
833 { | 851 |
834 /* This needs to be DDCAPS_DX5 for the DirectDraw2 interface */ | 852 |
853 static int | |
854 DX5_UpdateVideoInfo(_THIS) | |
855 { | |
856 /* This needs to be DDCAPS_DX5 for the DirectDraw2 interface */ | |
835 #if DIRECTDRAW_VERSION <= 0x300 | 857 #if DIRECTDRAW_VERSION <= 0x300 |
836 #error Your version of DirectX must be greater than or equal to 5.0 | 858 #error Your version of DirectX must be greater than or equal to 5.0 |
837 #endif | 859 #endif |
838 #ifndef IDirectDrawGammaControl_SetGammaRamp | 860 #ifndef IDirectDrawGammaControl_SetGammaRamp |
839 /*if gamma is undefined then we really have directx <= 0x500*/ | 861 /*if gamma is undefined then we really have directx <= 0x500 */ |
840 DDCAPS DDCaps; | 862 DDCAPS DDCaps; |
841 #else | 863 #else |
842 DDCAPS_DX5 DDCaps; | 864 DDCAPS_DX5 DDCaps; |
843 #endif | 865 #endif |
844 HRESULT result; | 866 HRESULT result; |
845 | 867 |
846 /* Fill in our hardware acceleration capabilities */ | 868 /* Fill in our hardware acceleration capabilities */ |
847 SDL_memset(&DDCaps, 0, sizeof(DDCaps)); | 869 SDL_memset(&DDCaps, 0, sizeof(DDCaps)); |
848 DDCaps.dwSize = sizeof(DDCaps); | 870 DDCaps.dwSize = sizeof(DDCaps); |
849 result = IDirectDraw2_GetCaps(ddraw2, (DDCAPS *)&DDCaps, NULL); | 871 result = IDirectDraw2_GetCaps(ddraw2, (DDCAPS *) & DDCaps, NULL); |
850 if ( result != DD_OK ) { | 872 if (result != DD_OK) { |
851 SetDDerror("DirectDraw2::GetCaps", result); | 873 SetDDerror("DirectDraw2::GetCaps", result); |
852 return(-1); | 874 return (-1); |
853 } | 875 } |
854 this->info.hw_available = 1; | 876 this->info.hw_available = 1; |
855 if ( (DDCaps.dwCaps & DDCAPS_BLT) == DDCAPS_BLT ) { | 877 if ((DDCaps.dwCaps & DDCAPS_BLT) == DDCAPS_BLT) { |
856 this->info.blit_hw = 1; | 878 this->info.blit_hw = 1; |
857 } | 879 } |
858 if ( ((DDCaps.dwCaps & DDCAPS_COLORKEY) == DDCAPS_COLORKEY) && | 880 if (((DDCaps.dwCaps & DDCAPS_COLORKEY) == DDCAPS_COLORKEY) && |
859 ((DDCaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT) == DDCKEYCAPS_SRCBLT) ) { | 881 ((DDCaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT) == DDCKEYCAPS_SRCBLT)) { |
860 this->info.blit_hw_CC = 1; | 882 this->info.blit_hw_CC = 1; |
861 } | 883 } |
862 if ( (DDCaps.dwCaps & DDCAPS_ALPHA) == DDCAPS_ALPHA ) { | 884 if ((DDCaps.dwCaps & DDCAPS_ALPHA) == DDCAPS_ALPHA) { |
863 /* This is only for alpha channel, and DirectX 6 | 885 /* This is only for alpha channel, and DirectX 6 |
864 doesn't support 2D alpha blits yet, so set it 0 | 886 doesn't support 2D alpha blits yet, so set it 0 |
865 */ | 887 */ |
866 this->info.blit_hw_A = 0; | 888 this->info.blit_hw_A = 0; |
867 } | 889 } |
868 if ( (DDCaps.dwCaps & DDCAPS_CANBLTSYSMEM) == DDCAPS_CANBLTSYSMEM ) { | 890 if ((DDCaps.dwCaps & DDCAPS_CANBLTSYSMEM) == DDCAPS_CANBLTSYSMEM) { |
869 this->info.blit_sw = 1; | 891 this->info.blit_sw = 1; |
870 /* This isn't necessarily true, but the HEL will cover us */ | 892 /* This isn't necessarily true, but the HEL will cover us */ |
871 this->info.blit_sw_CC = this->info.blit_hw_CC; | 893 this->info.blit_sw_CC = this->info.blit_hw_CC; |
872 this->info.blit_sw_A = this->info.blit_hw_A; | 894 this->info.blit_sw_A = this->info.blit_hw_A; |
873 } | 895 } |
874 if ( (DDCaps.dwCaps & DDCAPS_BLTCOLORFILL) == DDCAPS_BLTCOLORFILL ) { | 896 if ((DDCaps.dwCaps & DDCAPS_BLTCOLORFILL) == DDCAPS_BLTCOLORFILL) { |
875 this->info.blit_fill = 1; | 897 this->info.blit_fill = 1; |
876 } | 898 } |
877 | 899 |
878 /* Find out how much video memory is available */ | 900 /* Find out how much video memory is available */ |
879 { DDSCAPS ddsCaps; | 901 { |
880 DWORD total_mem; | 902 DDSCAPS ddsCaps; |
881 ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; | 903 DWORD total_mem; |
882 result = IDirectDraw2_GetAvailableVidMem(ddraw2, | 904 ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; |
883 &ddsCaps, &total_mem, NULL); | 905 result = IDirectDraw2_GetAvailableVidMem(ddraw2, |
884 if ( result != DD_OK ) { | 906 &ddsCaps, &total_mem, NULL); |
885 total_mem = DDCaps.dwVidMemTotal; | 907 if (result != DD_OK) { |
886 } | 908 total_mem = DDCaps.dwVidMemTotal; |
887 this->info.video_mem = total_mem/1024; | 909 } |
888 } | 910 this->info.video_mem = total_mem / 1024; |
889 return(0); | 911 } |
890 } | 912 return (0); |
891 | 913 } |
892 int DX5_VideoInit(_THIS, SDL_PixelFormat *vformat) | 914 |
893 { | 915 int |
894 HRESULT result; | 916 DX5_VideoInit(_THIS, SDL_PixelFormat * vformat) |
895 LPDIRECTDRAW ddraw; | 917 { |
896 int i, j; | 918 HRESULT result; |
897 HDC hdc; | 919 LPDIRECTDRAW ddraw; |
898 | 920 int i, j; |
899 /* Intialize everything */ | 921 HDC hdc; |
900 ddraw2 = NULL; | 922 |
901 SDL_primary = NULL; | 923 /* Intialize everything */ |
902 SDL_clipper = NULL; | 924 ddraw2 = NULL; |
903 SDL_palette = NULL; | 925 SDL_primary = NULL; |
904 for ( i=0; i<NUM_MODELISTS; ++i ) { | 926 SDL_clipper = NULL; |
905 SDL_nummodes[i] = 0; | 927 SDL_palette = NULL; |
906 SDL_modelist[i] = NULL; | 928 for (i = 0; i < NUM_MODELISTS; ++i) { |
907 SDL_modeindex[i] = 0; | 929 SDL_nummodes[i] = 0; |
908 } | 930 SDL_modelist[i] = NULL; |
909 colorchange_expected = 0; | 931 SDL_modeindex[i] = 0; |
910 | 932 } |
911 /* Create the window */ | 933 colorchange_expected = 0; |
912 if ( DX5_CreateWindow(this) < 0 ) { | 934 |
913 return(-1); | 935 /* Create the window */ |
914 } | 936 if (DX5_CreateWindow(this) < 0) { |
915 | 937 return (-1); |
938 } | |
916 #if !SDL_AUDIO_DISABLED | 939 #if !SDL_AUDIO_DISABLED |
917 DX5_SoundFocus(SDL_Window); | 940 DX5_SoundFocus(SDL_Window); |
918 #endif | 941 #endif |
919 | 942 |
920 /* Create the DirectDraw object */ | 943 /* Create the DirectDraw object */ |
921 result = DDrawCreate(NULL, &ddraw, NULL); | 944 result = DDrawCreate(NULL, &ddraw, NULL); |
922 if ( result != DD_OK ) { | 945 if (result != DD_OK) { |
923 SetDDerror("DirectDrawCreate", result); | 946 SetDDerror("DirectDrawCreate", result); |
924 return(-1); | 947 return (-1); |
925 } | 948 } |
926 result = IDirectDraw_QueryInterface(ddraw, &IID_IDirectDraw2, | 949 result = IDirectDraw_QueryInterface(ddraw, &IID_IDirectDraw2, |
927 (LPVOID *)&ddraw2); | 950 (LPVOID *) & ddraw2); |
928 IDirectDraw_Release(ddraw); | 951 IDirectDraw_Release(ddraw); |
929 if ( result != DD_OK ) { | 952 if (result != DD_OK) { |
930 SetDDerror("DirectDraw::QueryInterface", result); | 953 SetDDerror("DirectDraw::QueryInterface", result); |
931 return(-1); | 954 return (-1); |
932 } | 955 } |
933 | 956 |
934 /* Determine the screen depth */ | 957 /* Determine the screen depth */ |
935 hdc = GetDC(SDL_Window); | 958 hdc = GetDC(SDL_Window); |
936 vformat->BitsPerPixel = GetDeviceCaps(hdc,PLANES) * | 959 vformat->BitsPerPixel = GetDeviceCaps(hdc, PLANES) * |
937 GetDeviceCaps(hdc,BITSPIXEL); | 960 GetDeviceCaps(hdc, BITSPIXEL); |
938 ReleaseDC(SDL_Window, hdc); | 961 ReleaseDC(SDL_Window, hdc); |
939 | 962 |
940 #ifndef NO_CHANGEDISPLAYSETTINGS | 963 #ifndef NO_CHANGEDISPLAYSETTINGS |
941 /* Query for the desktop resolution */ | 964 /* Query for the desktop resolution */ |
942 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode); | 965 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode); |
943 this->info.current_w = SDL_desktop_mode.dmPelsWidth; | 966 this->info.current_w = SDL_desktop_mode.dmPelsWidth; |
944 this->info.current_h = SDL_desktop_mode.dmPelsHeight; | 967 this->info.current_h = SDL_desktop_mode.dmPelsHeight; |
945 #endif | 968 #endif |
946 | 969 |
947 /* Enumerate the available fullscreen modes */ | 970 /* Enumerate the available fullscreen modes */ |
948 for ( i=0; i<NUM_MODELISTS; ++i ) | 971 for (i = 0; i < NUM_MODELISTS; ++i) |
949 enumlists[i] = NULL; | 972 enumlists[i] = NULL; |
950 | 973 |
951 result = IDirectDraw2_EnumDisplayModes(ddraw2,DDEDM_REFRESHRATES,NULL,this,EnumModes2); | 974 result = |
952 if ( result != DD_OK ) { | 975 IDirectDraw2_EnumDisplayModes(ddraw2, DDEDM_REFRESHRATES, NULL, this, |
953 SetDDerror("DirectDraw2::EnumDisplayModes", result); | 976 EnumModes2); |
954 return(-1); | 977 if (result != DD_OK) { |
955 } | 978 SetDDerror("DirectDraw2::EnumDisplayModes", result); |
956 for ( i=0; i<NUM_MODELISTS; ++i ) { | 979 return (-1); |
957 struct DX5EnumRect *rect; | 980 } |
958 SDL_modelist[i] = (SDL_Rect **) | 981 for (i = 0; i < NUM_MODELISTS; ++i) { |
959 SDL_malloc((SDL_nummodes[i]+1)*sizeof(SDL_Rect *)); | 982 struct DX5EnumRect *rect; |
960 if ( SDL_modelist[i] == NULL ) { | 983 SDL_modelist[i] = (SDL_Rect **) |
961 SDL_OutOfMemory(); | 984 SDL_malloc((SDL_nummodes[i] + 1) * sizeof(SDL_Rect *)); |
962 return(-1); | 985 if (SDL_modelist[i] == NULL) { |
963 } | 986 SDL_OutOfMemory(); |
964 for ( j = 0, rect = enumlists[i]; rect; ++j, rect = rect->next ) { | 987 return (-1); |
965 SDL_modelist[i][j] = &rect->r; | 988 } |
966 } | 989 for (j = 0, rect = enumlists[i]; rect; ++j, rect = rect->next) { |
967 SDL_modelist[i][j] = NULL; | 990 SDL_modelist[i][j] = &rect->r; |
968 | 991 } |
969 if ( SDL_nummodes[i] > 0 ) { | 992 SDL_modelist[i][j] = NULL; |
970 SDL_qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes); | 993 |
971 } | 994 if (SDL_nummodes[i] > 0) { |
972 } | 995 SDL_qsort(SDL_modelist[i], SDL_nummodes[i], |
973 | 996 sizeof *SDL_modelist[i], cmpmodes); |
974 /* Fill in some window manager capabilities */ | 997 } |
975 this->info.wm_available = 1; | 998 } |
976 | 999 |
977 /* Fill in the video hardware capabilities */ | 1000 /* Fill in some window manager capabilities */ |
978 DX5_UpdateVideoInfo(this); | 1001 this->info.wm_available = 1; |
979 | 1002 |
980 return(0); | 1003 /* Fill in the video hardware capabilities */ |
981 } | 1004 DX5_UpdateVideoInfo(this); |
982 | 1005 |
983 SDL_Rect **DX5_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | 1006 return (0); |
984 { | 1007 } |
985 int bpp; | 1008 |
986 | 1009 SDL_Rect ** |
987 bpp = format->BitsPerPixel; | 1010 DX5_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) |
988 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | 1011 { |
989 /* FIXME: No support for 1 bpp or 4 bpp formats */ | 1012 int bpp; |
990 switch (bpp) { /* Does windows support other BPP? */ | 1013 |
991 case 8: | 1014 bpp = format->BitsPerPixel; |
992 case 16: | 1015 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
993 case 24: | 1016 /* FIXME: No support for 1 bpp or 4 bpp formats */ |
994 case 32: | 1017 switch (bpp) { /* Does windows support other BPP? */ |
995 bpp = (bpp/8)-1; | 1018 case 8: |
996 if ( SDL_nummodes[bpp] > 0 ) | 1019 case 16: |
997 return(SDL_modelist[bpp]); | 1020 case 24: |
998 /* Fall through */ | 1021 case 32: |
999 default: | 1022 bpp = (bpp / 8) - 1; |
1000 return((SDL_Rect **)0); | 1023 if (SDL_nummodes[bpp] > 0) |
1001 } | 1024 return (SDL_modelist[bpp]); |
1002 } else { | 1025 /* Fall through */ |
1003 if ( this->screen->format->BitsPerPixel == bpp ) { | 1026 default: |
1004 return((SDL_Rect **)-1); | 1027 return ((SDL_Rect **) 0); |
1005 } else { | 1028 } |
1006 return((SDL_Rect **)0); | 1029 } else { |
1007 } | 1030 if (this->screen->format->BitsPerPixel == bpp) { |
1008 } | 1031 return ((SDL_Rect **) - 1); |
1032 } else { | |
1033 return ((SDL_Rect **) 0); | |
1034 } | |
1035 } | |
1009 } | 1036 } |
1010 | 1037 |
1011 /* Various screen update functions available */ | 1038 /* Various screen update functions available */ |
1012 static void DX5_WindowUpdate(_THIS, int numrects, SDL_Rect *rects); | 1039 static void DX5_WindowUpdate(_THIS, int numrects, SDL_Rect * rects); |
1013 static void DX5_DirectUpdate(_THIS, int numrects, SDL_Rect *rects); | 1040 static void DX5_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); |
1014 | 1041 |
1015 SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, | 1042 SDL_Surface * |
1016 int width, int height, int bpp, Uint32 flags) | 1043 DX5_SetVideoMode(_THIS, SDL_Surface * current, |
1017 { | 1044 int width, int height, int bpp, Uint32 flags) |
1018 SDL_Surface *video; | 1045 { |
1019 HRESULT result; | 1046 SDL_Surface *video; |
1020 DWORD sharemode; | 1047 HRESULT result; |
1021 DWORD style; | 1048 DWORD sharemode; |
1022 const DWORD directstyle = | 1049 DWORD style; |
1023 (WS_POPUP); | 1050 const DWORD directstyle = (WS_POPUP); |
1024 const DWORD windowstyle = | 1051 const DWORD windowstyle = |
1025 (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX); | 1052 (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX); |
1026 const DWORD resizestyle = | 1053 const DWORD resizestyle = (WS_THICKFRAME | WS_MAXIMIZEBOX); |
1027 (WS_THICKFRAME|WS_MAXIMIZEBOX); | 1054 DDSURFACEDESC ddsd; |
1028 DDSURFACEDESC ddsd; | 1055 LPDIRECTDRAWSURFACE dd_surface1; |
1029 LPDIRECTDRAWSURFACE dd_surface1; | 1056 LPDIRECTDRAWSURFACE3 dd_surface3; |
1030 LPDIRECTDRAWSURFACE3 dd_surface3; | 1057 |
1031 | 1058 SDL_resizing = 1; |
1032 SDL_resizing = 1; | |
1033 #ifdef DDRAW_DEBUG | 1059 #ifdef DDRAW_DEBUG |
1034 fprintf(stderr, "Setting %dx%dx%d video mode\n", width, height, bpp); | 1060 fprintf(stderr, "Setting %dx%dx%d video mode\n", width, height, bpp); |
1035 #endif | 1061 #endif |
1036 /* Clean up any previous DirectDraw surfaces */ | 1062 /* Clean up any previous DirectDraw surfaces */ |
1037 if ( current->hwdata ) { | 1063 if (current->hwdata) { |
1038 this->FreeHWSurface(this, current); | 1064 this->FreeHWSurface(this, current); |
1039 current->hwdata = NULL; | 1065 current->hwdata = NULL; |
1040 } | 1066 } |
1041 if ( SDL_primary != NULL ) { | 1067 if (SDL_primary != NULL) { |
1042 IDirectDrawSurface3_Release(SDL_primary); | 1068 IDirectDrawSurface3_Release(SDL_primary); |
1043 SDL_primary = NULL; | 1069 SDL_primary = NULL; |
1044 } | 1070 } |
1045 | |
1046 #ifndef NO_CHANGEDISPLAYSETTINGS | 1071 #ifndef NO_CHANGEDISPLAYSETTINGS |
1047 /* Unset any previous OpenGL fullscreen mode */ | 1072 /* Unset any previous OpenGL fullscreen mode */ |
1048 if ( (current->flags & (SDL_OPENGL|SDL_FULLSCREEN)) == | 1073 if ((current->flags & (SDL_INTERNALOPENGL | SDL_FULLSCREEN)) == |
1049 (SDL_OPENGL|SDL_FULLSCREEN) ) { | 1074 (SDL_INTERNALOPENGL | SDL_FULLSCREEN)) { |
1050 ChangeDisplaySettings(NULL, 0); | 1075 ChangeDisplaySettings(NULL, 0); |
1051 } | 1076 } |
1052 #endif | 1077 #endif |
1053 | 1078 |
1054 /* Clean up any GL context that may be hanging around */ | 1079 /* Clean up any GL context that may be hanging around */ |
1055 if ( current->flags & SDL_OPENGL ) { | 1080 if (current->flags & SDL_INTERNALOPENGL) { |
1056 WIN_GL_ShutDown(this); | 1081 WIN_GL_ShutDown(this); |
1057 } | 1082 } |
1058 | 1083 |
1059 /* If we are setting a GL mode, use GDI, not DirectX (yuck) */ | 1084 /* If we are setting a GL mode, use GDI, not DirectX (yuck) */ |
1060 if ( flags & SDL_OPENGL ) { | 1085 if (flags & SDL_INTERNALOPENGL) { |
1061 Uint32 Rmask, Gmask, Bmask; | 1086 Uint32 Rmask, Gmask, Bmask; |
1062 | 1087 |
1063 /* Recalculate the bitmasks if necessary */ | 1088 /* Recalculate the bitmasks if necessary */ |
1064 if ( bpp == current->format->BitsPerPixel ) { | 1089 if (bpp == current->format->BitsPerPixel) { |
1065 video = current; | 1090 video = current; |
1066 } else { | 1091 } else { |
1067 switch (bpp) { | 1092 switch (bpp) { |
1068 case 15: | 1093 case 15: |
1069 case 16: | 1094 case 16: |
1070 if ( 0 /*DIB_SussScreenDepth() == 15*/ ) { | 1095 if (0 /*DIB_SussScreenDepth() == 15 */ ) { |
1071 /* 5-5-5 */ | 1096 /* 5-5-5 */ |
1072 Rmask = 0x00007c00; | 1097 Rmask = 0x00007c00; |
1073 Gmask = 0x000003e0; | 1098 Gmask = 0x000003e0; |
1074 Bmask = 0x0000001f; | 1099 Bmask = 0x0000001f; |
1075 } else { | 1100 } else { |
1076 /* 5-6-5 */ | 1101 /* 5-6-5 */ |
1077 Rmask = 0x0000f800; | 1102 Rmask = 0x0000f800; |
1078 Gmask = 0x000007e0; | 1103 Gmask = 0x000007e0; |
1079 Bmask = 0x0000001f; | 1104 Bmask = 0x0000001f; |
1080 } | 1105 } |
1081 break; | 1106 break; |
1082 case 24: | 1107 case 24: |
1083 case 32: | 1108 case 32: |
1084 /* GDI defined as 8-8-8 */ | 1109 /* GDI defined as 8-8-8 */ |
1085 Rmask = 0x00ff0000; | 1110 Rmask = 0x00ff0000; |
1086 Gmask = 0x0000ff00; | 1111 Gmask = 0x0000ff00; |
1087 Bmask = 0x000000ff; | 1112 Bmask = 0x000000ff; |
1088 break; | 1113 break; |
1089 default: | 1114 default: |
1090 Rmask = 0x00000000; | 1115 Rmask = 0x00000000; |
1091 Gmask = 0x00000000; | 1116 Gmask = 0x00000000; |
1092 Bmask = 0x00000000; | 1117 Bmask = 0x00000000; |
1093 break; | 1118 break; |
1094 } | 1119 } |
1095 video = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, bpp, | 1120 video = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, bpp, |
1096 Rmask, Gmask, Bmask, 0); | 1121 Rmask, Gmask, Bmask, 0); |
1097 if ( video == NULL ) { | 1122 if (video == NULL) { |
1098 SDL_OutOfMemory(); | 1123 SDL_OutOfMemory(); |
1099 return(NULL); | 1124 return (NULL); |
1100 } | 1125 } |
1101 } | 1126 } |
1102 | 1127 |
1103 /* Fill in part of the video surface */ | 1128 /* Fill in part of the video surface */ |
1104 video->flags = 0; /* Clear flags */ | 1129 video->flags = 0; /* Clear flags */ |
1105 video->w = width; | 1130 video->w = width; |
1106 video->h = height; | 1131 video->h = height; |
1107 video->pitch = SDL_CalculatePitch(video); | 1132 video->pitch = SDL_CalculatePitch(video); |
1108 | 1133 |
1109 #ifndef NO_CHANGEDISPLAYSETTINGS | 1134 #ifndef NO_CHANGEDISPLAYSETTINGS |
1110 /* Set fullscreen mode if appropriate. | 1135 /* Set fullscreen mode if appropriate. |
1111 Ugh, since our list of valid video modes comes from | 1136 Ugh, since our list of valid video modes comes from |
1112 the DirectX driver, we may not actually be able to | 1137 the DirectX driver, we may not actually be able to |
1113 change to the desired resolution here. | 1138 change to the desired resolution here. |
1114 FIXME: Should we do a closest match? | 1139 FIXME: Should we do a closest match? |
1115 */ | 1140 */ |
1116 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | 1141 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
1117 DEVMODE settings; | 1142 DEVMODE settings; |
1118 BOOL changed; | 1143 BOOL changed; |
1119 | 1144 |
1120 SDL_memset(&settings, 0, sizeof(DEVMODE)); | 1145 SDL_memset(&settings, 0, sizeof(DEVMODE)); |
1121 settings.dmSize = sizeof(DEVMODE); | 1146 settings.dmSize = sizeof(DEVMODE); |
1122 settings.dmBitsPerPel = video->format->BitsPerPixel; | 1147 settings.dmBitsPerPel = video->format->BitsPerPixel; |
1123 settings.dmPelsWidth = width; | 1148 settings.dmPelsWidth = width; |
1124 settings.dmPelsHeight = height; | 1149 settings.dmPelsHeight = height; |
1125 settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; | 1150 settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; |
1126 if ( width <= (int)SDL_desktop_mode.dmPelsWidth && | 1151 if (width <= (int) SDL_desktop_mode.dmPelsWidth |
1127 height <= (int)SDL_desktop_mode.dmPelsHeight ) { | 1152 && height <= (int) SDL_desktop_mode.dmPelsHeight) { |
1128 settings.dmDisplayFrequency = SDL_desktop_mode.dmDisplayFrequency; | 1153 settings.dmDisplayFrequency = |
1129 settings.dmFields |= DM_DISPLAYFREQUENCY; | 1154 SDL_desktop_mode.dmDisplayFrequency; |
1130 } | 1155 settings.dmFields |= DM_DISPLAYFREQUENCY; |
1131 changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL); | 1156 } |
1132 if ( ! changed && (settings.dmFields & DM_DISPLAYFREQUENCY) ) { | 1157 changed = |
1133 settings.dmFields &= ~DM_DISPLAYFREQUENCY; | 1158 (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == |
1134 changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL); | 1159 DISP_CHANGE_SUCCESSFUL); |
1135 } | 1160 if (!changed && (settings.dmFields & DM_DISPLAYFREQUENCY)) { |
1136 if ( changed ) { | 1161 settings.dmFields &= ~DM_DISPLAYFREQUENCY; |
1137 video->flags |= SDL_FULLSCREEN; | 1162 changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) |
1138 SDL_fullscreen_mode = settings; | 1163 == DISP_CHANGE_SUCCESSFUL); |
1139 } | 1164 } |
1140 } | 1165 if (changed) { |
1166 video->flags |= SDL_FULLSCREEN; | |
1167 SDL_fullscreen_mode = settings; | |
1168 } | |
1169 } | |
1141 #endif /* !NO_CHANGEDISPLAYSETTINGS */ | 1170 #endif /* !NO_CHANGEDISPLAYSETTINGS */ |
1142 | 1171 |
1143 style = GetWindowLong(SDL_Window, GWL_STYLE); | 1172 style = GetWindowLong(SDL_Window, GWL_STYLE); |
1144 style &= ~(resizestyle|WS_MAXIMIZE); | 1173 style &= ~(resizestyle | WS_MAXIMIZE); |
1145 if ( video->flags & SDL_FULLSCREEN ) { | 1174 if (video->flags & SDL_FULLSCREEN) { |
1146 style &= ~windowstyle; | 1175 style &= ~windowstyle; |
1147 style |= directstyle; | 1176 style |= directstyle; |
1148 } else { | 1177 } else { |
1149 if ( flags & SDL_NOFRAME ) { | 1178 if (flags & SDL_NOFRAME) { |
1150 style &= ~windowstyle; | 1179 style &= ~windowstyle; |
1151 style |= directstyle; | 1180 style |= directstyle; |
1152 video->flags |= SDL_NOFRAME; | 1181 video->flags |= SDL_NOFRAME; |
1153 } else { | 1182 } else { |
1154 style &= ~directstyle; | 1183 style &= ~directstyle; |
1155 style |= windowstyle; | 1184 style |= windowstyle; |
1156 if ( flags & SDL_RESIZABLE ) { | 1185 if (flags & SDL_RESIZABLE) { |
1157 style |= resizestyle; | 1186 style |= resizestyle; |
1158 video->flags |= SDL_RESIZABLE; | 1187 video->flags |= SDL_RESIZABLE; |
1159 } | 1188 } |
1160 } | 1189 } |
1161 #if WS_MAXIMIZE | 1190 #if WS_MAXIMIZE |
1162 if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; | 1191 if (IsZoomed(SDL_Window)) |
1163 #endif | 1192 style |= WS_MAXIMIZE; |
1164 } | 1193 #endif |
1165 | 1194 } |
1166 /* DJM: Don't piss of anyone who has setup his own window */ | 1195 |
1167 if ( !SDL_windowid ) | 1196 /* DJM: Don't piss of anyone who has setup his own window */ |
1168 SetWindowLong(SDL_Window, GWL_STYLE, style); | 1197 if (!SDL_windowid) |
1169 | 1198 SetWindowLong(SDL_Window, GWL_STYLE, style); |
1170 /* Resize the window (copied from SDL WinDIB driver) */ | 1199 |
1171 if ( !SDL_windowid && !IsZoomed(SDL_Window) ) { | 1200 /* Resize the window (copied from SDL WinDIB driver) */ |
1172 RECT bounds; | 1201 if (!SDL_windowid && !IsZoomed(SDL_Window)) { |
1173 int x, y; | 1202 RECT bounds; |
1174 HWND top; | 1203 int x, y; |
1175 UINT swp_flags; | 1204 HWND top; |
1176 const char *window = NULL; | 1205 UINT swp_flags; |
1177 const char *center = NULL; | 1206 const char *window = NULL; |
1178 | 1207 const char *center = NULL; |
1179 if ( !SDL_windowX && !SDL_windowY ) { | 1208 |
1180 window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); | 1209 if (!SDL_windowX && !SDL_windowY) { |
1181 center = SDL_getenv("SDL_VIDEO_CENTERED"); | 1210 window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); |
1182 if ( window ) { | 1211 center = SDL_getenv("SDL_VIDEO_CENTERED"); |
1183 if ( SDL_sscanf(window, "%d,%d", &x, &y) == 2 ) { | 1212 if (window) { |
1184 SDL_windowX = x; | 1213 if (SDL_sscanf(window, "%d,%d", &x, &y) == 2) { |
1185 SDL_windowY = y; | 1214 SDL_windowX = x; |
1186 } | 1215 SDL_windowY = y; |
1187 if ( SDL_strcmp(window, "center") == 0 ) { | 1216 } |
1188 center = window; | 1217 if (SDL_strcmp(window, "center") == 0) { |
1189 } | 1218 center = window; |
1190 } | 1219 } |
1191 } | 1220 } |
1192 swp_flags = (SWP_NOCOPYBITS | SWP_SHOWWINDOW); | 1221 } |
1193 | 1222 swp_flags = (SWP_NOCOPYBITS | SWP_SHOWWINDOW); |
1194 bounds.left = SDL_windowX; | 1223 |
1195 bounds.top = SDL_windowY; | 1224 bounds.left = SDL_windowX; |
1196 bounds.right = SDL_windowX+video->w; | 1225 bounds.top = SDL_windowY; |
1197 bounds.bottom = SDL_windowY+video->h; | 1226 bounds.right = SDL_windowX + video->w; |
1198 AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), (GetMenu(SDL_Window) != NULL), 0); | 1227 bounds.bottom = SDL_windowY + video->h; |
1199 width = bounds.right-bounds.left; | 1228 AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), |
1200 height = bounds.bottom-bounds.top; | 1229 (GetMenu(SDL_Window) != NULL), 0); |
1201 if ( (flags & SDL_FULLSCREEN) ) { | 1230 width = bounds.right - bounds.left; |
1202 x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; | 1231 height = bounds.bottom - bounds.top; |
1203 y = (GetSystemMetrics(SM_CYSCREEN)-height)/2; | 1232 if ((flags & SDL_FULLSCREEN)) { |
1204 } else if ( center ) { | 1233 x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2; |
1205 x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; | 1234 y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2; |
1206 y = (GetSystemMetrics(SM_CYSCREEN)-height)/2; | 1235 } else if (center) { |
1207 } else if ( SDL_windowX || SDL_windowY || window ) { | 1236 x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2; |
1208 x = bounds.left; | 1237 y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2; |
1209 y = bounds.top; | 1238 } else if (SDL_windowX || SDL_windowY || window) { |
1210 } else { | 1239 x = bounds.left; |
1211 x = y = -1; | 1240 y = bounds.top; |
1212 swp_flags |= SWP_NOMOVE; | 1241 } else { |
1213 } | 1242 x = y = -1; |
1214 if ( flags & SDL_FULLSCREEN ) { | 1243 swp_flags |= SWP_NOMOVE; |
1215 top = HWND_TOPMOST; | 1244 } |
1216 } else { | 1245 if (flags & SDL_FULLSCREEN) { |
1217 top = HWND_NOTOPMOST; | 1246 top = HWND_TOPMOST; |
1218 } | 1247 } else { |
1219 SetWindowPos(SDL_Window, top, x, y, width, height, swp_flags); | 1248 top = HWND_NOTOPMOST; |
1220 if ( !(flags & SDL_FULLSCREEN) ) { | 1249 } |
1221 SDL_windowX = SDL_bounds.left; | 1250 SetWindowPos(SDL_Window, top, x, y, width, height, swp_flags); |
1222 SDL_windowY = SDL_bounds.top; | 1251 if (!(flags & SDL_FULLSCREEN)) { |
1223 } | 1252 SDL_windowX = SDL_bounds.left; |
1224 SetForegroundWindow(SDL_Window); | 1253 SDL_windowY = SDL_bounds.top; |
1225 } | 1254 } |
1226 SDL_resizing = 0; | 1255 SetForegroundWindow(SDL_Window); |
1227 | 1256 } |
1228 /* Set up for OpenGL */ | 1257 SDL_resizing = 0; |
1229 if ( WIN_GL_SetupWindow(this) < 0 ) { | 1258 |
1230 return(NULL); | 1259 /* Set up for OpenGL */ |
1231 } | 1260 if (WIN_GL_SetupWindow(this) < 0) { |
1232 video->flags |= SDL_OPENGL; | 1261 return (NULL); |
1233 return(video); | 1262 } |
1234 } | 1263 video->flags |= SDL_INTERNALOPENGL; |
1235 | 1264 return (video); |
1236 /* Set the appropriate window style */ | 1265 } |
1237 style = GetWindowLong(SDL_Window, GWL_STYLE); | 1266 |
1238 style &= ~(resizestyle|WS_MAXIMIZE); | 1267 /* Set the appropriate window style */ |
1239 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | 1268 style = GetWindowLong(SDL_Window, GWL_STYLE); |
1240 style &= ~windowstyle; | 1269 style &= ~(resizestyle | WS_MAXIMIZE); |
1241 style |= directstyle; | 1270 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
1242 } else { | 1271 style &= ~windowstyle; |
1243 if ( flags & SDL_NOFRAME ) { | 1272 style |= directstyle; |
1244 style &= ~windowstyle; | 1273 } else { |
1245 style |= directstyle; | 1274 if (flags & SDL_NOFRAME) { |
1246 } else { | 1275 style &= ~windowstyle; |
1247 style &= ~directstyle; | 1276 style |= directstyle; |
1248 style |= windowstyle; | 1277 } else { |
1249 if ( flags & SDL_RESIZABLE ) { | 1278 style &= ~directstyle; |
1250 style |= resizestyle; | 1279 style |= windowstyle; |
1251 } | 1280 if (flags & SDL_RESIZABLE) { |
1252 } | 1281 style |= resizestyle; |
1282 } | |
1283 } | |
1253 #if WS_MAXIMIZE | 1284 #if WS_MAXIMIZE |
1254 if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; | 1285 if (IsZoomed(SDL_Window)) |
1255 #endif | 1286 style |= WS_MAXIMIZE; |
1256 } | 1287 #endif |
1257 /* DJM: Don't piss of anyone who has setup his own window */ | 1288 } |
1258 if ( !SDL_windowid ) | 1289 /* DJM: Don't piss of anyone who has setup his own window */ |
1259 SetWindowLong(SDL_Window, GWL_STYLE, style); | 1290 if (!SDL_windowid) |
1260 | 1291 SetWindowLong(SDL_Window, GWL_STYLE, style); |
1261 /* Set DirectDraw sharing mode.. exclusive when fullscreen */ | 1292 |
1262 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | 1293 /* Set DirectDraw sharing mode.. exclusive when fullscreen */ |
1263 sharemode = DDSCL_FULLSCREEN|DDSCL_EXCLUSIVE|DDSCL_ALLOWREBOOT; | 1294 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
1264 } else { | 1295 sharemode = DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT; |
1265 sharemode = DDSCL_NORMAL; | 1296 } else { |
1266 } | 1297 sharemode = DDSCL_NORMAL; |
1267 result = IDirectDraw2_SetCooperativeLevel(ddraw2,SDL_Window,sharemode); | 1298 } |
1268 if ( result != DD_OK ) { | 1299 result = IDirectDraw2_SetCooperativeLevel(ddraw2, SDL_Window, sharemode); |
1269 SetDDerror("DirectDraw2::SetCooperativeLevel", result); | 1300 if (result != DD_OK) { |
1270 return(NULL); | 1301 SetDDerror("DirectDraw2::SetCooperativeLevel", result); |
1271 } | 1302 return (NULL); |
1272 | 1303 } |
1273 /* Set the display mode, if we are in fullscreen mode */ | 1304 |
1274 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | 1305 /* Set the display mode, if we are in fullscreen mode */ |
1275 RECT bounds; | 1306 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
1276 struct DX5EnumRect *rect; | 1307 RECT bounds; |
1277 int maxRefreshRate; | 1308 struct DX5EnumRect *rect; |
1278 | 1309 int maxRefreshRate; |
1279 /* Cover up desktop during mode change */ | 1310 |
1280 bounds.left = 0; | 1311 /* Cover up desktop during mode change */ |
1281 bounds.top = 0; | 1312 bounds.left = 0; |
1282 bounds.right = GetSystemMetrics(SM_CXSCREEN); | 1313 bounds.top = 0; |
1283 bounds.bottom = GetSystemMetrics(SM_CYSCREEN); | 1314 bounds.right = GetSystemMetrics(SM_CXSCREEN); |
1284 AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), (GetMenu(SDL_Window) != NULL), 0); | 1315 bounds.bottom = GetSystemMetrics(SM_CYSCREEN); |
1285 SetWindowPos(SDL_Window, HWND_TOPMOST, | 1316 AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), |
1286 bounds.left, bounds.top, | 1317 (GetMenu(SDL_Window) != NULL), 0); |
1287 bounds.right - bounds.left, | 1318 SetWindowPos(SDL_Window, HWND_TOPMOST, bounds.left, bounds.top, |
1288 bounds.bottom - bounds.top, SWP_NOCOPYBITS); | 1319 bounds.right - bounds.left, bounds.bottom - bounds.top, |
1289 ShowWindow(SDL_Window, SW_SHOW); | 1320 SWP_NOCOPYBITS); |
1290 while ( GetForegroundWindow() != SDL_Window ) { | 1321 ShowWindow(SDL_Window, SW_SHOW); |
1291 SetForegroundWindow(SDL_Window); | 1322 while (GetForegroundWindow() != SDL_Window) { |
1292 SDL_Delay(100); | 1323 SetForegroundWindow(SDL_Window); |
1293 } | 1324 SDL_Delay(100); |
1294 | 1325 } |
1295 /* find maximum monitor refresh rate for this resolution */ | 1326 |
1296 /* Dmitry Yakimov ftech@tula.net */ | 1327 /* find maximum monitor refresh rate for this resolution */ |
1297 maxRefreshRate = 0; /* system default */ | 1328 /* Dmitry Yakimov ftech@tula.net */ |
1298 for ( rect = enumlists[bpp / 8 - 1]; rect; rect = rect->next ) { | 1329 maxRefreshRate = 0; /* system default */ |
1299 if ( (width == rect->r.w) && (height == rect->r.h) ) { | 1330 for (rect = enumlists[bpp / 8 - 1]; rect; rect = rect->next) { |
1300 maxRefreshRate = rect->refreshRate; | 1331 if ((width == rect->r.w) && (height == rect->r.h)) { |
1301 break; | 1332 maxRefreshRate = rect->refreshRate; |
1302 } | 1333 break; |
1303 } | 1334 } |
1335 } | |
1304 #ifdef DDRAW_DEBUG | 1336 #ifdef DDRAW_DEBUG |
1305 fprintf(stderr, "refresh rate = %d Hz\n", maxRefreshRate); | 1337 fprintf(stderr, "refresh rate = %d Hz\n", maxRefreshRate); |
1306 #endif | 1338 #endif |
1307 | 1339 |
1308 result = IDirectDraw2_SetDisplayMode(ddraw2, width, height, bpp, maxRefreshRate, 0); | 1340 result = |
1309 if ( result != DD_OK ) { | 1341 IDirectDraw2_SetDisplayMode(ddraw2, width, height, bpp, |
1310 result = IDirectDraw2_SetDisplayMode(ddraw2, width, height, bpp, 0, 0); | 1342 maxRefreshRate, 0); |
1311 if ( result != DD_OK ) { | 1343 if (result != DD_OK) { |
1312 /* We couldn't set fullscreen mode, try window */ | 1344 result = |
1313 return(DX5_SetVideoMode(this, current, width, height, bpp, flags & ~SDL_FULLSCREEN)); | 1345 IDirectDraw2_SetDisplayMode(ddraw2, width, height, bpp, 0, 0); |
1314 } | 1346 if (result != DD_OK) { |
1315 } | 1347 /* We couldn't set fullscreen mode, try window */ |
1316 DX5_DInputReset(this, 1); | 1348 return (DX5_SetVideoMode |
1317 } else { | 1349 (this, current, width, height, bpp, |
1318 DX5_DInputReset(this, 0); | 1350 flags & ~SDL_FULLSCREEN)); |
1319 } | 1351 } |
1320 DX5_UpdateVideoInfo(this); | 1352 } |
1321 | 1353 DX5_DInputReset(this, 1); |
1322 /* Create a primary DirectDraw surface */ | 1354 } else { |
1323 SDL_memset(&ddsd, 0, sizeof(ddsd)); | 1355 DX5_DInputReset(this, 0); |
1324 ddsd.dwSize = sizeof(ddsd); | 1356 } |
1325 ddsd.dwFlags = DDSD_CAPS; | 1357 DX5_UpdateVideoInfo(this); |
1326 ddsd.ddsCaps.dwCaps = (DDSCAPS_PRIMARYSURFACE|DDSCAPS_VIDEOMEMORY); | 1358 |
1327 if ( (flags & SDL_FULLSCREEN) != SDL_FULLSCREEN ) { | 1359 /* Create a primary DirectDraw surface */ |
1328 /* There's no windowed double-buffering */ | 1360 SDL_memset(&ddsd, 0, sizeof(ddsd)); |
1329 flags &= ~SDL_DOUBLEBUF; | 1361 ddsd.dwSize = sizeof(ddsd); |
1330 } | 1362 ddsd.dwFlags = DDSD_CAPS; |
1331 if ( (flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) { | 1363 ddsd.ddsCaps.dwCaps = (DDSCAPS_PRIMARYSURFACE | DDSCAPS_VIDEOMEMORY); |
1332 ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT; | 1364 if ((flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) { |
1333 ddsd.ddsCaps.dwCaps |= (DDSCAPS_COMPLEX|DDSCAPS_FLIP); | 1365 /* There's no windowed double-buffering */ |
1334 ddsd.dwBackBufferCount = 1; | 1366 flags &= ~SDL_DOUBLEBUF; |
1335 } | 1367 } |
1336 result = IDirectDraw2_CreateSurface(ddraw2, &ddsd, &dd_surface1, NULL); | 1368 if ((flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { |
1337 if ( (result != DD_OK) && ((flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) ) { | 1369 ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT; |
1338 ddsd.dwFlags &= ~DDSD_BACKBUFFERCOUNT; | 1370 ddsd.ddsCaps.dwCaps |= (DDSCAPS_COMPLEX | DDSCAPS_FLIP); |
1339 ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_COMPLEX|DDSCAPS_FLIP); | 1371 ddsd.dwBackBufferCount = 1; |
1340 ddsd.dwBackBufferCount = 0; | 1372 } |
1341 result = IDirectDraw2_CreateSurface(ddraw2, | 1373 result = IDirectDraw2_CreateSurface(ddraw2, &ddsd, &dd_surface1, NULL); |
1342 &ddsd, &dd_surface1, NULL); | 1374 if ((result != DD_OK) && ((flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF)) { |
1343 } | 1375 ddsd.dwFlags &= ~DDSD_BACKBUFFERCOUNT; |
1344 if ( result != DD_OK ) { | 1376 ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_COMPLEX | DDSCAPS_FLIP); |
1345 SetDDerror("DirectDraw2::CreateSurface(PRIMARY)", result); | 1377 ddsd.dwBackBufferCount = 0; |
1346 return(NULL); | 1378 result = IDirectDraw2_CreateSurface(ddraw2, |
1347 } | 1379 &ddsd, &dd_surface1, NULL); |
1348 result = IDirectDrawSurface_QueryInterface(dd_surface1, | 1380 } |
1349 &IID_IDirectDrawSurface3, (LPVOID *)&SDL_primary); | 1381 if (result != DD_OK) { |
1350 if ( result != DD_OK ) { | 1382 SetDDerror("DirectDraw2::CreateSurface(PRIMARY)", result); |
1351 SetDDerror("DirectDrawSurface::QueryInterface", result); | 1383 return (NULL); |
1352 return(NULL); | 1384 } |
1353 } | 1385 result = IDirectDrawSurface_QueryInterface(dd_surface1, |
1354 IDirectDrawSurface_Release(dd_surface1); | 1386 &IID_IDirectDrawSurface3, |
1355 | 1387 (LPVOID *) & SDL_primary); |
1356 /* Get the format of the primary DirectDraw surface */ | 1388 if (result != DD_OK) { |
1357 SDL_memset(&ddsd, 0, sizeof(ddsd)); | 1389 SetDDerror("DirectDrawSurface::QueryInterface", result); |
1358 ddsd.dwSize = sizeof(ddsd); | 1390 return (NULL); |
1359 ddsd.dwFlags = DDSD_PIXELFORMAT|DDSD_CAPS; | 1391 } |
1360 result = IDirectDrawSurface3_GetSurfaceDesc(SDL_primary, &ddsd); | 1392 IDirectDrawSurface_Release(dd_surface1); |
1361 if ( result != DD_OK ) { | 1393 |
1362 SetDDerror("DirectDrawSurface::GetSurfaceDesc", result); | 1394 /* Get the format of the primary DirectDraw surface */ |
1363 return(NULL); | 1395 SDL_memset(&ddsd, 0, sizeof(ddsd)); |
1364 } | 1396 ddsd.dwSize = sizeof(ddsd); |
1365 if ( ! (ddsd.ddpfPixelFormat.dwFlags&DDPF_RGB) ) { | 1397 ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_CAPS; |
1366 SDL_SetError("Primary DDRAW surface is not RGB format"); | 1398 result = IDirectDrawSurface3_GetSurfaceDesc(SDL_primary, &ddsd); |
1367 return(NULL); | 1399 if (result != DD_OK) { |
1368 } | 1400 SetDDerror("DirectDrawSurface::GetSurfaceDesc", result); |
1369 | 1401 return (NULL); |
1370 /* Free old palette and create a new one if we're in 8-bit mode */ | 1402 } |
1371 if ( SDL_palette != NULL ) { | 1403 if (!(ddsd.ddpfPixelFormat.dwFlags & DDPF_RGB)) { |
1372 IDirectDrawPalette_Release(SDL_palette); | 1404 SDL_SetError("Primary DDRAW surface is not RGB format"); |
1373 SDL_palette = NULL; | 1405 return (NULL); |
1374 } | 1406 } |
1407 | |
1408 /* Free old palette and create a new one if we're in 8-bit mode */ | |
1409 if (SDL_palette != NULL) { | |
1410 IDirectDrawPalette_Release(SDL_palette); | |
1411 SDL_palette = NULL; | |
1412 } | |
1375 #if defined(NONAMELESSUNION) | 1413 #if defined(NONAMELESSUNION) |
1376 if ( ddsd.ddpfPixelFormat.u1.dwRGBBitCount == 8 ) { | 1414 if (ddsd.ddpfPixelFormat.u1.dwRGBBitCount == 8) { |
1377 #else | 1415 #else |
1378 if ( ddsd.ddpfPixelFormat.dwRGBBitCount == 8 ) { | 1416 if (ddsd.ddpfPixelFormat.dwRGBBitCount == 8) { |
1379 #endif | 1417 #endif |
1380 int i; | 1418 int i; |
1381 | 1419 |
1382 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | 1420 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
1383 /* We have access to the entire palette */ | 1421 /* We have access to the entire palette */ |
1384 for ( i=0; i<256; ++i ) { | 1422 for (i = 0; i < 256; ++i) { |
1385 SDL_colors[i].peFlags = | 1423 SDL_colors[i].peFlags = (PC_NOCOLLAPSE | PC_RESERVED); |
1386 (PC_NOCOLLAPSE|PC_RESERVED); | 1424 SDL_colors[i].peRed = 0; |
1387 SDL_colors[i].peRed = 0; | 1425 SDL_colors[i].peGreen = 0; |
1388 SDL_colors[i].peGreen = 0; | 1426 SDL_colors[i].peBlue = 0; |
1389 SDL_colors[i].peBlue = 0; | 1427 } |
1390 } | 1428 } else { |
1391 } else { | 1429 /* First 10 colors are reserved by Windows */ |
1392 /* First 10 colors are reserved by Windows */ | 1430 for (i = 0; i < 10; ++i) { |
1393 for ( i=0; i<10; ++i ) { | 1431 SDL_colors[i].peFlags = PC_EXPLICIT; |
1394 SDL_colors[i].peFlags = PC_EXPLICIT; | 1432 SDL_colors[i].peRed = i; |
1395 SDL_colors[i].peRed = i; | 1433 SDL_colors[i].peGreen = 0; |
1396 SDL_colors[i].peGreen = 0; | 1434 SDL_colors[i].peBlue = 0; |
1397 SDL_colors[i].peBlue = 0; | 1435 } |
1398 } | 1436 for (i = 10; i < (10 + 236); ++i) { |
1399 for ( i=10; i<(10+236); ++i ) { | 1437 SDL_colors[i].peFlags = PC_NOCOLLAPSE; |
1400 SDL_colors[i].peFlags = PC_NOCOLLAPSE; | 1438 SDL_colors[i].peRed = 0; |
1401 SDL_colors[i].peRed = 0; | 1439 SDL_colors[i].peGreen = 0; |
1402 SDL_colors[i].peGreen = 0; | 1440 SDL_colors[i].peBlue = 0; |
1403 SDL_colors[i].peBlue = 0; | 1441 } |
1404 } | 1442 /* Last 10 colors are reserved by Windows */ |
1405 /* Last 10 colors are reserved by Windows */ | 1443 for (i = 246; i < 256; ++i) { |
1406 for ( i=246; i<256; ++i ) { | 1444 SDL_colors[i].peFlags = PC_EXPLICIT; |
1407 SDL_colors[i].peFlags = PC_EXPLICIT; | 1445 SDL_colors[i].peRed = i; |
1408 SDL_colors[i].peRed = i; | 1446 SDL_colors[i].peGreen = 0; |
1409 SDL_colors[i].peGreen = 0; | 1447 SDL_colors[i].peBlue = 0; |
1410 SDL_colors[i].peBlue = 0; | 1448 } |
1411 } | 1449 } |
1412 } | 1450 result = IDirectDraw2_CreatePalette(ddraw2, |
1413 result = IDirectDraw2_CreatePalette(ddraw2, | 1451 (DDPCAPS_8BIT | |
1414 (DDPCAPS_8BIT|DDPCAPS_ALLOW256), | 1452 DDPCAPS_ALLOW256), SDL_colors, |
1415 SDL_colors, &SDL_palette, NULL); | 1453 &SDL_palette, NULL); |
1416 if ( result != DD_OK ) { | 1454 if (result != DD_OK) { |
1417 SetDDerror("DirectDraw2::CreatePalette", result); | 1455 SetDDerror("DirectDraw2::CreatePalette", result); |
1418 return(NULL); | 1456 return (NULL); |
1419 } | 1457 } |
1420 result = IDirectDrawSurface3_SetPalette(SDL_primary, | 1458 result = IDirectDrawSurface3_SetPalette(SDL_primary, SDL_palette); |
1421 SDL_palette); | 1459 if (result != DD_OK) { |
1422 if ( result != DD_OK ) { | 1460 SetDDerror("DirectDrawSurface3::SetPalette", result); |
1423 SetDDerror("DirectDrawSurface3::SetPalette", result); | 1461 return (NULL); |
1424 return(NULL); | 1462 } |
1425 } | 1463 } |
1426 } | 1464 |
1427 | 1465 /* Create our video surface using the same pixel format */ |
1428 /* Create our video surface using the same pixel format */ | 1466 video = current; |
1429 video = current; | 1467 if ((width != video->w) || (height != video->h) |
1430 if ( (width != video->w) || (height != video->h) | 1468 || (video->format->BitsPerPixel != |
1431 || (video->format->BitsPerPixel != | |
1432 #if defined(NONAMELESSUNION) | 1469 #if defined(NONAMELESSUNION) |
1433 ddsd.ddpfPixelFormat.u1.dwRGBBitCount) ) { | 1470 ddsd.ddpfPixelFormat.u1.dwRGBBitCount)) { |
1434 #else | 1471 #else |
1435 ddsd.ddpfPixelFormat.dwRGBBitCount) ) { | 1472 ddsd.ddpfPixelFormat.dwRGBBitCount)) { |
1436 #endif | 1473 #endif |
1437 SDL_FreeSurface(video); | 1474 SDL_FreeSurface(video); |
1438 video = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, | 1475 video = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, |
1439 #if defined(NONAMELESSUNION) | 1476 #if defined(NONAMELESSUNION) |
1440 ddsd.ddpfPixelFormat.u1.dwRGBBitCount, | 1477 ddsd.ddpfPixelFormat.u1.dwRGBBitCount, |
1441 ddsd.ddpfPixelFormat.u2.dwRBitMask, | 1478 ddsd.ddpfPixelFormat.u2.dwRBitMask, |
1442 ddsd.ddpfPixelFormat.u3.dwGBitMask, | 1479 ddsd.ddpfPixelFormat.u3.dwGBitMask, |
1443 ddsd.ddpfPixelFormat.u4.dwBBitMask, | 1480 ddsd.ddpfPixelFormat.u4.dwBBitMask, |
1444 #else | 1481 #else |
1445 ddsd.ddpfPixelFormat.dwRGBBitCount, | 1482 ddsd.ddpfPixelFormat.dwRGBBitCount, |
1446 ddsd.ddpfPixelFormat.dwRBitMask, | 1483 ddsd.ddpfPixelFormat.dwRBitMask, |
1447 ddsd.ddpfPixelFormat.dwGBitMask, | 1484 ddsd.ddpfPixelFormat.dwGBitMask, |
1448 ddsd.ddpfPixelFormat.dwBBitMask, | 1485 ddsd.ddpfPixelFormat.dwBBitMask, |
1449 #endif | 1486 #endif |
1450 0); | 1487 0); |
1451 if ( video == NULL ) { | 1488 if (video == NULL) { |
1452 SDL_OutOfMemory(); | 1489 SDL_OutOfMemory(); |
1453 return(NULL); | 1490 return (NULL); |
1454 } | 1491 } |
1455 video->w = width; | 1492 video->w = width; |
1456 video->h = height; | 1493 video->h = height; |
1457 video->pitch = 0; | 1494 video->pitch = 0; |
1458 } | 1495 } |
1459 video->flags = 0; /* Clear flags */ | 1496 video->flags = 0; /* Clear flags */ |
1460 | 1497 |
1461 /* If not fullscreen, locking is possible, but it doesn't do what | 1498 /* If not fullscreen, locking is possible, but it doesn't do what |
1462 the caller really expects -- if the locked surface is written to, | 1499 the caller really expects -- if the locked surface is written to, |
1463 the appropriate portion of the entire screen is modified, not | 1500 the appropriate portion of the entire screen is modified, not |
1464 the application window, as we would like. | 1501 the application window, as we would like. |
1465 Note that it is still possible to write directly to display | 1502 Note that it is still possible to write directly to display |
1466 memory, but the application must respect the clip list of | 1503 memory, but the application must respect the clip list of |
1467 the surface. There might be some odd timing interactions | 1504 the surface. There might be some odd timing interactions |
1468 involving clip list updates and background refreshing as | 1505 involving clip list updates and background refreshing as |
1469 Windows moves other windows across our window. | 1506 Windows moves other windows across our window. |
1470 We currently don't support this, even though it might be a | 1507 We currently don't support this, even though it might be a |
1471 good idea since BeOS has an implementation of BDirectWindow | 1508 good idea since BeOS has an implementation of BDirectWindow |
1472 that does the same thing. This would be most useful for | 1509 that does the same thing. This would be most useful for |
1473 applications that do complete screen updates every frame. | 1510 applications that do complete screen updates every frame. |
1474 -- Fixme? | 1511 -- Fixme? |
1475 */ | 1512 */ |
1476 if ( (flags & SDL_FULLSCREEN) != SDL_FULLSCREEN ) { | 1513 if ((flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) { |
1477 /* Necessary if we're going from fullscreen to window */ | 1514 /* Necessary if we're going from fullscreen to window */ |
1478 if ( video->pixels == NULL ) { | 1515 if (video->pixels == NULL) { |
1479 video->pitch = (width*video->format->BytesPerPixel); | 1516 video->pitch = (width * video->format->BytesPerPixel); |
1480 /* Pitch needs to be QWORD (8-byte) aligned */ | 1517 /* Pitch needs to be QWORD (8-byte) aligned */ |
1481 video->pitch = (video->pitch + 7) & ~7; | 1518 video->pitch = (video->pitch + 7) & ~7; |
1482 video->pixels = (void *)SDL_malloc(video->h*video->pitch); | 1519 video->pixels = (void *) SDL_malloc(video->h * video->pitch); |
1483 if ( video->pixels == NULL ) { | 1520 if (video->pixels == NULL) { |
1484 if ( video != current ) { | 1521 if (video != current) { |
1485 SDL_FreeSurface(video); | 1522 SDL_FreeSurface(video); |
1486 } | 1523 } |
1487 SDL_OutOfMemory(); | 1524 SDL_OutOfMemory(); |
1488 return(NULL); | 1525 return (NULL); |
1489 } | 1526 } |
1490 } | 1527 } |
1491 dd_surface3 = NULL; | 1528 dd_surface3 = NULL; |
1492 #if 0 /* FIXME: enable this when SDL consistently reports lost surfaces */ | 1529 #if 0 /* FIXME: enable this when SDL consistently reports lost surfaces */ |
1493 if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) { | 1530 if ((flags & SDL_HWSURFACE) == SDL_HWSURFACE) { |
1494 video->flags |= SDL_HWSURFACE; | 1531 video->flags |= SDL_HWSURFACE; |
1495 } else { | 1532 } else { |
1496 video->flags |= SDL_SWSURFACE; | 1533 video->flags |= SDL_SWSURFACE; |
1497 } | 1534 } |
1498 #else | 1535 #else |
1499 video->flags |= SDL_SWSURFACE; | 1536 video->flags |= SDL_SWSURFACE; |
1500 #endif | 1537 #endif |
1501 if ( (flags & SDL_RESIZABLE) && !(flags & SDL_NOFRAME) ) { | 1538 if ((flags & SDL_RESIZABLE) && !(flags & SDL_NOFRAME)) { |
1502 video->flags |= SDL_RESIZABLE; | 1539 video->flags |= SDL_RESIZABLE; |
1503 } | 1540 } |
1504 if ( flags & SDL_NOFRAME ) { | 1541 if (flags & SDL_NOFRAME) { |
1505 video->flags |= SDL_NOFRAME; | 1542 video->flags |= SDL_NOFRAME; |
1506 } | 1543 } |
1507 } else { | 1544 } else { |
1508 /* Necessary if we're going from window to fullscreen */ | 1545 /* Necessary if we're going from window to fullscreen */ |
1509 if ( video->pixels != NULL ) { | 1546 if (video->pixels != NULL) { |
1510 SDL_free(video->pixels); | 1547 SDL_free(video->pixels); |
1511 video->pixels = NULL; | 1548 video->pixels = NULL; |
1512 } | 1549 } |
1513 dd_surface3 = SDL_primary; | 1550 dd_surface3 = SDL_primary; |
1514 video->flags |= SDL_HWSURFACE; | 1551 video->flags |= SDL_HWSURFACE; |
1515 } | 1552 } |
1516 | 1553 |
1517 /* See if the primary surface has double-buffering enabled */ | 1554 /* See if the primary surface has double-buffering enabled */ |
1518 if ( (ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP) == DDSCAPS_FLIP ) { | 1555 if ((ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP) == DDSCAPS_FLIP) { |
1519 video->flags |= SDL_DOUBLEBUF; | 1556 video->flags |= SDL_DOUBLEBUF; |
1520 } | 1557 } |
1521 | 1558 |
1522 /* Allocate the SDL surface associated with the primary surface */ | 1559 /* Allocate the SDL surface associated with the primary surface */ |
1523 if ( DX5_AllocDDSurface(this, video, dd_surface3, | 1560 if (DX5_AllocDDSurface(this, video, dd_surface3, |
1524 video->flags&SDL_HWSURFACE) < 0 ) { | 1561 video->flags & SDL_HWSURFACE) < 0) { |
1525 if ( video != current ) { | 1562 if (video != current) { |
1526 SDL_FreeSurface(video); | 1563 SDL_FreeSurface(video); |
1527 } | 1564 } |
1528 return(NULL); | 1565 return (NULL); |
1529 } | 1566 } |
1530 | 1567 |
1531 /* Use the appropriate blitting function */ | 1568 /* Use the appropriate blitting function */ |
1532 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | 1569 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
1533 video->flags |= SDL_FULLSCREEN; | 1570 video->flags |= SDL_FULLSCREEN; |
1534 if ( video->format->palette != NULL ) { | 1571 if (video->format->palette != NULL) { |
1535 video->flags |= SDL_HWPALETTE; | 1572 video->flags |= SDL_HWPALETTE; |
1536 } | 1573 } |
1537 this->UpdateRects = DX5_DirectUpdate; | 1574 this->UpdateRects = DX5_DirectUpdate; |
1538 } else { | 1575 } else { |
1539 this->UpdateRects = DX5_WindowUpdate; | 1576 this->UpdateRects = DX5_WindowUpdate; |
1540 } | 1577 } |
1541 | 1578 |
1542 /* Make our window the proper size, set the clipper, then show it */ | 1579 /* Make our window the proper size, set the clipper, then show it */ |
1543 if ( (flags & SDL_FULLSCREEN) != SDL_FULLSCREEN ) { | 1580 if ((flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) { |
1544 /* Create and set a clipper on our primary surface */ | 1581 /* Create and set a clipper on our primary surface */ |
1545 if ( SDL_clipper == NULL ) { | 1582 if (SDL_clipper == NULL) { |
1546 result = IDirectDraw2_CreateClipper(ddraw2, | 1583 result = IDirectDraw2_CreateClipper(ddraw2, |
1547 0, &SDL_clipper, NULL); | 1584 0, &SDL_clipper, NULL); |
1548 if ( result != DD_OK ) { | 1585 if (result != DD_OK) { |
1549 if ( video != current ) { | 1586 if (video != current) { |
1550 SDL_FreeSurface(video); | 1587 SDL_FreeSurface(video); |
1551 } | 1588 } |
1552 SetDDerror("DirectDraw2::CreateClipper",result); | 1589 SetDDerror("DirectDraw2::CreateClipper", result); |
1553 return(NULL); | 1590 return (NULL); |
1554 } | 1591 } |
1555 } | 1592 } |
1556 result = IDirectDrawClipper_SetHWnd(SDL_clipper, 0, SDL_Window); | 1593 result = IDirectDrawClipper_SetHWnd(SDL_clipper, 0, SDL_Window); |
1557 if ( result != DD_OK ) { | 1594 if (result != DD_OK) { |
1558 if ( video != current ) { | 1595 if (video != current) { |
1559 SDL_FreeSurface(video); | 1596 SDL_FreeSurface(video); |
1560 } | 1597 } |
1561 SetDDerror("DirectDrawClipper::SetHWnd", result); | 1598 SetDDerror("DirectDrawClipper::SetHWnd", result); |
1562 return(NULL); | 1599 return (NULL); |
1563 } | 1600 } |
1564 result = IDirectDrawSurface3_SetClipper(SDL_primary, | 1601 result = IDirectDrawSurface3_SetClipper(SDL_primary, SDL_clipper); |
1565 SDL_clipper); | 1602 if (result != DD_OK) { |
1566 if ( result != DD_OK ) { | 1603 if (video != current) { |
1567 if ( video != current ) { | 1604 SDL_FreeSurface(video); |
1568 SDL_FreeSurface(video); | 1605 } |
1569 } | 1606 SetDDerror("DirectDrawSurface3::SetClipper", result); |
1570 SetDDerror("DirectDrawSurface3::SetClipper", result); | 1607 return (NULL); |
1571 return(NULL); | 1608 } |
1572 } | 1609 |
1573 | 1610 /* Resize the window (copied from SDL WinDIB driver) */ |
1574 /* Resize the window (copied from SDL WinDIB driver) */ | 1611 if (!SDL_windowid && !IsZoomed(SDL_Window)) { |
1575 if ( !SDL_windowid && !IsZoomed(SDL_Window) ) { | 1612 RECT bounds; |
1576 RECT bounds; | 1613 int x, y; |
1577 int x, y; | 1614 UINT swp_flags; |
1578 UINT swp_flags; | 1615 const char *window = NULL; |
1579 const char *window = NULL; | 1616 const char *center = NULL; |
1580 const char *center = NULL; | 1617 |
1581 | 1618 if (!SDL_windowX && !SDL_windowY) { |
1582 if ( !SDL_windowX && !SDL_windowY ) { | 1619 window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); |
1583 window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); | 1620 center = SDL_getenv("SDL_VIDEO_CENTERED"); |
1584 center = SDL_getenv("SDL_VIDEO_CENTERED"); | 1621 if (window) { |
1585 if ( window ) { | 1622 if (SDL_sscanf(window, "%d,%d", &x, &y) == 2) { |
1586 if ( SDL_sscanf(window, "%d,%d", &x, &y) == 2 ) { | 1623 SDL_windowX = x; |
1587 SDL_windowX = x; | 1624 SDL_windowY = y; |
1588 SDL_windowY = y; | 1625 } |
1589 } | 1626 if (SDL_strcmp(window, "center") == 0) { |
1590 if ( SDL_strcmp(window, "center") == 0 ) { | 1627 center = window; |
1591 center = window; | 1628 } |
1592 } | 1629 } |
1593 } | 1630 } |
1594 } | 1631 swp_flags = SWP_NOCOPYBITS; |
1595 swp_flags = SWP_NOCOPYBITS; | 1632 |
1596 | 1633 bounds.left = SDL_windowX; |
1597 bounds.left = SDL_windowX; | 1634 bounds.top = SDL_windowY; |
1598 bounds.top = SDL_windowY; | 1635 bounds.right = SDL_windowX + video->w; |
1599 bounds.right = SDL_windowX+video->w; | 1636 bounds.bottom = SDL_windowY + video->h; |
1600 bounds.bottom = SDL_windowY+video->h; | 1637 AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), |
1601 AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), (GetMenu(SDL_Window) != NULL), 0); | 1638 (GetMenu(SDL_Window) != NULL), 0); |
1602 width = bounds.right-bounds.left; | 1639 width = bounds.right - bounds.left; |
1603 height = bounds.bottom-bounds.top; | 1640 height = bounds.bottom - bounds.top; |
1604 if ( center ) { | 1641 if (center) { |
1605 x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; | 1642 x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2; |
1606 y = (GetSystemMetrics(SM_CYSCREEN)-height)/2; | 1643 y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2; |
1607 } else if ( SDL_windowX || SDL_windowY || window ) { | 1644 } else if (SDL_windowX || SDL_windowY || window) { |
1608 x = bounds.left; | 1645 x = bounds.left; |
1609 y = bounds.top; | 1646 y = bounds.top; |
1610 } else { | 1647 } else { |
1611 x = y = -1; | 1648 x = y = -1; |
1612 swp_flags |= SWP_NOMOVE; | 1649 swp_flags |= SWP_NOMOVE; |
1613 } | 1650 } |
1614 SetWindowPos(SDL_Window, HWND_NOTOPMOST, x, y, width, height, swp_flags); | 1651 SetWindowPos(SDL_Window, HWND_NOTOPMOST, x, y, width, height, |
1615 SDL_windowX = SDL_bounds.left; | 1652 swp_flags); |
1616 SDL_windowY = SDL_bounds.top; | 1653 SDL_windowX = SDL_bounds.left; |
1617 } | 1654 SDL_windowY = SDL_bounds.top; |
1618 | 1655 } |
1619 } | 1656 |
1620 ShowWindow(SDL_Window, SW_SHOW); | 1657 } |
1621 SetForegroundWindow(SDL_Window); | 1658 ShowWindow(SDL_Window, SW_SHOW); |
1622 SDL_resizing = 0; | 1659 SetForegroundWindow(SDL_Window); |
1623 | 1660 SDL_resizing = 0; |
1624 /* JC 14 Mar 2006 | 1661 |
1625 Flush the message loop or this can cause big problems later | 1662 /* JC 14 Mar 2006 |
1626 Especially if the user decides to use dialog boxes or assert()! | 1663 Flush the message loop or this can cause big problems later |
1627 */ | 1664 Especially if the user decides to use dialog boxes or assert()! |
1628 WIN_FlushMessageQueue(); | 1665 */ |
1629 | 1666 WIN_FlushMessageQueue(); |
1630 /* We're live! */ | 1667 |
1631 return(video); | 1668 /* We're live! */ |
1632 } | 1669 return (video); |
1633 | 1670 } |
1634 struct private_hwdata { | 1671 |
1635 LPDIRECTDRAWSURFACE3 dd_surface; | 1672 struct private_hwdata |
1636 LPDIRECTDRAWSURFACE3 dd_writebuf; | 1673 { |
1674 LPDIRECTDRAWSURFACE3 dd_surface; | |
1675 LPDIRECTDRAWSURFACE3 dd_writebuf; | |
1637 }; | 1676 }; |
1638 | 1677 |
1639 static int DX5_AllocDDSurface(_THIS, SDL_Surface *surface, | 1678 static int |
1640 LPDIRECTDRAWSURFACE3 requested, Uint32 flag) | 1679 DX5_AllocDDSurface(_THIS, SDL_Surface * surface, |
1641 { | 1680 LPDIRECTDRAWSURFACE3 requested, Uint32 flag) |
1642 LPDIRECTDRAWSURFACE dd_surface1; | 1681 { |
1643 LPDIRECTDRAWSURFACE3 dd_surface3; | 1682 LPDIRECTDRAWSURFACE dd_surface1; |
1644 DDSURFACEDESC ddsd; | 1683 LPDIRECTDRAWSURFACE3 dd_surface3; |
1645 HRESULT result; | 1684 DDSURFACEDESC ddsd; |
1646 | 1685 HRESULT result; |
1647 /* Clear the hardware flag, in case we fail */ | 1686 |
1648 surface->flags &= ~flag; | 1687 /* Clear the hardware flag, in case we fail */ |
1649 | 1688 surface->flags &= ~flag; |
1650 /* Allocate the hardware acceleration data */ | 1689 |
1651 surface->hwdata = (struct private_hwdata *) | 1690 /* Allocate the hardware acceleration data */ |
1652 SDL_malloc(sizeof(*surface->hwdata)); | 1691 surface->hwdata = (struct private_hwdata *) |
1653 if ( surface->hwdata == NULL ) { | 1692 SDL_malloc(sizeof(*surface->hwdata)); |
1654 SDL_OutOfMemory(); | 1693 if (surface->hwdata == NULL) { |
1655 return(-1); | 1694 SDL_OutOfMemory(); |
1656 } | 1695 return (-1); |
1657 dd_surface3 = NULL; | 1696 } |
1658 | 1697 dd_surface3 = NULL; |
1659 /* Set up the surface description */ | 1698 |
1660 SDL_memset(&ddsd, 0, sizeof(ddsd)); | 1699 /* Set up the surface description */ |
1661 ddsd.dwSize = sizeof(ddsd); | 1700 SDL_memset(&ddsd, 0, sizeof(ddsd)); |
1662 ddsd.dwFlags = (DDSD_WIDTH|DDSD_HEIGHT|DDSD_CAPS| | 1701 ddsd.dwSize = sizeof(ddsd); |
1663 DDSD_PITCH|DDSD_PIXELFORMAT); | 1702 ddsd.dwFlags = (DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | |
1664 ddsd.dwWidth = surface->w; | 1703 DDSD_PITCH | DDSD_PIXELFORMAT); |
1665 ddsd.dwHeight= surface->h; | 1704 ddsd.dwWidth = surface->w; |
1705 ddsd.dwHeight = surface->h; | |
1666 #if defined(NONAMELESSUNION) | 1706 #if defined(NONAMELESSUNION) |
1667 ddsd.u1.lPitch = surface->pitch; | 1707 ddsd.u1.lPitch = surface->pitch; |
1668 #else | 1708 #else |
1669 ddsd.lPitch = surface->pitch; | 1709 ddsd.lPitch = surface->pitch; |
1670 #endif | 1710 #endif |
1671 if ( (flag & SDL_HWSURFACE) == SDL_HWSURFACE ) { | 1711 if ((flag & SDL_HWSURFACE) == SDL_HWSURFACE) { |
1672 ddsd.ddsCaps.dwCaps = | 1712 ddsd.ddsCaps.dwCaps = (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY); |
1673 (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY); | 1713 } else { |
1674 } else { | 1714 ddsd.ddsCaps.dwCaps = (DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY); |
1675 ddsd.ddsCaps.dwCaps = | 1715 } |
1676 (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY); | 1716 ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); |
1677 } | 1717 ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; |
1678 ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); | 1718 if (surface->format->palette) { |
1679 ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; | 1719 ddsd.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8; |
1680 if ( surface->format->palette ) { | 1720 } |
1681 ddsd.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8; | |
1682 } | |
1683 #if defined(NONAMELESSUNION) | 1721 #if defined(NONAMELESSUNION) |
1684 ddsd.ddpfPixelFormat.u1.dwRGBBitCount = surface->format->BitsPerPixel; | 1722 ddsd.ddpfPixelFormat.u1.dwRGBBitCount = surface->format->BitsPerPixel; |
1685 ddsd.ddpfPixelFormat.u2.dwRBitMask = surface->format->Rmask; | 1723 ddsd.ddpfPixelFormat.u2.dwRBitMask = surface->format->Rmask; |
1686 ddsd.ddpfPixelFormat.u3.dwGBitMask = surface->format->Gmask; | 1724 ddsd.ddpfPixelFormat.u3.dwGBitMask = surface->format->Gmask; |
1687 ddsd.ddpfPixelFormat.u4.dwBBitMask = surface->format->Bmask; | 1725 ddsd.ddpfPixelFormat.u4.dwBBitMask = surface->format->Bmask; |
1688 #else | 1726 #else |
1689 ddsd.ddpfPixelFormat.dwRGBBitCount = surface->format->BitsPerPixel; | 1727 ddsd.ddpfPixelFormat.dwRGBBitCount = surface->format->BitsPerPixel; |
1690 ddsd.ddpfPixelFormat.dwRBitMask = surface->format->Rmask; | 1728 ddsd.ddpfPixelFormat.dwRBitMask = surface->format->Rmask; |
1691 ddsd.ddpfPixelFormat.dwGBitMask = surface->format->Gmask; | 1729 ddsd.ddpfPixelFormat.dwGBitMask = surface->format->Gmask; |
1692 ddsd.ddpfPixelFormat.dwBBitMask = surface->format->Bmask; | 1730 ddsd.ddpfPixelFormat.dwBBitMask = surface->format->Bmask; |
1693 #endif | 1731 #endif |
1694 | 1732 |
1695 /* Create the DirectDraw video surface */ | 1733 /* Create the DirectDraw video surface */ |
1696 if ( requested != NULL ) { | 1734 if (requested != NULL) { |
1697 dd_surface3 = requested; | 1735 dd_surface3 = requested; |
1698 } else { | 1736 } else { |
1699 result = IDirectDraw2_CreateSurface(ddraw2, | 1737 result = IDirectDraw2_CreateSurface(ddraw2, |
1700 &ddsd, &dd_surface1, NULL); | 1738 &ddsd, &dd_surface1, NULL); |
1701 if ( result != DD_OK ) { | 1739 if (result != DD_OK) { |
1702 SetDDerror("DirectDraw2::CreateSurface", result); | 1740 SetDDerror("DirectDraw2::CreateSurface", result); |
1703 goto error_end; | 1741 goto error_end; |
1704 } | 1742 } |
1705 result = IDirectDrawSurface_QueryInterface(dd_surface1, | 1743 result = IDirectDrawSurface_QueryInterface(dd_surface1, |
1706 &IID_IDirectDrawSurface3, (LPVOID *)&dd_surface3); | 1744 &IID_IDirectDrawSurface3, |
1707 IDirectDrawSurface_Release(dd_surface1); | 1745 (LPVOID *) & dd_surface3); |
1708 if ( result != DD_OK ) { | 1746 IDirectDrawSurface_Release(dd_surface1); |
1709 SetDDerror("DirectDrawSurface::QueryInterface", result); | 1747 if (result != DD_OK) { |
1710 goto error_end; | 1748 SetDDerror("DirectDrawSurface::QueryInterface", result); |
1711 } | 1749 goto error_end; |
1712 } | 1750 } |
1713 | 1751 } |
1714 if ( (flag & SDL_HWSURFACE) == SDL_HWSURFACE ) { | 1752 |
1715 /* Check to see whether the surface actually ended up | 1753 if ((flag & SDL_HWSURFACE) == SDL_HWSURFACE) { |
1716 in video memory, and fail if not. We expect the | 1754 /* Check to see whether the surface actually ended up |
1717 surfaces we create here to actually be in hardware! | 1755 in video memory, and fail if not. We expect the |
1718 */ | 1756 surfaces we create here to actually be in hardware! |
1719 result = IDirectDrawSurface3_GetCaps(dd_surface3,&ddsd.ddsCaps); | 1757 */ |
1720 if ( result != DD_OK ) { | 1758 result = IDirectDrawSurface3_GetCaps(dd_surface3, &ddsd.ddsCaps); |
1721 SetDDerror("DirectDrawSurface3::GetCaps", result); | 1759 if (result != DD_OK) { |
1722 goto error_end; | 1760 SetDDerror("DirectDrawSurface3::GetCaps", result); |
1723 } | 1761 goto error_end; |
1724 if ( (ddsd.ddsCaps.dwCaps&DDSCAPS_VIDEOMEMORY) != | 1762 } |
1725 DDSCAPS_VIDEOMEMORY ) { | 1763 if ((ddsd.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY) != |
1726 SDL_SetError("No room in video memory"); | 1764 DDSCAPS_VIDEOMEMORY) { |
1727 goto error_end; | 1765 SDL_SetError("No room in video memory"); |
1728 } | 1766 goto error_end; |
1729 } else { | 1767 } |
1730 /* Try to hook our surface memory */ | 1768 } else { |
1731 ddsd.dwFlags = DDSD_LPSURFACE; | 1769 /* Try to hook our surface memory */ |
1732 ddsd.lpSurface = surface->pixels; | 1770 ddsd.dwFlags = DDSD_LPSURFACE; |
1733 result = IDirectDrawSurface3_SetSurfaceDesc(dd_surface3, | 1771 ddsd.lpSurface = surface->pixels; |
1734 &ddsd, 0); | 1772 result = IDirectDrawSurface3_SetSurfaceDesc(dd_surface3, &ddsd, 0); |
1735 if ( result != DD_OK ) { | 1773 if (result != DD_OK) { |
1736 SetDDerror("DirectDraw2::SetSurfaceDesc", result); | 1774 SetDDerror("DirectDraw2::SetSurfaceDesc", result); |
1737 goto error_end; | 1775 goto error_end; |
1738 } | 1776 } |
1739 | 1777 |
1740 } | 1778 } |
1741 | 1779 |
1742 /* Make sure the surface format was set properly */ | 1780 /* Make sure the surface format was set properly */ |
1743 SDL_memset(&ddsd, 0, sizeof(ddsd)); | 1781 SDL_memset(&ddsd, 0, sizeof(ddsd)); |
1744 ddsd.dwSize = sizeof(ddsd); | 1782 ddsd.dwSize = sizeof(ddsd); |
1745 result = IDirectDrawSurface3_Lock(dd_surface3, NULL, | 1783 result = IDirectDrawSurface3_Lock(dd_surface3, NULL, |
1746 &ddsd, (DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL); | 1784 &ddsd, |
1747 if ( result != DD_OK ) { | 1785 (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), NULL); |
1748 SetDDerror("DirectDrawSurface3::Lock", result); | 1786 if (result != DD_OK) { |
1749 goto error_end; | 1787 SetDDerror("DirectDrawSurface3::Lock", result); |
1750 } | 1788 goto error_end; |
1751 IDirectDrawSurface3_Unlock(dd_surface3, NULL); | 1789 } |
1752 | 1790 IDirectDrawSurface3_Unlock(dd_surface3, NULL); |
1753 if ( (flag & SDL_HWSURFACE) == SDL_SWSURFACE ) { | 1791 |
1754 if ( ddsd.lpSurface != surface->pixels ) { | 1792 if ((flag & SDL_HWSURFACE) == SDL_SWSURFACE) { |
1755 SDL_SetError("DDraw didn't use SDL surface memory"); | 1793 if (ddsd.lpSurface != surface->pixels) { |
1756 goto error_end; | 1794 SDL_SetError("DDraw didn't use SDL surface memory"); |
1757 } | 1795 goto error_end; |
1758 if ( | 1796 } |
1797 if ( | |
1759 #if defined(NONAMELESSUNION) | 1798 #if defined(NONAMELESSUNION) |
1760 ddsd.u1.lPitch | 1799 ddsd.u1.lPitch |
1761 #else | 1800 #else |
1762 ddsd.lPitch | 1801 ddsd.lPitch |
1763 #endif | 1802 #endif |
1764 != (LONG)surface->pitch ) { | 1803 != (LONG) surface->pitch) { |
1765 SDL_SetError("DDraw created surface with wrong pitch"); | 1804 SDL_SetError("DDraw created surface with wrong pitch"); |
1766 goto error_end; | 1805 goto error_end; |
1767 } | 1806 } |
1768 } else { | 1807 } else { |
1769 #if defined(NONAMELESSUNION) | 1808 #if defined(NONAMELESSUNION) |
1770 surface->pitch = (Uint16)ddsd.u1.lPitch; | 1809 surface->pitch = (Uint16) ddsd.u1.lPitch; |
1771 #else | 1810 #else |
1772 surface->pitch = (Uint16)ddsd.lPitch; | 1811 surface->pitch = (Uint16) ddsd.lPitch; |
1773 #endif | 1812 #endif |
1774 } | 1813 } |
1775 #if defined(NONAMELESSUNION) | 1814 #if defined(NONAMELESSUNION) |
1776 if ( (ddsd.ddpfPixelFormat.u1.dwRGBBitCount != | 1815 if ((ddsd.ddpfPixelFormat.u1.dwRGBBitCount != |
1777 surface->format->BitsPerPixel) || | 1816 surface->format->BitsPerPixel) || |
1778 (ddsd.ddpfPixelFormat.u2.dwRBitMask != surface->format->Rmask) || | 1817 (ddsd.ddpfPixelFormat.u2.dwRBitMask != surface->format->Rmask) || |
1779 (ddsd.ddpfPixelFormat.u3.dwGBitMask != surface->format->Gmask) || | 1818 (ddsd.ddpfPixelFormat.u3.dwGBitMask != surface->format->Gmask) || |
1780 (ddsd.ddpfPixelFormat.u4.dwBBitMask != surface->format->Bmask) ){ | 1819 (ddsd.ddpfPixelFormat.u4.dwBBitMask != surface->format->Bmask)) { |
1781 #else | 1820 #else |
1782 if ( (ddsd.ddpfPixelFormat.dwRGBBitCount != | 1821 if ((ddsd.ddpfPixelFormat.dwRGBBitCount != |
1783 surface->format->BitsPerPixel) || | 1822 surface->format->BitsPerPixel) || |
1784 (ddsd.ddpfPixelFormat.dwRBitMask != surface->format->Rmask) || | 1823 (ddsd.ddpfPixelFormat.dwRBitMask != surface->format->Rmask) || |
1785 (ddsd.ddpfPixelFormat.dwGBitMask != surface->format->Gmask) || | 1824 (ddsd.ddpfPixelFormat.dwGBitMask != surface->format->Gmask) || |
1786 (ddsd.ddpfPixelFormat.dwBBitMask != surface->format->Bmask) ){ | 1825 (ddsd.ddpfPixelFormat.dwBBitMask != surface->format->Bmask)) { |
1787 #endif | 1826 #endif |
1788 SDL_SetError("DDraw didn't use SDL surface description"); | 1827 SDL_SetError("DDraw didn't use SDL surface description"); |
1789 goto error_end; | 1828 goto error_end; |
1790 } | 1829 } |
1791 if ( (ddsd.dwWidth != (DWORD)surface->w) || | 1830 if ((ddsd.dwWidth != (DWORD) surface->w) || |
1792 (ddsd.dwHeight != (DWORD)surface->h) ) { | 1831 (ddsd.dwHeight != (DWORD) surface->h)) { |
1793 SDL_SetError("DDraw created surface with wrong size"); | 1832 SDL_SetError("DDraw created surface with wrong size"); |
1794 goto error_end; | 1833 goto error_end; |
1795 } | 1834 } |
1796 | 1835 |
1797 /* Set the surface private data */ | 1836 /* Set the surface private data */ |
1798 surface->flags |= flag; | 1837 surface->flags |= flag; |
1799 surface->hwdata->dd_surface = dd_surface3; | 1838 surface->hwdata->dd_surface = dd_surface3; |
1800 if ( (surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) { | 1839 if ((surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { |
1801 LPDIRECTDRAWSURFACE3 dd_writebuf; | 1840 LPDIRECTDRAWSURFACE3 dd_writebuf; |
1802 | 1841 |
1803 ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; | 1842 ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; |
1804 result = IDirectDrawSurface3_GetAttachedSurface(dd_surface3, | 1843 result = IDirectDrawSurface3_GetAttachedSurface(dd_surface3, |
1805 &ddsd.ddsCaps, &dd_writebuf); | 1844 &ddsd.ddsCaps, |
1806 if ( result != DD_OK ) { | 1845 &dd_writebuf); |
1807 SetDDerror("DirectDrawSurface3::GetAttachedSurface", | 1846 if (result != DD_OK) { |
1808 result); | 1847 SetDDerror("DirectDrawSurface3::GetAttachedSurface", result); |
1809 } else { | 1848 } else { |
1810 dd_surface3 = dd_writebuf; | 1849 dd_surface3 = dd_writebuf; |
1811 } | 1850 } |
1812 } | 1851 } |
1813 surface->hwdata->dd_writebuf = dd_surface3; | 1852 surface->hwdata->dd_writebuf = dd_surface3; |
1814 | 1853 |
1815 /* We're ready to go! */ | 1854 /* We're ready to go! */ |
1816 return(0); | 1855 return (0); |
1817 | 1856 |
1818 /* Okay, so goto's are cheesy, but there are so many possible | 1857 /* Okay, so goto's are cheesy, but there are so many possible |
1819 errors in this function, and the cleanup is the same in | 1858 errors in this function, and the cleanup is the same in |
1820 every single case. Is there a better way, other than deeply | 1859 every single case. Is there a better way, other than deeply |
1821 nesting the code? | 1860 nesting the code? |
1822 */ | 1861 */ |
1823 error_end: | 1862 error_end: |
1824 if ( (dd_surface3 != NULL) && (dd_surface3 != requested) ) { | 1863 if ((dd_surface3 != NULL) && (dd_surface3 != requested)) { |
1825 IDirectDrawSurface_Release(dd_surface3); | 1864 IDirectDrawSurface_Release(dd_surface3); |
1826 } | 1865 } |
1827 SDL_free(surface->hwdata); | 1866 SDL_free(surface->hwdata); |
1828 surface->hwdata = NULL; | 1867 surface->hwdata = NULL; |
1829 return(-1); | 1868 return (-1); |
1830 } | 1869 } |
1831 | 1870 |
1832 static int DX5_AllocHWSurface(_THIS, SDL_Surface *surface) | 1871 static int |
1833 { | 1872 DX5_AllocHWSurface(_THIS, SDL_Surface * surface) |
1834 /* DDraw limitation -- you need to set cooperative level first */ | 1873 { |
1835 if ( SDL_primary == NULL ) { | 1874 /* DDraw limitation -- you need to set cooperative level first */ |
1836 SDL_SetError("You must set a non-GL video mode first"); | 1875 if (SDL_primary == NULL) { |
1837 return(-1); | 1876 SDL_SetError("You must set a non-GL video mode first"); |
1838 } | 1877 return (-1); |
1839 return(DX5_AllocDDSurface(this, surface, NULL, SDL_HWSURFACE)); | 1878 } |
1879 return (DX5_AllocDDSurface(this, surface, NULL, SDL_HWSURFACE)); | |
1840 } | 1880 } |
1841 | 1881 |
1842 #ifdef DDRAW_DEBUG | 1882 #ifdef DDRAW_DEBUG |
1843 void PrintSurface(char *title, LPDIRECTDRAWSURFACE3 surface, Uint32 flags) | 1883 void |
1844 { | 1884 PrintSurface(char *title, LPDIRECTDRAWSURFACE3 surface, Uint32 flags) |
1845 DDSURFACEDESC ddsd; | 1885 { |
1846 | 1886 DDSURFACEDESC ddsd; |
1847 /* Lock and load! */ | 1887 |
1848 SDL_memset(&ddsd, 0, sizeof(ddsd)); | 1888 /* Lock and load! */ |
1849 ddsd.dwSize = sizeof(ddsd); | 1889 SDL_memset(&ddsd, 0, sizeof(ddsd)); |
1850 if ( IDirectDrawSurface3_Lock(surface, NULL, &ddsd, | 1890 ddsd.dwSize = sizeof(ddsd); |
1851 (DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL) != DD_OK ) { | 1891 if (IDirectDrawSurface3_Lock(surface, NULL, &ddsd, |
1852 return; | 1892 (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), |
1853 } | 1893 NULL) != DD_OK) { |
1854 IDirectDrawSurface3_Unlock(surface, NULL); | 1894 return; |
1855 | 1895 } |
1856 fprintf(stderr, "%s:\n", title); | 1896 IDirectDrawSurface3_Unlock(surface, NULL); |
1857 fprintf(stderr, "\tSize: %dx%d in %s at %ld bpp (pitch = %ld)\n", | 1897 |
1858 ddsd.dwWidth, ddsd.dwHeight, | 1898 fprintf(stderr, "%s:\n", title); |
1859 (flags & SDL_HWSURFACE) ? "hardware" : "software", | 1899 fprintf(stderr, "\tSize: %dx%d in %s at %ld bpp (pitch = %ld)\n", |
1900 ddsd.dwWidth, ddsd.dwHeight, | |
1901 (flags & SDL_HWSURFACE) ? "hardware" : "software", | |
1860 #if defined(NONAMELESSUNION) | 1902 #if defined(NONAMELESSUNION) |
1861 ddsd.ddpfPixelFormat.u1.dwRGBBitCount, ddsd.u1.lPitch); | 1903 ddsd.ddpfPixelFormat.u1.dwRGBBitCount, ddsd.u1.lPitch); |
1862 #else | 1904 #else |
1863 ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.lPitch); | 1905 ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.lPitch); |
1864 #endif | 1906 #endif |
1865 fprintf(stderr, "\tR = 0x%X, G = 0x%X, B = 0x%X\n", | 1907 fprintf(stderr, "\tR = 0x%X, G = 0x%X, B = 0x%X\n", |
1866 #if defined(NONAMELESSUNION) | 1908 #if defined(NONAMELESSUNION) |
1867 ddsd.ddpfPixelFormat.u2.dwRBitMask, | 1909 ddsd.ddpfPixelFormat.u2.dwRBitMask, |
1868 ddsd.ddpfPixelFormat.u3.dwGBitMask, | 1910 ddsd.ddpfPixelFormat.u3.dwGBitMask, |
1869 ddsd.ddpfPixelFormat.u4.dwBBitMask); | 1911 ddsd.ddpfPixelFormat.u4.dwBBitMask); |
1870 #else | 1912 #else |
1871 ddsd.ddpfPixelFormat.dwRBitMask, | 1913 ddsd.ddpfPixelFormat.dwRBitMask, |
1872 ddsd.ddpfPixelFormat.dwGBitMask, | 1914 ddsd.ddpfPixelFormat.dwGBitMask, ddsd.ddpfPixelFormat.dwBBitMask); |
1873 ddsd.ddpfPixelFormat.dwBBitMask); | |
1874 #endif | 1915 #endif |
1875 } | 1916 } |
1876 #endif /* DDRAW_DEBUG */ | 1917 #endif /* DDRAW_DEBUG */ |
1877 | 1918 |
1878 static int DX5_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, | 1919 static int |
1879 SDL_Surface *dst, SDL_Rect *dstrect) | 1920 DX5_HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, |
1880 { | 1921 SDL_Surface * dst, SDL_Rect * dstrect) |
1881 LPDIRECTDRAWSURFACE3 src_surface; | 1922 { |
1882 LPDIRECTDRAWSURFACE3 dst_surface; | 1923 LPDIRECTDRAWSURFACE3 src_surface; |
1883 DWORD flags; | 1924 LPDIRECTDRAWSURFACE3 dst_surface; |
1884 RECT rect; | 1925 DWORD flags; |
1885 HRESULT result; | 1926 RECT rect; |
1886 | 1927 HRESULT result; |
1887 /* Set it up.. the desination must have a DDRAW surface */ | 1928 |
1888 src_surface = src->hwdata->dd_writebuf; | 1929 /* Set it up.. the desination must have a DDRAW surface */ |
1889 dst_surface = dst->hwdata->dd_writebuf; | 1930 src_surface = src->hwdata->dd_writebuf; |
1890 rect.top = (LONG)srcrect->y; | 1931 dst_surface = dst->hwdata->dd_writebuf; |
1891 rect.bottom = (LONG)srcrect->y+srcrect->h; | 1932 rect.top = (LONG) srcrect->y; |
1892 rect.left = (LONG)srcrect->x; | 1933 rect.bottom = (LONG) srcrect->y + srcrect->h; |
1893 rect.right = (LONG)srcrect->x+srcrect->w; | 1934 rect.left = (LONG) srcrect->x; |
1894 if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) | 1935 rect.right = (LONG) srcrect->x + srcrect->w; |
1895 flags = DDBLTFAST_SRCCOLORKEY; | 1936 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) |
1896 else | 1937 flags = DDBLTFAST_SRCCOLORKEY; |
1897 flags = DDBLTFAST_NOCOLORKEY; | 1938 else |
1898 /* FIXME: We can remove this flag for _really_ fast blit queuing, | 1939 flags = DDBLTFAST_NOCOLORKEY; |
1899 but it will affect the return values of locks and flips. | 1940 /* FIXME: We can remove this flag for _really_ fast blit queuing, |
1900 */ | 1941 but it will affect the return values of locks and flips. |
1901 flags |= DDBLTFAST_WAIT; | 1942 */ |
1902 | 1943 flags |= DDBLTFAST_WAIT; |
1903 /* Do the blit! */ | 1944 |
1904 result = IDirectDrawSurface3_BltFast(dst_surface, | 1945 /* Do the blit! */ |
1905 dstrect->x, dstrect->y, src_surface, &rect, flags); | 1946 result = IDirectDrawSurface3_BltFast(dst_surface, |
1906 if ( result != DD_OK ) { | 1947 dstrect->x, dstrect->y, src_surface, |
1907 if ( result == DDERR_SURFACELOST ) { | 1948 &rect, flags); |
1908 result = IDirectDrawSurface3_Restore(src_surface); | 1949 if (result != DD_OK) { |
1909 result = IDirectDrawSurface3_Restore(dst_surface); | 1950 if (result == DDERR_SURFACELOST) { |
1910 /* The surfaces need to be reloaded with artwork */ | 1951 result = IDirectDrawSurface3_Restore(src_surface); |
1911 SDL_SetError("Blit surfaces were lost, reload them"); | 1952 result = IDirectDrawSurface3_Restore(dst_surface); |
1912 return(-2); | 1953 /* The surfaces need to be reloaded with artwork */ |
1913 } | 1954 SDL_SetError("Blit surfaces were lost, reload them"); |
1914 SetDDerror("IDirectDrawSurface3::BltFast", result); | 1955 return (-2); |
1956 } | |
1957 SetDDerror("IDirectDrawSurface3::BltFast", result); | |
1915 #ifdef DDRAW_DEBUG | 1958 #ifdef DDRAW_DEBUG |
1916 fprintf(stderr, "Original dest rect: %dx%d at %d,%d\n", dstrect->w, dstrect->h, dstrect->x, dstrect->y); | 1959 fprintf(stderr, "Original dest rect: %dx%d at %d,%d\n", dstrect->w, |
1917 fprintf(stderr, "HW accelerated %sblit to from 0x%p to 0x%p at (%d,%d)\n", | 1960 dstrect->h, dstrect->x, dstrect->y); |
1918 (src->flags & SDL_SRCCOLORKEY) ? "colorkey " : "", src, dst, | 1961 fprintf(stderr, |
1919 dstrect->x, dstrect->y); | 1962 "HW accelerated %sblit to from 0x%p to 0x%p at (%d,%d)\n", |
1920 PrintSurface("SRC", src_surface, src->flags); | 1963 (src->flags & SDL_SRCCOLORKEY) ? "colorkey " : "", src, |
1921 PrintSurface("DST", dst_surface, dst->flags); | 1964 dst, dstrect->x, dstrect->y); |
1922 fprintf(stderr, "Source rectangle: (%d,%d) - (%d,%d)\n", | 1965 PrintSurface("SRC", src_surface, src->flags); |
1923 rect.left, rect.top, rect.right, rect.bottom); | 1966 PrintSurface("DST", dst_surface, dst->flags); |
1924 #endif | 1967 fprintf(stderr, "Source rectangle: (%d,%d) - (%d,%d)\n", |
1925 /* Unexpected error, fall back to software blit */ | 1968 rect.left, rect.top, rect.right, rect.bottom); |
1926 return(src->map->sw_blit(src, srcrect, dst, dstrect)); | 1969 #endif |
1927 } | 1970 /* Unexpected error, fall back to software blit */ |
1928 return(0); | 1971 return (src->map->sw_blit(src, srcrect, dst, dstrect)); |
1929 } | 1972 } |
1930 | 1973 return (0); |
1931 static int DX5_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst) | 1974 } |
1932 { | 1975 |
1933 int accelerated; | 1976 static int |
1934 | 1977 DX5_CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) |
1935 /* We need to have a DDraw surface for HW blits */ | 1978 { |
1936 if ( (src->flags & SDL_HWSURFACE) == SDL_SWSURFACE ) { | 1979 int accelerated; |
1937 /* Allocate a DDraw surface for the blit */ | 1980 |
1938 if ( src->hwdata == NULL ) { | 1981 /* We need to have a DDraw surface for HW blits */ |
1939 DX5_AllocDDSurface(this, src, NULL, SDL_SWSURFACE); | 1982 if ((src->flags & SDL_HWSURFACE) == SDL_SWSURFACE) { |
1940 } | 1983 /* Allocate a DDraw surface for the blit */ |
1941 } | 1984 if (src->hwdata == NULL) { |
1942 if ( src->hwdata == NULL ) { | 1985 DX5_AllocDDSurface(this, src, NULL, SDL_SWSURFACE); |
1943 return(0); | 1986 } |
1944 } | 1987 } |
1945 | 1988 if (src->hwdata == NULL) { |
1946 /* Set initial acceleration on */ | 1989 return (0); |
1947 src->flags |= SDL_HWACCEL; | 1990 } |
1948 | 1991 |
1949 /* Set the surface attributes */ | 1992 /* Set initial acceleration on */ |
1950 if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) { | 1993 src->flags |= SDL_HWACCEL; |
1951 if ( DX5_SetHWColorKey(this, src, src->format->colorkey) < 0 ) { | 1994 |
1952 src->flags &= ~SDL_HWACCEL; | 1995 /* Set the surface attributes */ |
1953 } | 1996 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { |
1954 } | 1997 if (DX5_SetHWColorKey(this, src, src->format->colorkey) < 0) { |
1955 if ( (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA ) { | 1998 src->flags &= ~SDL_HWACCEL; |
1956 if ( DX5_SetHWAlpha(this, src, src->format->alpha) < 0 ) { | 1999 } |
1957 src->flags &= ~SDL_HWACCEL; | 2000 } |
1958 } | 2001 if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { |
1959 } | 2002 if (DX5_SetHWAlpha(this, src, src->format->alpha) < 0) { |
1960 | 2003 src->flags &= ~SDL_HWACCEL; |
1961 /* Check to see if final surface blit is accelerated */ | 2004 } |
1962 accelerated = !!(src->flags & SDL_HWACCEL); | 2005 } |
1963 if ( accelerated ) { | 2006 |
2007 /* Check to see if final surface blit is accelerated */ | |
2008 accelerated = !!(src->flags & SDL_HWACCEL); | |
2009 if (accelerated) { | |
1964 #ifdef DDRAW_DEBUG | 2010 #ifdef DDRAW_DEBUG |
1965 fprintf(stderr, "Setting accelerated blit on 0x%p\n", src); | 2011 fprintf(stderr, "Setting accelerated blit on 0x%p\n", src); |
1966 #endif | 2012 #endif |
1967 src->map->hw_blit = DX5_HWAccelBlit; | 2013 src->map->hw_blit = DX5_HWAccelBlit; |
1968 } | 2014 } |
1969 return(accelerated); | 2015 return (accelerated); |
1970 } | 2016 } |
1971 | 2017 |
1972 static int DX5_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) | 2018 static int |
1973 { | 2019 DX5_FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color) |
1974 LPDIRECTDRAWSURFACE3 dst_surface; | 2020 { |
1975 RECT area; | 2021 LPDIRECTDRAWSURFACE3 dst_surface; |
1976 DDBLTFX bltfx; | 2022 RECT area; |
1977 HRESULT result; | 2023 DDBLTFX bltfx; |
2024 HRESULT result; | |
1978 | 2025 |
1979 #ifdef DDRAW_DEBUG | 2026 #ifdef DDRAW_DEBUG |
1980 fprintf(stderr, "HW accelerated fill at (%d,%d)\n", dstrect->x, dstrect->y); | 2027 fprintf(stderr, "HW accelerated fill at (%d,%d)\n", dstrect->x, |
1981 #endif | 2028 dstrect->y); |
1982 dst_surface = dst->hwdata->dd_writebuf; | 2029 #endif |
1983 area.top = (LONG)dstrect->y; | 2030 dst_surface = dst->hwdata->dd_writebuf; |
1984 area.bottom = (LONG)dstrect->y+dstrect->h; | 2031 area.top = (LONG) dstrect->y; |
1985 area.left = (LONG)dstrect->x; | 2032 area.bottom = (LONG) dstrect->y + dstrect->h; |
1986 area.right = (LONG)dstrect->x+dstrect->w; | 2033 area.left = (LONG) dstrect->x; |
1987 bltfx.dwSize = sizeof(bltfx); | 2034 area.right = (LONG) dstrect->x + dstrect->w; |
2035 bltfx.dwSize = sizeof(bltfx); | |
1988 #if defined(NONAMELESSUNION) | 2036 #if defined(NONAMELESSUNION) |
1989 bltfx.u5.dwFillColor = color; | 2037 bltfx.u5.dwFillColor = color; |
1990 #else | 2038 #else |
1991 bltfx.dwFillColor = color; | 2039 bltfx.dwFillColor = color; |
1992 #endif | 2040 #endif |
1993 result = IDirectDrawSurface3_Blt(dst_surface, | 2041 result = IDirectDrawSurface3_Blt(dst_surface, |
1994 &area, NULL, NULL, DDBLT_COLORFILL|DDBLT_WAIT, &bltfx); | 2042 &area, NULL, NULL, |
1995 if ( result == DDERR_SURFACELOST ) { | 2043 DDBLT_COLORFILL | DDBLT_WAIT, &bltfx); |
1996 IDirectDrawSurface3_Restore(dst_surface); | 2044 if (result == DDERR_SURFACELOST) { |
1997 result = IDirectDrawSurface3_Blt(dst_surface, | 2045 IDirectDrawSurface3_Restore(dst_surface); |
1998 &area, NULL, NULL, DDBLT_COLORFILL|DDBLT_WAIT, &bltfx); | 2046 result = IDirectDrawSurface3_Blt(dst_surface, |
1999 } | 2047 &area, NULL, NULL, |
2000 if ( result != DD_OK ) { | 2048 DDBLT_COLORFILL | DDBLT_WAIT, |
2001 SetDDerror("IDirectDrawSurface3::Blt", result); | 2049 &bltfx); |
2002 return(-1); | 2050 } |
2003 } | 2051 if (result != DD_OK) { |
2004 return(0); | 2052 SetDDerror("IDirectDrawSurface3::Blt", result); |
2005 } | 2053 return (-1); |
2006 | 2054 } |
2007 static int DX5_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key) | 2055 return (0); |
2008 { | 2056 } |
2009 DDCOLORKEY colorkey; | 2057 |
2010 HRESULT result; | 2058 static int |
2011 | 2059 DX5_SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) |
2012 /* Set the surface colorkey */ | 2060 { |
2013 colorkey.dwColorSpaceLowValue = key; | 2061 DDCOLORKEY colorkey; |
2014 colorkey.dwColorSpaceHighValue = key; | 2062 HRESULT result; |
2015 result = IDirectDrawSurface3_SetColorKey( | 2063 |
2016 surface->hwdata->dd_surface, DDCKEY_SRCBLT, &colorkey); | 2064 /* Set the surface colorkey */ |
2017 if ( result != DD_OK ) { | 2065 colorkey.dwColorSpaceLowValue = key; |
2018 SetDDerror("IDirectDrawSurface3::SetColorKey", result); | 2066 colorkey.dwColorSpaceHighValue = key; |
2019 return(-1); | 2067 result = |
2020 } | 2068 IDirectDrawSurface3_SetColorKey(surface->hwdata->dd_surface, |
2021 return(0); | 2069 DDCKEY_SRCBLT, &colorkey); |
2022 } | 2070 if (result != DD_OK) { |
2023 static int DX5_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha) | 2071 SetDDerror("IDirectDrawSurface3::SetColorKey", result); |
2024 { | 2072 return (-1); |
2025 return(-1); | 2073 } |
2026 } | 2074 return (0); |
2027 | 2075 } |
2028 static int DX5_LockHWSurface(_THIS, SDL_Surface *surface) | 2076 static int |
2029 { | 2077 DX5_SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 alpha) |
2030 HRESULT result; | 2078 { |
2031 LPDIRECTDRAWSURFACE3 dd_surface; | 2079 return (-1); |
2032 DDSURFACEDESC ddsd; | 2080 } |
2033 | 2081 |
2034 /* Lock and load! */ | 2082 static int |
2035 dd_surface = surface->hwdata->dd_writebuf; | 2083 DX5_LockHWSurface(_THIS, SDL_Surface * surface) |
2036 SDL_memset(&ddsd, 0, sizeof(ddsd)); | 2084 { |
2037 ddsd.dwSize = sizeof(ddsd); | 2085 HRESULT result; |
2038 result = IDirectDrawSurface3_Lock(dd_surface, NULL, &ddsd, | 2086 LPDIRECTDRAWSURFACE3 dd_surface; |
2039 (DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL); | 2087 DDSURFACEDESC ddsd; |
2040 if ( result == DDERR_SURFACELOST ) { | 2088 |
2041 result = IDirectDrawSurface3_Restore( | 2089 /* Lock and load! */ |
2042 surface->hwdata->dd_surface); | 2090 dd_surface = surface->hwdata->dd_writebuf; |
2043 result = IDirectDrawSurface3_Lock(dd_surface, NULL, &ddsd, | 2091 SDL_memset(&ddsd, 0, sizeof(ddsd)); |
2044 (DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL); | 2092 ddsd.dwSize = sizeof(ddsd); |
2045 } | 2093 result = IDirectDrawSurface3_Lock(dd_surface, NULL, &ddsd, |
2046 if ( result != DD_OK ) { | 2094 (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), NULL); |
2047 SetDDerror("DirectDrawSurface3::Lock", result); | 2095 if (result == DDERR_SURFACELOST) { |
2048 return(-1); | 2096 result = IDirectDrawSurface3_Restore(surface->hwdata->dd_surface); |
2049 } | 2097 result = IDirectDrawSurface3_Lock(dd_surface, NULL, &ddsd, |
2050 /* Pitch might have changed -- recalculate pitch and offset */ | 2098 (DDLOCK_NOSYSLOCK | DDLOCK_WAIT), |
2099 NULL); | |
2100 } | |
2101 if (result != DD_OK) { | |
2102 SetDDerror("DirectDrawSurface3::Lock", result); | |
2103 return (-1); | |
2104 } | |
2105 /* Pitch might have changed -- recalculate pitch and offset */ | |
2051 #if defined(NONAMELESSUNION) | 2106 #if defined(NONAMELESSUNION) |
2052 if ( surface->pitch != ddsd.u1.lPitch ) { | 2107 if (surface->pitch != ddsd.u1.lPitch) { |
2053 surface->pitch = ddsd.u1.lPitch; | 2108 surface->pitch = ddsd.u1.lPitch; |
2054 #else | 2109 #else |
2055 if ( surface->pitch != ddsd.lPitch ) { | 2110 if (surface->pitch != ddsd.lPitch) { |
2056 surface->pitch = (Uint16)ddsd.lPitch; | 2111 surface->pitch = (Uint16) ddsd.lPitch; |
2057 #endif | 2112 #endif |
2058 surface->offset = | 2113 surface->offset = |
2059 ((ddsd.dwHeight-surface->h)/2)*surface->pitch + | 2114 ((ddsd.dwHeight - surface->h) / 2) * surface->pitch + |
2060 ((ddsd.dwWidth-surface->w)/2)* | 2115 ((ddsd.dwWidth - surface->w) / 2) * |
2061 surface->format->BytesPerPixel; | 2116 surface->format->BytesPerPixel; |
2062 } | 2117 } |
2063 surface->pixels = ddsd.lpSurface; | 2118 surface->pixels = ddsd.lpSurface; |
2064 return(0); | 2119 return (0); |
2065 } | 2120 } |
2066 | 2121 |
2067 static void DX5_UnlockHWSurface(_THIS, SDL_Surface *surface) | 2122 static void |
2068 { | 2123 DX5_UnlockHWSurface(_THIS, SDL_Surface * surface) |
2069 IDirectDrawSurface3_Unlock(surface->hwdata->dd_writebuf, NULL); | 2124 { |
2070 surface->pixels = NULL; | 2125 IDirectDrawSurface3_Unlock(surface->hwdata->dd_writebuf, NULL); |
2071 } | 2126 surface->pixels = NULL; |
2072 | 2127 } |
2073 static int DX5_FlipHWSurface(_THIS, SDL_Surface *surface) | 2128 |
2074 { | 2129 static int |
2075 HRESULT result; | 2130 DX5_FlipHWSurface(_THIS, SDL_Surface * surface) |
2076 LPDIRECTDRAWSURFACE3 dd_surface; | 2131 { |
2077 | 2132 HRESULT result; |
2078 dd_surface = surface->hwdata->dd_surface; | 2133 LPDIRECTDRAWSURFACE3 dd_surface; |
2079 | 2134 |
2080 /* to prevent big slowdown on fast computers, wait here instead of driver ring 0 code */ | 2135 dd_surface = surface->hwdata->dd_surface; |
2081 /* Dmitry Yakimov (ftech@tula.net) */ | 2136 |
2082 while(IDirectDrawSurface3_GetFlipStatus(dd_surface, DDGBS_ISBLTDONE) == DDERR_WASSTILLDRAWING); | 2137 /* to prevent big slowdown on fast computers, wait here instead of driver ring 0 code */ |
2083 | 2138 /* Dmitry Yakimov (ftech@tula.net) */ |
2084 result = IDirectDrawSurface3_Flip(dd_surface, NULL, DDFLIP_WAIT); | 2139 while (IDirectDrawSurface3_GetFlipStatus(dd_surface, DDGBS_ISBLTDONE) == |
2085 if ( result == DDERR_SURFACELOST ) { | 2140 DDERR_WASSTILLDRAWING); |
2086 result = IDirectDrawSurface3_Restore( | 2141 |
2087 surface->hwdata->dd_surface); | 2142 result = IDirectDrawSurface3_Flip(dd_surface, NULL, DDFLIP_WAIT); |
2088 while(IDirectDrawSurface3_GetFlipStatus(dd_surface, DDGBS_ISBLTDONE) == DDERR_WASSTILLDRAWING); | 2143 if (result == DDERR_SURFACELOST) { |
2089 result = IDirectDrawSurface3_Flip(dd_surface, NULL, DDFLIP_WAIT); | 2144 result = IDirectDrawSurface3_Restore(surface->hwdata->dd_surface); |
2090 } | 2145 while (IDirectDrawSurface3_GetFlipStatus |
2091 if ( result != DD_OK ) { | 2146 (dd_surface, DDGBS_ISBLTDONE) == DDERR_WASSTILLDRAWING); |
2092 SetDDerror("DirectDrawSurface3::Flip", result); | 2147 result = IDirectDrawSurface3_Flip(dd_surface, NULL, DDFLIP_WAIT); |
2093 return(-1); | 2148 } |
2094 } | 2149 if (result != DD_OK) { |
2095 return(0); | 2150 SetDDerror("DirectDrawSurface3::Flip", result); |
2096 } | 2151 return (-1); |
2097 | 2152 } |
2098 static void DX5_FreeHWSurface(_THIS, SDL_Surface *surface) | 2153 return (0); |
2099 { | 2154 } |
2100 if ( surface->hwdata ) { | 2155 |
2101 if ( surface->hwdata->dd_surface != SDL_primary ) { | 2156 static void |
2102 IDirectDrawSurface3_Release(surface->hwdata->dd_surface); | 2157 DX5_FreeHWSurface(_THIS, SDL_Surface * surface) |
2103 } | 2158 { |
2104 SDL_free(surface->hwdata); | 2159 if (surface->hwdata) { |
2105 surface->hwdata = NULL; | 2160 if (surface->hwdata->dd_surface != SDL_primary) { |
2106 } | 2161 IDirectDrawSurface3_Release(surface->hwdata->dd_surface); |
2107 } | 2162 } |
2108 | 2163 SDL_free(surface->hwdata); |
2109 void DX5_WindowUpdate(_THIS, int numrects, SDL_Rect *rects) | 2164 surface->hwdata = NULL; |
2110 { | 2165 } |
2111 HRESULT result; | 2166 } |
2112 int i; | 2167 |
2113 RECT src, dst; | 2168 void |
2114 | 2169 DX5_WindowUpdate(_THIS, int numrects, SDL_Rect * rects) |
2115 for ( i=0; i<numrects; ++i ) { | 2170 { |
2116 src.top = (LONG)rects[i].y; | 2171 HRESULT result; |
2117 src.bottom = (LONG)rects[i].y+rects[i].h; | 2172 int i; |
2118 src.left = (LONG)rects[i].x; | 2173 RECT src, dst; |
2119 src.right = (LONG)rects[i].x+rects[i].w; | 2174 |
2120 dst.top = SDL_bounds.top+src.top; | 2175 for (i = 0; i < numrects; ++i) { |
2121 dst.left = SDL_bounds.left+src.left; | 2176 src.top = (LONG) rects[i].y; |
2122 dst.bottom = SDL_bounds.top+src.bottom; | 2177 src.bottom = (LONG) rects[i].y + rects[i].h; |
2123 dst.right = SDL_bounds.left+src.right; | 2178 src.left = (LONG) rects[i].x; |
2124 result = IDirectDrawSurface3_Blt(SDL_primary, &dst, | 2179 src.right = (LONG) rects[i].x + rects[i].w; |
2125 this->screen->hwdata->dd_surface, &src, | 2180 dst.top = SDL_bounds.top + src.top; |
2126 DDBLT_WAIT, NULL); | 2181 dst.left = SDL_bounds.left + src.left; |
2127 /* Doh! Check for lost surface and restore it */ | 2182 dst.bottom = SDL_bounds.top + src.bottom; |
2128 if ( result == DDERR_SURFACELOST ) { | 2183 dst.right = SDL_bounds.left + src.right; |
2129 IDirectDrawSurface3_Restore(SDL_primary); | 2184 result = IDirectDrawSurface3_Blt(SDL_primary, &dst, |
2130 IDirectDrawSurface3_Blt(SDL_primary, &dst, | 2185 this->screen->hwdata->dd_surface, |
2131 this->screen->hwdata->dd_surface, &src, | 2186 &src, DDBLT_WAIT, NULL); |
2132 DDBLT_WAIT, NULL); | 2187 /* Doh! Check for lost surface and restore it */ |
2133 } | 2188 if (result == DDERR_SURFACELOST) { |
2134 } | 2189 IDirectDrawSurface3_Restore(SDL_primary); |
2135 } | 2190 IDirectDrawSurface3_Blt(SDL_primary, &dst, |
2136 | 2191 this->screen->hwdata->dd_surface, |
2137 void DX5_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) | 2192 &src, DDBLT_WAIT, NULL); |
2193 } | |
2194 } | |
2195 } | |
2196 | |
2197 void | |
2198 DX5_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) | |
2138 { | 2199 { |
2139 } | 2200 } |
2140 | 2201 |
2141 /* Compress a full palette into the limited number of colors given to us | 2202 /* Compress a full palette into the limited number of colors given to us |
2142 by windows. | 2203 by windows. |
2162 int r = (A.r - B.r); \ | 2223 int r = (A.r - B.r); \ |
2163 int g = (A.g - B.g); \ | 2224 int g = (A.g - B.g); \ |
2164 int b = (A.b - B.b); \ | 2225 int b = (A.b - B.b); \ |
2165 (r*r + g*g + b*b); \ | 2226 (r*r + g*g + b*b); \ |
2166 }) | 2227 }) |
2167 static void DX5_CompressPalette(_THIS, SDL_Color *colors, int ncolors, int maxcolors) | 2228 static void |
2229 DX5_CompressPalette(_THIS, SDL_Color * colors, int ncolors, int maxcolors) | |
2168 { | 2230 { |
2169 #ifdef SIMPLE_COMPRESSION | 2231 #ifdef SIMPLE_COMPRESSION |
2170 int i, j; | 2232 int i, j; |
2171 #else | 2233 #else |
2172 static SDL_Color zero = { 0, 0, 0, 0 }; | 2234 static SDL_Color zero = { 0, 0, 0, 0 }; |
2173 int i, j; | 2235 int i, j; |
2174 int max, dist; | 2236 int max, dist; |
2175 int prev, next; | 2237 int prev, next; |
2176 int *pool; | 2238 int *pool; |
2177 int *seen, *order; | 2239 int *seen, *order; |
2178 #endif | 2240 #endif |
2179 | 2241 |
2180 /* Does this happen? */ | 2242 /* Does this happen? */ |
2181 if ( maxcolors > ncolors ) { | 2243 if (maxcolors > ncolors) { |
2182 maxcolors = ncolors; | 2244 maxcolors = ncolors; |
2183 } | 2245 } |
2184 | |
2185 #ifdef SIMPLE_COMPRESSION | 2246 #ifdef SIMPLE_COMPRESSION |
2186 /* Just copy the first "maxcolors" colors */ | 2247 /* Just copy the first "maxcolors" colors */ |
2187 for ( j=10, i=0; i<maxcolors; ++i, ++j ) { | 2248 for (j = 10, i = 0; i < maxcolors; ++i, ++j) { |
2188 SDL_colors[j].peRed = colors[i].r; | 2249 SDL_colors[j].peRed = colors[i].r; |
2189 SDL_colors[j].peGreen = colors[i].g; | 2250 SDL_colors[j].peGreen = colors[i].g; |
2190 SDL_colors[j].peBlue = colors[i].b; | 2251 SDL_colors[j].peBlue = colors[i].b; |
2191 } | 2252 } |
2192 #else | 2253 #else |
2193 /* Allocate memory for the arrays we use */ | 2254 /* Allocate memory for the arrays we use */ |
2194 pool = SDL_stack_alloc(int, 2*ncolors); | 2255 pool = SDL_stack_alloc(int, 2 * ncolors); |
2195 if ( pool == NULL ) { | 2256 if (pool == NULL) { |
2196 /* No worries, just return */; | 2257 /* No worries, just return */ ; |
2197 return; | 2258 return; |
2198 } | 2259 } |
2199 seen = pool; | 2260 seen = pool; |
2200 SDL_memset(seen, 0, ncolors*sizeof(int)); | 2261 SDL_memset(seen, 0, ncolors * sizeof(int)); |
2201 order = pool+ncolors; | 2262 order = pool + ncolors; |
2202 | 2263 |
2203 /* Start with the brightest color */ | 2264 /* Start with the brightest color */ |
2204 max = 0; | 2265 max = 0; |
2205 for ( i=0; i<ncolors; ++i ) { | 2266 for (i = 0; i < ncolors; ++i) { |
2206 dist = CS_CS_DIST(zero, colors[i]); | 2267 dist = CS_CS_DIST(zero, colors[i]); |
2207 if ( dist >= max ) { | 2268 if (dist >= max) { |
2208 max = dist; | 2269 max = dist; |
2209 next = i; | 2270 next = i; |
2210 } | 2271 } |
2211 } | 2272 } |
2212 j = 0; | 2273 j = 0; |
2213 order[j++] = next; | 2274 order[j++] = next; |
2214 seen[next] = 1; | 2275 seen[next] = 1; |
2215 prev = next; | 2276 prev = next; |
2216 | 2277 |
2217 /* Keep going through all the colors */ | 2278 /* Keep going through all the colors */ |
2218 while ( j < maxcolors ) { | 2279 while (j < maxcolors) { |
2219 max = 0; | 2280 max = 0; |
2220 for ( i=0; i<ncolors; ++i ) { | 2281 for (i = 0; i < ncolors; ++i) { |
2221 if ( seen[i] ) { | 2282 if (seen[i]) { |
2222 continue; | 2283 continue; |
2223 } | 2284 } |
2224 dist = CS_CS_DIST(colors[i], colors[prev]); | 2285 dist = CS_CS_DIST(colors[i], colors[prev]); |
2225 if ( dist >= max ) { | 2286 if (dist >= max) { |
2226 max = dist; | 2287 max = dist; |
2227 next = i; | 2288 next = i; |
2228 } | 2289 } |
2229 } | 2290 } |
2230 order[j++] = next; | 2291 order[j++] = next; |
2231 seen[next] = 1; | 2292 seen[next] = 1; |
2232 prev = next; | 2293 prev = next; |
2233 } | 2294 } |
2234 | 2295 |
2235 /* Compress the colors to the palette */ | 2296 /* Compress the colors to the palette */ |
2236 for ( j=10, i=0; i<maxcolors; ++i, ++j ) { | 2297 for (j = 10, i = 0; i < maxcolors; ++i, ++j) { |
2237 SDL_colors[j].peRed = colors[order[i]].r; | 2298 SDL_colors[j].peRed = colors[order[i]].r; |
2238 SDL_colors[j].peGreen = colors[order[i]].g; | 2299 SDL_colors[j].peGreen = colors[order[i]].g; |
2239 SDL_colors[j].peBlue = colors[order[i]].b; | 2300 SDL_colors[j].peBlue = colors[order[i]].b; |
2240 } | 2301 } |
2241 SDL_stack_free(pool); | 2302 SDL_stack_free(pool); |
2242 #endif /* SIMPLE_COMPRESSION */ | 2303 #endif /* SIMPLE_COMPRESSION */ |
2243 } | 2304 } |
2244 | 2305 |
2245 /* Set the system colormap in both fullscreen and windowed modes */ | 2306 /* Set the system colormap in both fullscreen and windowed modes */ |
2246 int DX5_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | 2307 int |
2247 { | 2308 DX5_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) |
2248 int i; | 2309 { |
2249 int alloct_all; | 2310 int i; |
2250 | 2311 int alloct_all; |
2251 /* Copy palette colors into display palette */ | 2312 |
2252 alloct_all = 0; | 2313 /* Copy palette colors into display palette */ |
2253 if ( SDL_palette != NULL ) { | 2314 alloct_all = 0; |
2254 if ( (this->screen->flags&SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | 2315 if (SDL_palette != NULL) { |
2255 /* We can set all entries explicitly */ | 2316 if ((this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { |
2256 for ( i=0; i< ncolors; ++i ) { | 2317 /* We can set all entries explicitly */ |
2257 int j = firstcolor + i; | 2318 for (i = 0; i < ncolors; ++i) { |
2258 SDL_colors[j].peRed = colors[i].r; | 2319 int j = firstcolor + i; |
2259 SDL_colors[j].peGreen = colors[i].g; | 2320 SDL_colors[j].peRed = colors[i].r; |
2260 SDL_colors[j].peBlue = colors[i].b; | 2321 SDL_colors[j].peGreen = colors[i].g; |
2261 } | 2322 SDL_colors[j].peBlue = colors[i].b; |
2262 IDirectDrawPalette_SetEntries(SDL_palette, 0, | 2323 } |
2263 firstcolor, ncolors, &SDL_colors[firstcolor]); | 2324 IDirectDrawPalette_SetEntries(SDL_palette, 0, |
2264 alloct_all = 1; | 2325 firstcolor, ncolors, |
2265 } else { | 2326 &SDL_colors[firstcolor]); |
2266 /* Grab the 236 most diverse colors in the palette */ | 2327 alloct_all = 1; |
2267 DX5_CompressPalette(this, colors, ncolors, 236); | 2328 } else { |
2268 /* This sends an WM_PALETTECHANGED message to us */ | 2329 /* Grab the 236 most diverse colors in the palette */ |
2269 colorchange_expected = 1; | 2330 DX5_CompressPalette(this, colors, ncolors, 236); |
2270 IDirectDrawPalette_SetEntries(SDL_palette, 0, | 2331 /* This sends an WM_PALETTECHANGED message to us */ |
2271 0, 256, SDL_colors); | 2332 colorchange_expected = 1; |
2272 } | 2333 IDirectDrawPalette_SetEntries(SDL_palette, 0, 0, 256, SDL_colors); |
2273 } | 2334 } |
2274 return(alloct_all); | 2335 } |
2336 return (alloct_all); | |
2275 } | 2337 } |
2276 | 2338 |
2277 /* Gamma code is only available on DirectX 7 and newer */ | 2339 /* Gamma code is only available on DirectX 7 and newer */ |
2278 static int DX5_SetGammaRamp(_THIS, Uint16 *ramp) | 2340 static int |
2341 DX5_SetGammaRamp(_THIS, Uint16 * ramp) | |
2279 { | 2342 { |
2280 #ifdef IDirectDrawGammaControl_SetGammaRamp | 2343 #ifdef IDirectDrawGammaControl_SetGammaRamp |
2281 LPDIRECTDRAWGAMMACONTROL gamma; | 2344 LPDIRECTDRAWGAMMACONTROL gamma; |
2282 DDGAMMARAMP gamma_ramp; | 2345 DDGAMMARAMP gamma_ramp; |
2283 HRESULT result; | 2346 HRESULT result; |
2284 #endif | 2347 #endif |
2285 | 2348 |
2286 /* In windowed or OpenGL mode, use windib gamma code */ | 2349 /* In windowed or OpenGL mode, use windib gamma code */ |
2287 if ( ! DDRAW_FULLSCREEN() ) { | 2350 if (!DDRAW_FULLSCREEN()) { |
2288 return DIB_SetGammaRamp(this, ramp); | 2351 return DIB_SetGammaRamp(this, ramp); |
2289 } | 2352 } |
2290 | |
2291 #ifndef IDirectDrawGammaControl_SetGammaRamp | 2353 #ifndef IDirectDrawGammaControl_SetGammaRamp |
2292 SDL_SetError("SDL compiled without DirectX gamma ramp support"); | 2354 SDL_SetError("SDL compiled without DirectX gamma ramp support"); |
2293 return -1; | 2355 return -1; |
2294 #else | 2356 #else |
2295 /* Check for a video mode! */ | 2357 /* Check for a video mode! */ |
2296 if ( ! SDL_primary ) { | 2358 if (!SDL_primary) { |
2297 SDL_SetError("A video mode must be set for gamma correction"); | 2359 SDL_SetError("A video mode must be set for gamma correction"); |
2298 return(-1); | 2360 return (-1); |
2299 } | 2361 } |
2300 | 2362 |
2301 /* Get the gamma control object */ | 2363 /* Get the gamma control object */ |
2302 result = IDirectDrawSurface3_QueryInterface(SDL_primary, | 2364 result = IDirectDrawSurface3_QueryInterface(SDL_primary, |
2303 &IID_IDirectDrawGammaControl, (LPVOID *)&gamma); | 2365 &IID_IDirectDrawGammaControl, |
2304 if ( result != DD_OK ) { | 2366 (LPVOID *) & gamma); |
2305 SetDDerror("DirectDrawSurface3::QueryInterface(GAMMA)", result); | 2367 if (result != DD_OK) { |
2306 return(-1); | 2368 SetDDerror("DirectDrawSurface3::QueryInterface(GAMMA)", result); |
2307 } | 2369 return (-1); |
2308 | 2370 } |
2309 /* Set up the gamma ramp */ | 2371 |
2310 SDL_memcpy(gamma_ramp.red, &ramp[0*256], 256*sizeof(*ramp)); | 2372 /* Set up the gamma ramp */ |
2311 SDL_memcpy(gamma_ramp.green, &ramp[1*256], 256*sizeof(*ramp)); | 2373 SDL_memcpy(gamma_ramp.red, &ramp[0 * 256], 256 * sizeof(*ramp)); |
2312 SDL_memcpy(gamma_ramp.blue, &ramp[2*256], 256*sizeof(*ramp)); | 2374 SDL_memcpy(gamma_ramp.green, &ramp[1 * 256], 256 * sizeof(*ramp)); |
2313 result = IDirectDrawGammaControl_SetGammaRamp(gamma, 0, &gamma_ramp); | 2375 SDL_memcpy(gamma_ramp.blue, &ramp[2 * 256], 256 * sizeof(*ramp)); |
2314 if ( result != DD_OK ) { | 2376 result = IDirectDrawGammaControl_SetGammaRamp(gamma, 0, &gamma_ramp); |
2315 SetDDerror("DirectDrawGammaControl::SetGammaRamp()", result); | 2377 if (result != DD_OK) { |
2316 } | 2378 SetDDerror("DirectDrawGammaControl::SetGammaRamp()", result); |
2317 | 2379 } |
2318 /* Release the interface and return */ | 2380 |
2319 IDirectDrawGammaControl_Release(gamma); | 2381 /* Release the interface and return */ |
2320 return (result == DD_OK) ? 0 : -1; | 2382 IDirectDrawGammaControl_Release(gamma); |
2383 return (result == DD_OK) ? 0 : -1; | |
2321 #endif /* !IDirectDrawGammaControl_SetGammaRamp */ | 2384 #endif /* !IDirectDrawGammaControl_SetGammaRamp */ |
2322 } | 2385 } |
2323 | 2386 |
2324 static int DX5_GetGammaRamp(_THIS, Uint16 *ramp) | 2387 static int |
2388 DX5_GetGammaRamp(_THIS, Uint16 * ramp) | |
2325 { | 2389 { |
2326 #ifdef IDirectDrawGammaControl_SetGammaRamp | 2390 #ifdef IDirectDrawGammaControl_SetGammaRamp |
2327 LPDIRECTDRAWGAMMACONTROL gamma; | 2391 LPDIRECTDRAWGAMMACONTROL gamma; |
2328 DDGAMMARAMP gamma_ramp; | 2392 DDGAMMARAMP gamma_ramp; |
2329 HRESULT result; | 2393 HRESULT result; |
2330 #endif | 2394 #endif |
2331 | 2395 |
2332 /* In windowed or OpenGL mode, use windib gamma code */ | 2396 /* In windowed or OpenGL mode, use windib gamma code */ |
2333 if ( ! DDRAW_FULLSCREEN() ) { | 2397 if (!DDRAW_FULLSCREEN()) { |
2334 return DIB_GetGammaRamp(this, ramp); | 2398 return DIB_GetGammaRamp(this, ramp); |
2335 } | 2399 } |
2336 | |
2337 #ifndef IDirectDrawGammaControl_SetGammaRamp | 2400 #ifndef IDirectDrawGammaControl_SetGammaRamp |
2338 SDL_SetError("SDL compiled without DirectX gamma ramp support"); | 2401 SDL_SetError("SDL compiled without DirectX gamma ramp support"); |
2339 return -1; | 2402 return -1; |
2340 #else | 2403 #else |
2341 /* Check for a video mode! */ | 2404 /* Check for a video mode! */ |
2342 if ( ! SDL_primary ) { | 2405 if (!SDL_primary) { |
2343 SDL_SetError("A video mode must be set for gamma correction"); | 2406 SDL_SetError("A video mode must be set for gamma correction"); |
2344 return(-1); | 2407 return (-1); |
2345 } | 2408 } |
2346 | 2409 |
2347 /* Get the gamma control object */ | 2410 /* Get the gamma control object */ |
2348 result = IDirectDrawSurface3_QueryInterface(SDL_primary, | 2411 result = IDirectDrawSurface3_QueryInterface(SDL_primary, |
2349 &IID_IDirectDrawGammaControl, (LPVOID *)&gamma); | 2412 &IID_IDirectDrawGammaControl, |
2350 if ( result != DD_OK ) { | 2413 (LPVOID *) & gamma); |
2351 SetDDerror("DirectDrawSurface3::QueryInterface(GAMMA)", result); | 2414 if (result != DD_OK) { |
2352 return(-1); | 2415 SetDDerror("DirectDrawSurface3::QueryInterface(GAMMA)", result); |
2353 } | 2416 return (-1); |
2354 | 2417 } |
2355 /* Set up the gamma ramp */ | 2418 |
2356 result = IDirectDrawGammaControl_GetGammaRamp(gamma, 0, &gamma_ramp); | 2419 /* Set up the gamma ramp */ |
2357 if ( result == DD_OK ) { | 2420 result = IDirectDrawGammaControl_GetGammaRamp(gamma, 0, &gamma_ramp); |
2358 SDL_memcpy(&ramp[0*256], gamma_ramp.red, 256*sizeof(*ramp)); | 2421 if (result == DD_OK) { |
2359 SDL_memcpy(&ramp[1*256], gamma_ramp.green, 256*sizeof(*ramp)); | 2422 SDL_memcpy(&ramp[0 * 256], gamma_ramp.red, 256 * sizeof(*ramp)); |
2360 SDL_memcpy(&ramp[2*256], gamma_ramp.blue, 256*sizeof(*ramp)); | 2423 SDL_memcpy(&ramp[1 * 256], gamma_ramp.green, 256 * sizeof(*ramp)); |
2361 } else { | 2424 SDL_memcpy(&ramp[2 * 256], gamma_ramp.blue, 256 * sizeof(*ramp)); |
2362 SetDDerror("DirectDrawGammaControl::GetGammaRamp()", result); | 2425 } else { |
2363 } | 2426 SetDDerror("DirectDrawGammaControl::GetGammaRamp()", result); |
2364 | 2427 } |
2365 /* Release the interface and return */ | 2428 |
2366 IDirectDrawGammaControl_Release(gamma); | 2429 /* Release the interface and return */ |
2367 return (result == DD_OK) ? 0 : -1; | 2430 IDirectDrawGammaControl_Release(gamma); |
2431 return (result == DD_OK) ? 0 : -1; | |
2368 #endif /* !IDirectDrawGammaControl_SetGammaRamp */ | 2432 #endif /* !IDirectDrawGammaControl_SetGammaRamp */ |
2369 } | 2433 } |
2370 | 2434 |
2371 void DX5_VideoQuit(_THIS) | 2435 void |
2372 { | 2436 DX5_VideoQuit(_THIS) |
2373 int i, j; | 2437 { |
2374 | 2438 int i, j; |
2375 /* If we're fullscreen GL, we need to reset the display */ | 2439 |
2376 if ( this->screen != NULL ) { | 2440 /* If we're fullscreen GL, we need to reset the display */ |
2441 if (this->screen != NULL) { | |
2377 #ifndef NO_CHANGEDISPLAYSETTINGS | 2442 #ifndef NO_CHANGEDISPLAYSETTINGS |
2378 if ( (this->screen->flags & (SDL_OPENGL|SDL_FULLSCREEN)) == | 2443 if ((this->screen->flags & (SDL_INTERNALOPENGL | SDL_FULLSCREEN)) == |
2379 (SDL_OPENGL|SDL_FULLSCREEN) ) { | 2444 (SDL_INTERNALOPENGL | SDL_FULLSCREEN)) { |
2380 ChangeDisplaySettings(NULL, 0); | 2445 ChangeDisplaySettings(NULL, 0); |
2381 ShowWindow(SDL_Window, SW_HIDE); | 2446 ShowWindow(SDL_Window, SW_HIDE); |
2382 } | 2447 } |
2383 #endif | 2448 #endif |
2384 if ( this->screen->flags & SDL_OPENGL ) { | 2449 if (this->screen->flags & SDL_INTERNALOPENGL) { |
2385 WIN_GL_ShutDown(this); | 2450 WIN_GL_ShutDown(this); |
2386 } | 2451 } |
2387 } | 2452 } |
2388 | 2453 |
2389 /* Free any palettes we used */ | 2454 /* Free any palettes we used */ |
2390 if ( SDL_palette != NULL ) { | 2455 if (SDL_palette != NULL) { |
2391 IDirectDrawPalette_Release(SDL_palette); | 2456 IDirectDrawPalette_Release(SDL_palette); |
2392 SDL_palette = NULL; | 2457 SDL_palette = NULL; |
2393 } | 2458 } |
2394 | 2459 |
2395 /* Allow the primary surface to be freed */ | 2460 /* Allow the primary surface to be freed */ |
2396 if ( SDL_primary != NULL ) { | 2461 if (SDL_primary != NULL) { |
2397 SDL_primary = NULL; | 2462 SDL_primary = NULL; |
2398 } | 2463 } |
2399 | 2464 |
2400 /* Free video mode lists */ | 2465 /* Free video mode lists */ |
2401 for ( i=0; i<NUM_MODELISTS; ++i ) { | 2466 for (i = 0; i < NUM_MODELISTS; ++i) { |
2402 if ( SDL_modelist[i] != NULL ) { | 2467 if (SDL_modelist[i] != NULL) { |
2403 for ( j=0; SDL_modelist[i][j]; ++j ) | 2468 for (j = 0; SDL_modelist[i][j]; ++j) |
2404 SDL_free(SDL_modelist[i][j]); | 2469 SDL_free(SDL_modelist[i][j]); |
2405 SDL_free(SDL_modelist[i]); | 2470 SDL_free(SDL_modelist[i]); |
2406 SDL_modelist[i] = NULL; | 2471 SDL_modelist[i] = NULL; |
2407 } | 2472 } |
2408 } | 2473 } |
2409 | 2474 |
2410 /* Free the window */ | 2475 /* Free the window */ |
2411 DIB_QuitGamma(this); | 2476 DIB_QuitGamma(this); |
2412 if ( SDL_Window ) { | 2477 if (SDL_Window) { |
2413 DX5_DestroyWindow(this); | 2478 DX5_DestroyWindow(this); |
2414 } | 2479 } |
2415 | 2480 |
2416 /* Free our window icon */ | 2481 /* Free our window icon */ |
2417 if ( screen_icn ) { | 2482 if (screen_icn) { |
2418 DestroyIcon(screen_icn); | 2483 DestroyIcon(screen_icn); |
2419 screen_icn = NULL; | 2484 screen_icn = NULL; |
2420 } | 2485 } |
2421 } | 2486 } |
2422 | 2487 |
2423 /* Exported for the windows message loop only */ | 2488 /* Exported for the windows message loop only */ |
2424 void DX5_RealizePalette(_THIS) | 2489 void |
2425 { | 2490 DX5_RealizePalette(_THIS) |
2426 if ( SDL_palette ) { | 2491 { |
2427 IDirectDrawSurface3_SetPalette(SDL_primary, SDL_palette); | 2492 if (SDL_palette) { |
2428 } | 2493 IDirectDrawSurface3_SetPalette(SDL_primary, SDL_palette); |
2429 } | 2494 } |
2430 static void DX5_Recolor8Bit(_THIS, SDL_Surface *surface, Uint8 *mapping) | 2495 } |
2431 { | 2496 static void |
2432 int row, col; | 2497 DX5_Recolor8Bit(_THIS, SDL_Surface * surface, Uint8 * mapping) |
2433 Uint8 *pixels; | 2498 { |
2434 | 2499 int row, col; |
2435 if ( surface->w && surface->h ) { | 2500 Uint8 *pixels; |
2436 if ( (surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) { | 2501 |
2437 if ( this->LockHWSurface(this, surface) < 0 ) { | 2502 if (surface->w && surface->h) { |
2438 return; | 2503 if ((surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { |
2439 } | 2504 if (this->LockHWSurface(this, surface) < 0) { |
2440 } | 2505 return; |
2441 for ( row=0; row<surface->h; ++row ) { | 2506 } |
2442 pixels = (Uint8 *)surface->pixels+row*surface->pitch; | 2507 } |
2443 for ( col=0; col<surface->w; ++col, ++pixels ) { | 2508 for (row = 0; row < surface->h; ++row) { |
2444 *pixels = mapping[*pixels]; | 2509 pixels = (Uint8 *) surface->pixels + row * surface->pitch; |
2445 } | 2510 for (col = 0; col < surface->w; ++col, ++pixels) { |
2446 } | 2511 *pixels = mapping[*pixels]; |
2447 if ( (surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) { | 2512 } |
2448 this->UnlockHWSurface(this, surface); | 2513 } |
2449 } | 2514 if ((surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { |
2450 SDL_UpdateRect(surface, 0, 0, 0, 0); | 2515 this->UnlockHWSurface(this, surface); |
2451 } | 2516 } |
2452 } | 2517 SDL_UpdateRect(surface, 0, 0, 0, 0); |
2453 void DX5_PaletteChanged(_THIS, HWND window) | 2518 } |
2454 { | 2519 } |
2455 SDL_Palette *palette; | 2520 void |
2456 SDL_Color *saved = NULL; | 2521 DX5_PaletteChanged(_THIS, HWND window) |
2457 HDC hdc; | 2522 { |
2458 int i; | 2523 SDL_Palette *palette; |
2459 PALETTEENTRY *entries; | 2524 SDL_Color *saved = NULL; |
2460 | 2525 HDC hdc; |
2461 /* This is true when the window is closing */ | 2526 int i; |
2462 if ( (SDL_primary == NULL) || (SDL_VideoSurface == NULL) ) | 2527 PALETTEENTRY *entries; |
2463 return; | 2528 |
2464 | 2529 /* This is true when the window is closing */ |
2465 /* We need to get the colors as they were set */ | 2530 if ((SDL_primary == NULL) || (SDL_VideoSurface == NULL)) |
2466 palette = this->physpal; | 2531 return; |
2467 if(!palette) | 2532 |
2468 palette = SDL_VideoSurface->format->palette; | 2533 /* We need to get the colors as they were set */ |
2469 if ( palette == NULL ) { /* Sometimes we don't have a palette */ | 2534 palette = this->physpal; |
2470 return; | 2535 if (!palette) |
2471 } | 2536 palette = SDL_VideoSurface->format->palette; |
2472 entries = SDL_stack_alloc(PALETTEENTRY, palette->ncolors); | 2537 if (palette == NULL) { /* Sometimes we don't have a palette */ |
2473 hdc = GetDC(window); | 2538 return; |
2474 GetSystemPaletteEntries(hdc, 0, palette->ncolors, entries); | 2539 } |
2475 ReleaseDC(window, hdc); | 2540 entries = SDL_stack_alloc(PALETTEENTRY, palette->ncolors); |
2476 if ( ! colorchange_expected ) { | 2541 hdc = GetDC(window); |
2477 saved = SDL_stack_alloc(SDL_Color, palette->ncolors); | 2542 GetSystemPaletteEntries(hdc, 0, palette->ncolors, entries); |
2478 SDL_memcpy(saved, palette->colors, | 2543 ReleaseDC(window, hdc); |
2479 palette->ncolors*sizeof(SDL_Color)); | 2544 if (!colorchange_expected) { |
2480 } | 2545 saved = SDL_stack_alloc(SDL_Color, palette->ncolors); |
2481 for ( i=0; i<palette->ncolors; ++i ) { | 2546 SDL_memcpy(saved, palette->colors, |
2482 palette->colors[i].r = entries[i].peRed; | 2547 palette->ncolors * sizeof(SDL_Color)); |
2483 palette->colors[i].g = entries[i].peGreen; | 2548 } |
2484 palette->colors[i].b = entries[i].peBlue; | 2549 for (i = 0; i < palette->ncolors; ++i) { |
2485 } | 2550 palette->colors[i].r = entries[i].peRed; |
2486 SDL_stack_free(entries); | 2551 palette->colors[i].g = entries[i].peGreen; |
2487 if ( ! colorchange_expected ) { | 2552 palette->colors[i].b = entries[i].peBlue; |
2488 Uint8 mapping[256]; | 2553 } |
2489 | 2554 SDL_stack_free(entries); |
2490 SDL_memset(mapping, 0, sizeof(mapping)); | 2555 if (!colorchange_expected) { |
2491 for ( i=0; i<palette->ncolors; ++i ) { | 2556 Uint8 mapping[256]; |
2492 mapping[i] = SDL_FindColor(palette, | 2557 |
2493 saved[i].r, saved[i].g, saved[i].b); | 2558 SDL_memset(mapping, 0, sizeof(mapping)); |
2494 } | 2559 for (i = 0; i < palette->ncolors; ++i) { |
2495 DX5_Recolor8Bit(this, SDL_VideoSurface, mapping); | 2560 mapping[i] = SDL_FindColor(palette, |
2496 SDL_stack_free(saved); | 2561 saved[i].r, saved[i].g, saved[i].b); |
2497 } | 2562 } |
2498 colorchange_expected = 0; | 2563 DX5_Recolor8Bit(this, SDL_VideoSurface, mapping); |
2499 | 2564 SDL_stack_free(saved); |
2500 /* Notify all mapped surfaces of the change */ | 2565 } |
2501 SDL_FormatChanged(SDL_VideoSurface); | 2566 colorchange_expected = 0; |
2567 | |
2568 /* Notify all mapped surfaces of the change */ | |
2569 SDL_FormatChanged(SDL_VideoSurface); | |
2502 } | 2570 } |
2503 | 2571 |
2504 /* Exported for the windows message loop only */ | 2572 /* Exported for the windows message loop only */ |
2505 void DX5_WinPAINT(_THIS, HDC hdc) | 2573 void |
2506 { | 2574 DX5_WinPAINT(_THIS, HDC hdc) |
2507 SDL_UpdateRect(SDL_PublicSurface, 0, 0, 0, 0); | 2575 { |
2508 } | 2576 SDL_UpdateRect(SDL_PublicSurface, 0, 0, 0, 0); |
2577 } | |
2578 | |
2579 /* vi: set ts=4 sw=4 expandtab: */ |