diff options
author | Franklin Wei <git@fwei.tk> | 2018-02-07 20:04:46 -0500 |
---|---|---|
committer | Franklin Wei <git@fwei.tk> | 2018-03-12 20:52:01 -0400 |
commit | 6039eb05ba6d82ef56f2868c96654c552d117bf9 (patch) | |
tree | 9db7016bcbf66cfdf7b9bc998d84c6eaff9c8378 /apps/plugins/sdl/src/video/svga | |
parent | ef373c03b96b0be08babca581d9f10bccfd4931f (diff) | |
download | rockbox-6039eb05ba6d82ef56f2868c96654c552d117bf9.tar.gz rockbox-6039eb05ba6d82ef56f2868c96654c552d117bf9.zip |
sdl: remove non-rockbox drivers
We never use any of these other drivers, so having them around just takes
up space.
Change-Id: Iced812162df1fef3fd55522b7e700acb6c3bcd41
Diffstat (limited to 'apps/plugins/sdl/src/video/svga')
-rw-r--r-- | apps/plugins/sdl/src/video/svga/SDL_svgaevents.c | 412 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/svga/SDL_svgaevents_c.h | 35 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/svga/SDL_svgamouse.c | 33 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/svga/SDL_svgamouse_c.h | 26 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/svga/SDL_svgavideo.c | 584 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/svga/SDL_svgavideo.h | 58 |
6 files changed, 0 insertions, 1148 deletions
diff --git a/apps/plugins/sdl/src/video/svga/SDL_svgaevents.c b/apps/plugins/sdl/src/video/svga/SDL_svgaevents.c deleted file mode 100644 index 107a702cf3..0000000000 --- a/apps/plugins/sdl/src/video/svga/SDL_svgaevents.c +++ /dev/null | |||
@@ -1,412 +0,0 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | /* Handle the event stream, converting X11 events into SDL events */ | ||
25 | |||
26 | #include <vga.h> | ||
27 | #include <vgamouse.h> | ||
28 | #include <vgakeyboard.h> | ||
29 | #if defined(__LINUX__) | ||
30 | #include <linux/kd.h> | ||
31 | #include <linux/keyboard.h> | ||
32 | #elif defined(__FREEBSD__) | ||
33 | #include <sys/kbio.h> | ||
34 | #else | ||
35 | #error You must choose your operating system here | ||
36 | #endif | ||
37 | |||
38 | #include "../../events/SDL_sysevents.h" | ||
39 | #include "../../events/SDL_events_c.h" | ||
40 | #include "SDL_svgavideo.h" | ||
41 | #include "SDL_svgaevents_c.h" | ||
42 | |||
43 | /* The translation tables from a console scancode to a SDL keysym */ | ||
44 | #if defined(linux) | ||
45 | #define NUM_VGAKEYMAPS (1<<KG_CAPSSHIFT) | ||
46 | static Uint16 vga_keymap[NUM_VGAKEYMAPS][NR_KEYS]; | ||
47 | #elif defined(__FREEBSD__) | ||
48 | /* FIXME: Free the keymap when we shut down the video mode */ | ||
49 | static keymap_t *vga_keymap = NULL; | ||
50 | #else | ||
51 | #error You must choose your operating system here | ||
52 | #endif | ||
53 | static SDLKey keymap[128]; | ||
54 | static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym); | ||
55 | |||
56 | /* Ugh, we have to duplicate the kernel's keysym mapping code... | ||
57 | Oh, it's not so bad. :-) | ||
58 | |||
59 | FIXME: Add keyboard LED handling code | ||
60 | */ | ||
61 | #if defined(linux) | ||
62 | int SVGA_initkeymaps(int fd) | ||
63 | { | ||
64 | struct kbentry entry; | ||
65 | int map, i; | ||
66 | |||
67 | /* Load all the keysym mappings */ | ||
68 | for ( map=0; map<NUM_VGAKEYMAPS; ++map ) { | ||
69 | SDL_memset(vga_keymap[map], 0, NR_KEYS*sizeof(Uint16)); | ||
70 | for ( i=0; i<NR_KEYS; ++i ) { | ||
71 | entry.kb_table = map; | ||
72 | entry.kb_index = i; | ||
73 | if ( ioctl(fd, KDGKBENT, &entry) == 0 ) { | ||
74 | /* The "Enter" key is a special case */ | ||
75 | if ( entry.kb_value == K_ENTER ) { | ||
76 | entry.kb_value = K(KT_ASCII,13); | ||
77 | } | ||
78 | /* Handle numpad specially as well */ | ||
79 | if ( KTYP(entry.kb_value) == KT_PAD ) { | ||
80 | switch ( entry.kb_value ) { | ||
81 | case K_P0: | ||
82 | case K_P1: | ||
83 | case K_P2: | ||
84 | case K_P3: | ||
85 | case K_P4: | ||
86 | case K_P5: | ||
87 | case K_P6: | ||
88 | case K_P7: | ||
89 | case K_P8: | ||
90 | case K_P9: | ||
91 | vga_keymap[map][i]=entry.kb_value; | ||
92 | vga_keymap[map][i]+= '0'; | ||
93 | break; | ||
94 | case K_PPLUS: | ||
95 | vga_keymap[map][i]=K(KT_ASCII,'+'); | ||
96 | break; | ||
97 | case K_PMINUS: | ||
98 | vga_keymap[map][i]=K(KT_ASCII,'-'); | ||
99 | break; | ||
100 | case K_PSTAR: | ||
101 | vga_keymap[map][i]=K(KT_ASCII,'*'); | ||
102 | break; | ||
103 | case K_PSLASH: | ||
104 | vga_keymap[map][i]=K(KT_ASCII,'/'); | ||
105 | break; | ||
106 | case K_PENTER: | ||
107 | vga_keymap[map][i]=K(KT_ASCII,'\r'); | ||
108 | break; | ||
109 | case K_PCOMMA: | ||
110 | vga_keymap[map][i]=K(KT_ASCII,','); | ||
111 | break; | ||
112 | case K_PDOT: | ||
113 | vga_keymap[map][i]=K(KT_ASCII,'.'); | ||
114 | break; | ||
115 | default: | ||
116 | break; | ||
117 | } | ||
118 | } | ||
119 | /* Do the normal key translation */ | ||
120 | if ( (KTYP(entry.kb_value) == KT_LATIN) || | ||
121 | (KTYP(entry.kb_value) == KT_ASCII) || | ||
122 | (KTYP(entry.kb_value) == KT_LETTER) ) { | ||
123 | vga_keymap[map][i] = entry.kb_value; | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | return(0); | ||
129 | } | ||
130 | #elif defined(__FREEBSD__) | ||
131 | int SVGA_initkeymaps(int fd) | ||
132 | { | ||
133 | vga_keymap = SDL_malloc(sizeof(keymap_t)); | ||
134 | if ( ! vga_keymap ) { | ||
135 | SDL_OutOfMemory(); | ||
136 | return(-1); | ||
137 | } | ||
138 | if (ioctl(fd, GIO_KEYMAP, vga_keymap) == -1) { | ||
139 | SDL_free(vga_keymap); | ||
140 | vga_keymap = NULL; | ||
141 | SDL_SetError("Unable to get keyboard map"); | ||
142 | return(-1); | ||
143 | } | ||
144 | return(0); | ||
145 | } | ||
146 | #else | ||
147 | #error You must choose your operating system here | ||
148 | #endif | ||
149 | |||
150 | int posted = 0; | ||
151 | |||
152 | void SVGA_mousecallback(int button, int dx, int dy, | ||
153 | int u1,int u2,int u3, int u4) | ||
154 | { | ||
155 | if ( dx || dy ) { | ||
156 | posted += SDL_PrivateMouseMotion(0, 1, dx, dy); | ||
157 | } | ||
158 | if ( button & MOUSE_LEFTBUTTON ) { | ||
159 | if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)) ) { | ||
160 | posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0); | ||
161 | } | ||
162 | } else { | ||
163 | if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)) ) { | ||
164 | posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0); | ||
165 | } | ||
166 | } | ||
167 | if ( button & MOUSE_MIDDLEBUTTON ) { | ||
168 | if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(2)) ) { | ||
169 | posted += SDL_PrivateMouseButton(SDL_PRESSED, 2, 0, 0); | ||
170 | } | ||
171 | } else { | ||
172 | if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(2)) ) { | ||
173 | posted += SDL_PrivateMouseButton(SDL_RELEASED, 2, 0, 0); | ||
174 | } | ||
175 | } | ||
176 | if ( button & MOUSE_RIGHTBUTTON ) { | ||
177 | if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)) ) { | ||
178 | posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0); | ||
179 | } | ||
180 | } else { | ||
181 | if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)) ) { | ||
182 | posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0); | ||
183 | } | ||
184 | } | ||
185 | } | ||
186 | |||
187 | void SVGA_keyboardcallback(int scancode, int pressed) | ||
188 | { | ||
189 | SDL_keysym keysym; | ||
190 | |||
191 | if ( pressed ) { | ||
192 | posted += SDL_PrivateKeyboard(SDL_PRESSED, | ||
193 | TranslateKey(scancode, &keysym)); | ||
194 | } else { | ||
195 | posted += SDL_PrivateKeyboard(SDL_RELEASED, | ||
196 | TranslateKey(scancode, &keysym)); | ||
197 | } | ||
198 | } | ||
199 | |||
200 | void SVGA_PumpEvents(_THIS) | ||
201 | { | ||
202 | do { | ||
203 | posted = 0; | ||
204 | mouse_update(); | ||
205 | keyboard_update(); | ||
206 | } while ( posted ); | ||
207 | } | ||
208 | |||
209 | void SVGA_InitOSKeymap(_THIS) | ||
210 | { | ||
211 | int i; | ||
212 | |||
213 | /* Initialize the BeOS key translation table */ | ||
214 | for ( i=0; i<SDL_arraysize(keymap); ++i ) | ||
215 | keymap[i] = SDLK_UNKNOWN; | ||
216 | |||
217 | keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; | ||
218 | keymap[SCANCODE_1] = SDLK_1; | ||
219 | keymap[SCANCODE_2] = SDLK_2; | ||
220 | keymap[SCANCODE_3] = SDLK_3; | ||
221 | keymap[SCANCODE_4] = SDLK_4; | ||
222 | keymap[SCANCODE_5] = SDLK_5; | ||
223 | keymap[SCANCODE_6] = SDLK_6; | ||
224 | keymap[SCANCODE_7] = SDLK_7; | ||
225 | keymap[SCANCODE_8] = SDLK_8; | ||
226 | keymap[SCANCODE_9] = SDLK_9; | ||
227 | keymap[SCANCODE_0] = SDLK_0; | ||
228 | keymap[SCANCODE_MINUS] = SDLK_MINUS; | ||
229 | keymap[SCANCODE_EQUAL] = SDLK_EQUALS; | ||
230 | keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE; | ||
231 | keymap[SCANCODE_TAB] = SDLK_TAB; | ||
232 | keymap[SCANCODE_Q] = SDLK_q; | ||
233 | keymap[SCANCODE_W] = SDLK_w; | ||
234 | keymap[SCANCODE_E] = SDLK_e; | ||
235 | keymap[SCANCODE_R] = SDLK_r; | ||
236 | keymap[SCANCODE_T] = SDLK_t; | ||
237 | keymap[SCANCODE_Y] = SDLK_y; | ||
238 | keymap[SCANCODE_U] = SDLK_u; | ||
239 | keymap[SCANCODE_I] = SDLK_i; | ||
240 | keymap[SCANCODE_O] = SDLK_o; | ||
241 | keymap[SCANCODE_P] = SDLK_p; | ||
242 | keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET; | ||
243 | keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET; | ||
244 | keymap[SCANCODE_ENTER] = SDLK_RETURN; | ||
245 | keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL; | ||
246 | keymap[SCANCODE_A] = SDLK_a; | ||
247 | keymap[SCANCODE_S] = SDLK_s; | ||
248 | keymap[SCANCODE_D] = SDLK_d; | ||
249 | keymap[SCANCODE_F] = SDLK_f; | ||
250 | keymap[SCANCODE_G] = SDLK_g; | ||
251 | keymap[SCANCODE_H] = SDLK_h; | ||
252 | keymap[SCANCODE_J] = SDLK_j; | ||
253 | keymap[SCANCODE_K] = SDLK_k; | ||
254 | keymap[SCANCODE_L] = SDLK_l; | ||
255 | keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON; | ||
256 | keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE; | ||
257 | keymap[SCANCODE_GRAVE] = SDLK_BACKQUOTE; | ||
258 | keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT; | ||
259 | keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH; | ||
260 | keymap[SCANCODE_Z] = SDLK_z; | ||
261 | keymap[SCANCODE_X] = SDLK_x; | ||
262 | keymap[SCANCODE_C] = SDLK_c; | ||
263 | keymap[SCANCODE_V] = SDLK_v; | ||
264 | keymap[SCANCODE_B] = SDLK_b; | ||
265 | keymap[SCANCODE_N] = SDLK_n; | ||
266 | keymap[SCANCODE_M] = SDLK_m; | ||
267 | keymap[SCANCODE_COMMA] = SDLK_COMMA; | ||
268 | keymap[SCANCODE_PERIOD] = SDLK_PERIOD; | ||
269 | keymap[SCANCODE_SLASH] = SDLK_SLASH; | ||
270 | keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT; | ||
271 | keymap[SCANCODE_KEYPADMULTIPLY] = SDLK_KP_MULTIPLY; | ||
272 | keymap[SCANCODE_LEFTALT] = SDLK_LALT; | ||
273 | keymap[SCANCODE_SPACE] = SDLK_SPACE; | ||
274 | keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; | ||
275 | keymap[SCANCODE_F1] = SDLK_F1; | ||
276 | keymap[SCANCODE_F2] = SDLK_F2; | ||
277 | keymap[SCANCODE_F3] = SDLK_F3; | ||
278 | keymap[SCANCODE_F4] = SDLK_F4; | ||
279 | keymap[SCANCODE_F5] = SDLK_F5; | ||
280 | keymap[SCANCODE_F6] = SDLK_F6; | ||
281 | keymap[SCANCODE_F7] = SDLK_F7; | ||
282 | keymap[SCANCODE_F8] = SDLK_F8; | ||
283 | keymap[SCANCODE_F9] = SDLK_F9; | ||
284 | keymap[SCANCODE_F10] = SDLK_F10; | ||
285 | keymap[SCANCODE_NUMLOCK] = SDLK_NUMLOCK; | ||
286 | keymap[SCANCODE_SCROLLLOCK] = SDLK_SCROLLOCK; | ||
287 | keymap[SCANCODE_KEYPAD7] = SDLK_KP7; | ||
288 | keymap[SCANCODE_CURSORUPLEFT] = SDLK_KP7; | ||
289 | keymap[SCANCODE_KEYPAD8] = SDLK_KP8; | ||
290 | keymap[SCANCODE_CURSORUP] = SDLK_KP8; | ||
291 | keymap[SCANCODE_KEYPAD9] = SDLK_KP9; | ||
292 | keymap[SCANCODE_CURSORUPRIGHT] = SDLK_KP9; | ||
293 | keymap[SCANCODE_KEYPADMINUS] = SDLK_KP_MINUS; | ||
294 | keymap[SCANCODE_KEYPAD4] = SDLK_KP4; | ||
295 | keymap[SCANCODE_CURSORLEFT] = SDLK_KP4; | ||
296 | keymap[SCANCODE_KEYPAD5] = SDLK_KP5; | ||
297 | keymap[SCANCODE_KEYPAD6] = SDLK_KP6; | ||
298 | keymap[SCANCODE_CURSORRIGHT] = SDLK_KP6; | ||
299 | keymap[SCANCODE_KEYPADPLUS] = SDLK_KP_PLUS; | ||
300 | keymap[SCANCODE_KEYPAD1] = SDLK_KP1; | ||
301 | keymap[SCANCODE_CURSORDOWNLEFT] = SDLK_KP1; | ||
302 | keymap[SCANCODE_KEYPAD2] = SDLK_KP2; | ||
303 | keymap[SCANCODE_CURSORDOWN] = SDLK_KP2; | ||
304 | keymap[SCANCODE_KEYPAD3] = SDLK_KP3; | ||
305 | keymap[SCANCODE_CURSORDOWNRIGHT] = SDLK_KP3; | ||
306 | keymap[SCANCODE_KEYPAD0] = SDLK_KP0; | ||
307 | keymap[SCANCODE_KEYPADPERIOD] = SDLK_KP_PERIOD; | ||
308 | keymap[SCANCODE_LESS] = SDLK_LESS; | ||
309 | keymap[SCANCODE_F11] = SDLK_F11; | ||
310 | keymap[SCANCODE_F12] = SDLK_F12; | ||
311 | keymap[SCANCODE_KEYPADENTER] = SDLK_KP_ENTER; | ||
312 | keymap[SCANCODE_RIGHTCONTROL] = SDLK_RCTRL; | ||
313 | keymap[SCANCODE_CONTROL] = SDLK_RCTRL; | ||
314 | keymap[SCANCODE_KEYPADDIVIDE] = SDLK_KP_DIVIDE; | ||
315 | keymap[SCANCODE_PRINTSCREEN] = SDLK_PRINT; | ||
316 | keymap[SCANCODE_RIGHTALT] = SDLK_RALT; | ||
317 | keymap[SCANCODE_BREAK] = SDLK_BREAK; | ||
318 | keymap[SCANCODE_BREAK_ALTERNATIVE] = SDLK_UNKNOWN; | ||
319 | keymap[SCANCODE_HOME] = SDLK_HOME; | ||
320 | keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP; | ||
321 | keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP; | ||
322 | keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT; | ||
323 | keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT; | ||
324 | keymap[SCANCODE_END] = SDLK_END; | ||
325 | keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN; | ||
326 | keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN; | ||
327 | keymap[SCANCODE_INSERT] = SDLK_INSERT; | ||
328 | keymap[SCANCODE_REMOVE] = SDLK_DELETE; | ||
329 | keymap[119] = SDLK_PAUSE; | ||
330 | keymap[SCANCODE_RIGHTWIN] = SDLK_RSUPER; | ||
331 | keymap[SCANCODE_LEFTWIN] = SDLK_LSUPER; | ||
332 | keymap[127] = SDLK_MENU; | ||
333 | } | ||
334 | |||
335 | #if defined(linux) | ||
336 | static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym) | ||
337 | { | ||
338 | /* Set the keysym information */ | ||
339 | keysym->scancode = scancode; | ||
340 | keysym->sym = keymap[scancode]; | ||
341 | keysym->mod = KMOD_NONE; | ||
342 | |||
343 | /* If UNICODE is on, get the UNICODE value for the key */ | ||
344 | keysym->unicode = 0; | ||
345 | if ( SDL_TranslateUNICODE ) { | ||
346 | int map; | ||
347 | SDLMod modstate; | ||
348 | |||
349 | modstate = SDL_GetModState(); | ||
350 | map = 0; | ||
351 | if ( modstate & KMOD_SHIFT ) { | ||
352 | map |= (1<<KG_SHIFT); | ||
353 | } | ||
354 | if ( modstate & KMOD_CTRL ) { | ||
355 | map |= (1<<KG_CTRL); | ||
356 | } | ||
357 | if ( modstate & KMOD_ALT ) { | ||
358 | map |= (1<<KG_ALT); | ||
359 | } | ||
360 | if ( modstate & KMOD_MODE ) { | ||
361 | map |= (1<<KG_ALTGR); | ||
362 | } | ||
363 | if ( KTYP(vga_keymap[map][scancode]) == KT_LETTER ) { | ||
364 | if ( modstate & KMOD_CAPS ) { | ||
365 | map ^= (1<<KG_SHIFT); | ||
366 | } | ||
367 | } | ||
368 | if ( KTYP(vga_keymap[map][scancode]) == KT_PAD ) { | ||
369 | if ( modstate & KMOD_NUM ) { | ||
370 | keysym->unicode=KVAL(vga_keymap[map][scancode]); | ||
371 | } | ||
372 | } else { | ||
373 | keysym->unicode = KVAL(vga_keymap[map][scancode]); | ||
374 | } | ||
375 | } | ||
376 | return(keysym); | ||
377 | } | ||
378 | #elif defined(__FREEBSD__) | ||
379 | static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym) | ||
380 | { | ||
381 | /* Set the keysym information */ | ||
382 | keysym->scancode = scancode; | ||
383 | keysym->sym = keymap[scancode]; | ||
384 | keysym->mod = KMOD_NONE; | ||
385 | |||
386 | /* If UNICODE is on, get the UNICODE value for the key */ | ||
387 | keysym->unicode = 0; | ||
388 | if ( SDL_TranslateUNICODE && vga_keymap ) { | ||
389 | int map; | ||
390 | SDLMod modstate; | ||
391 | |||
392 | modstate = SDL_GetModState(); | ||
393 | map = 0; | ||
394 | if ( modstate & KMOD_SHIFT ) { | ||
395 | map += 1; | ||
396 | } | ||
397 | if ( modstate & KMOD_CTRL ) { | ||
398 | map += 2; | ||
399 | } | ||
400 | if ( modstate & KMOD_ALT ) { | ||
401 | map += 4; | ||
402 | } | ||
403 | if ( !(vga_keymap->key[scancode].spcl & (0x80 >> map)) ) { | ||
404 | keysym->unicode = vga_keymap->key[scancode].map[map]; | ||
405 | } | ||
406 | |||
407 | } | ||
408 | return(keysym); | ||
409 | } | ||
410 | #else | ||
411 | #error You must choose your operating system here | ||
412 | #endif | ||
diff --git a/apps/plugins/sdl/src/video/svga/SDL_svgaevents_c.h b/apps/plugins/sdl/src/video/svga/SDL_svgaevents_c.h deleted file mode 100644 index cd9f888904..0000000000 --- a/apps/plugins/sdl/src/video/svga/SDL_svgaevents_c.h +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #include "SDL_svgavideo.h" | ||
25 | |||
26 | /* Variables and functions exported by SDL_sysevents.c to other parts | ||
27 | of the native video subsystem (SDL_sysvideo.c) | ||
28 | */ | ||
29 | extern int SVGA_initkeymaps(int fd); | ||
30 | extern void SVGA_mousecallback(int button, int dx, int dy, | ||
31 | int u1,int u2,int u3, int u4); | ||
32 | extern void SVGA_keyboardcallback(int scancode, int pressed); | ||
33 | |||
34 | extern void SVGA_InitOSKeymap(_THIS); | ||
35 | extern void SVGA_PumpEvents(_THIS); | ||
diff --git a/apps/plugins/sdl/src/video/svga/SDL_svgamouse.c b/apps/plugins/sdl/src/video/svga/SDL_svgamouse.c deleted file mode 100644 index a82dbfd7c7..0000000000 --- a/apps/plugins/sdl/src/video/svga/SDL_svgamouse.c +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #include "SDL_mouse.h" | ||
25 | #include "../../events/SDL_events_c.h" | ||
26 | #include "SDL_svgavideo.h" | ||
27 | #include "SDL_svgamouse_c.h" | ||
28 | |||
29 | |||
30 | /* The implementation dependent data for the window manager cursor */ | ||
31 | struct WMcursor { | ||
32 | int unused; | ||
33 | }; | ||
diff --git a/apps/plugins/sdl/src/video/svga/SDL_svgamouse_c.h b/apps/plugins/sdl/src/video/svga/SDL_svgamouse_c.h deleted file mode 100644 index 78fe8abcb2..0000000000 --- a/apps/plugins/sdl/src/video/svga/SDL_svgamouse_c.h +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #include "SDL_svgavideo.h" | ||
25 | |||
26 | /* Functions to be exported */ | ||
diff --git a/apps/plugins/sdl/src/video/svga/SDL_svgavideo.c b/apps/plugins/sdl/src/video/svga/SDL_svgavideo.c deleted file mode 100644 index 58ea800f24..0000000000 --- a/apps/plugins/sdl/src/video/svga/SDL_svgavideo.c +++ /dev/null | |||
@@ -1,584 +0,0 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | /* SVGAlib based SDL video driver implementation. | ||
25 | */ | ||
26 | |||
27 | #include <unistd.h> | ||
28 | #include <sys/stat.h> | ||
29 | #include <sys/types.h> | ||
30 | #include <sys/ioctl.h> | ||
31 | #include <fcntl.h> | ||
32 | |||
33 | #if defined(__LINUX__) | ||
34 | #include <linux/vt.h> | ||
35 | #elif defined(__FREEBSD__) | ||
36 | #include <sys/consio.h> | ||
37 | #else | ||
38 | #error You must choose your operating system here | ||
39 | #endif | ||
40 | #include <vga.h> | ||
41 | #include <vgamouse.h> | ||
42 | #include <vgakeyboard.h> | ||
43 | |||
44 | #include "SDL_video.h" | ||
45 | #include "SDL_mouse.h" | ||
46 | #include "../SDL_sysvideo.h" | ||
47 | #include "../SDL_pixels_c.h" | ||
48 | #include "../../events/SDL_events_c.h" | ||
49 | #include "SDL_svgavideo.h" | ||
50 | #include "SDL_svgaevents_c.h" | ||
51 | #include "SDL_svgamouse_c.h" | ||
52 | |||
53 | /* Initialization/Query functions */ | ||
54 | static int SVGA_VideoInit(_THIS, SDL_PixelFormat *vformat); | ||
55 | static SDL_Rect **SVGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | ||
56 | static SDL_Surface *SVGA_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | ||
57 | static int SVGA_SetColors(_THIS, int firstcolor, int ncolors, | ||
58 | SDL_Color *colors); | ||
59 | static void SVGA_VideoQuit(_THIS); | ||
60 | |||
61 | /* Hardware surface functions */ | ||
62 | static int SVGA_AllocHWSurface(_THIS, SDL_Surface *surface); | ||
63 | static int SVGA_LockHWSurface(_THIS, SDL_Surface *surface); | ||
64 | static int SVGA_FlipHWSurface(_THIS, SDL_Surface *surface); | ||
65 | static void SVGA_UnlockHWSurface(_THIS, SDL_Surface *surface); | ||
66 | static void SVGA_FreeHWSurface(_THIS, SDL_Surface *surface); | ||
67 | |||
68 | /* SVGAlib driver bootstrap functions */ | ||
69 | |||
70 | static int SVGA_Available(void) | ||
71 | { | ||
72 | /* Check to see if we are root and stdin is a virtual console */ | ||
73 | int console; | ||
74 | |||
75 | /* SVGALib 1.9.x+ doesn't require root (via /dev/svga) */ | ||
76 | int svgalib2 = -1; | ||
77 | |||
78 | /* See if we are connected to a virtual terminal */ | ||
79 | console = STDIN_FILENO; | ||
80 | #if 0 /* This is no longer needed, SVGAlib can switch consoles for us */ | ||
81 | if ( console >= 0 ) { | ||
82 | struct stat sb; | ||
83 | struct vt_mode dummy; | ||
84 | |||
85 | if ( (fstat(console, &sb) < 0) || | ||
86 | (ioctl(console, VT_GETMODE, &dummy) < 0) ) { | ||
87 | console = -1; | ||
88 | } | ||
89 | } | ||
90 | #endif /* 0 */ | ||
91 | |||
92 | /* See if SVGAlib 2.0 is available */ | ||
93 | svgalib2 = open("/dev/svga", O_RDONLY); | ||
94 | if (svgalib2 != -1) { | ||
95 | close(svgalib2); | ||
96 | } | ||
97 | |||
98 | return(((svgalib2 != -1) || (geteuid() == 0)) && (console >= 0)); | ||
99 | } | ||
100 | |||
101 | static void SVGA_DeleteDevice(SDL_VideoDevice *device) | ||
102 | { | ||
103 | SDL_free(device->hidden); | ||
104 | SDL_free(device); | ||
105 | } | ||
106 | |||
107 | static SDL_VideoDevice *SVGA_CreateDevice(int devindex) | ||
108 | { | ||
109 | SDL_VideoDevice *device; | ||
110 | |||
111 | /* Initialize all variables that we clean on shutdown */ | ||
112 | device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); | ||
113 | if ( device ) { | ||
114 | SDL_memset(device, 0, (sizeof *device)); | ||
115 | device->hidden = (struct SDL_PrivateVideoData *) | ||
116 | SDL_malloc((sizeof *device->hidden)); | ||
117 | } | ||
118 | if ( (device == NULL) || (device->hidden == NULL) ) { | ||
119 | SDL_OutOfMemory(); | ||
120 | if ( device ) { | ||
121 | SDL_free(device); | ||
122 | } | ||
123 | return(0); | ||
124 | } | ||
125 | SDL_memset(device->hidden, 0, (sizeof *device->hidden)); | ||
126 | |||
127 | /* Set the function pointers */ | ||
128 | device->VideoInit = SVGA_VideoInit; | ||
129 | device->ListModes = SVGA_ListModes; | ||
130 | device->SetVideoMode = SVGA_SetVideoMode; | ||
131 | device->SetColors = SVGA_SetColors; | ||
132 | device->UpdateRects = NULL; | ||
133 | device->VideoQuit = SVGA_VideoQuit; | ||
134 | device->AllocHWSurface = SVGA_AllocHWSurface; | ||
135 | device->CheckHWBlit = NULL; | ||
136 | device->FillHWRect = NULL; | ||
137 | device->SetHWColorKey = NULL; | ||
138 | device->SetHWAlpha = NULL; | ||
139 | device->LockHWSurface = SVGA_LockHWSurface; | ||
140 | device->UnlockHWSurface = SVGA_UnlockHWSurface; | ||
141 | device->FlipHWSurface = SVGA_FlipHWSurface; | ||
142 | device->FreeHWSurface = SVGA_FreeHWSurface; | ||
143 | device->SetCaption = NULL; | ||
144 | device->SetIcon = NULL; | ||
145 | device->IconifyWindow = NULL; | ||
146 | device->GrabInput = NULL; | ||
147 | device->GetWMInfo = NULL; | ||
148 | device->InitOSKeymap = SVGA_InitOSKeymap; | ||
149 | device->PumpEvents = SVGA_PumpEvents; | ||
150 | |||
151 | device->free = SVGA_DeleteDevice; | ||
152 | |||
153 | return device; | ||
154 | } | ||
155 | |||
156 | VideoBootStrap SVGALIB_bootstrap = { | ||
157 | "svgalib", "SVGAlib", | ||
158 | SVGA_Available, SVGA_CreateDevice | ||
159 | }; | ||
160 | |||
161 | static int SVGA_AddMode(_THIS, int mode, int actually_add) | ||
162 | { | ||
163 | int i, j; | ||
164 | vga_modeinfo *modeinfo; | ||
165 | |||
166 | modeinfo = vga_getmodeinfo(mode); | ||
167 | |||
168 | i = modeinfo->bytesperpixel-1; | ||
169 | if ( i < 0 ) { | ||
170 | return 0; | ||
171 | } | ||
172 | if ( actually_add ) { | ||
173 | SDL_Rect saved_rect[2]; | ||
174 | int saved_mode[2]; | ||
175 | int b; | ||
176 | |||
177 | /* Add the mode, sorted largest to smallest */ | ||
178 | b = 0; | ||
179 | j = 0; | ||
180 | while ( (SDL_modelist[i][j]->w > modeinfo->width) || | ||
181 | (SDL_modelist[i][j]->h > modeinfo->height) ) { | ||
182 | ++j; | ||
183 | } | ||
184 | /* Skip modes that are already in our list */ | ||
185 | if ( (SDL_modelist[i][j]->w == modeinfo->width) && | ||
186 | (SDL_modelist[i][j]->h == modeinfo->height) ) { | ||
187 | return(0); | ||
188 | } | ||
189 | /* Insert the new mode */ | ||
190 | saved_rect[b] = *SDL_modelist[i][j]; | ||
191 | saved_mode[b] = SDL_vgamode[i][j]; | ||
192 | SDL_modelist[i][j]->w = modeinfo->width; | ||
193 | SDL_modelist[i][j]->h = modeinfo->height; | ||
194 | SDL_vgamode[i][j] = mode; | ||
195 | /* Everybody scoot down! */ | ||
196 | if ( saved_rect[b].w && saved_rect[b].h ) { | ||
197 | for ( ++j; SDL_modelist[i][j]->w; ++j ) { | ||
198 | saved_rect[!b] = *SDL_modelist[i][j]; | ||
199 | saved_mode[!b] = SDL_vgamode[i][j]; | ||
200 | *SDL_modelist[i][j] = saved_rect[b]; | ||
201 | SDL_vgamode[i][j] = saved_mode[b]; | ||
202 | b = !b; | ||
203 | } | ||
204 | *SDL_modelist[i][j] = saved_rect[b]; | ||
205 | SDL_vgamode[i][j] = saved_mode[b]; | ||
206 | } | ||
207 | } else { | ||
208 | ++SDL_nummodes[i]; | ||
209 | } | ||
210 | return(1); | ||
211 | } | ||
212 | |||
213 | static void SVGA_UpdateVideoInfo(_THIS) | ||
214 | { | ||
215 | vga_modeinfo *modeinfo; | ||
216 | |||
217 | this->info.wm_available = 0; | ||
218 | this->info.hw_available = (banked ? 0 : 1); | ||
219 | modeinfo = vga_getmodeinfo(vga_getcurrentmode()); | ||
220 | this->info.video_mem = modeinfo->memory; | ||
221 | /* FIXME: Add hardware accelerated blit information */ | ||
222 | #ifdef SVGALIB_DEBUG | ||
223 | printf("Hardware accelerated blit: %savailable\n", modeinfo->haveblit ? "" : "not "); | ||
224 | #endif | ||
225 | } | ||
226 | |||
227 | int SVGA_VideoInit(_THIS, SDL_PixelFormat *vformat) | ||
228 | { | ||
229 | int keyboard; | ||
230 | int i, j; | ||
231 | int mode, total_modes; | ||
232 | |||
233 | /* Initialize all variables that we clean on shutdown */ | ||
234 | for ( i=0; i<NUM_MODELISTS; ++i ) { | ||
235 | SDL_nummodes[i] = 0; | ||
236 | SDL_modelist[i] = NULL; | ||
237 | SDL_vgamode[i] = NULL; | ||
238 | } | ||
239 | |||
240 | /* Initialize the library */ | ||
241 | vga_disabledriverreport(); | ||
242 | if ( vga_init() < 0 ) { | ||
243 | SDL_SetError("Unable to initialize SVGAlib"); | ||
244 | return(-1); | ||
245 | } | ||
246 | vga_setmode(TEXT); | ||
247 | |||
248 | /* Enable mouse and keyboard support */ | ||
249 | vga_setmousesupport(1); | ||
250 | keyboard = keyboard_init_return_fd(); | ||
251 | if ( keyboard < 0 ) { | ||
252 | SDL_SetError("Unable to initialize keyboard"); | ||
253 | return(-1); | ||
254 | } | ||
255 | if ( SVGA_initkeymaps(keyboard) < 0 ) { | ||
256 | return(-1); | ||
257 | } | ||
258 | keyboard_seteventhandler(SVGA_keyboardcallback); | ||
259 | |||
260 | /* Determine the current screen size */ | ||
261 | this->info.current_w = 0; | ||
262 | this->info.current_h = 0; | ||
263 | |||
264 | /* Determine the screen depth (use default 8-bit depth) */ | ||
265 | vformat->BitsPerPixel = 8; | ||
266 | |||
267 | /* Enumerate the available fullscreen modes */ | ||
268 | total_modes = 0; | ||
269 | for ( mode=vga_lastmodenumber(); mode; --mode ) { | ||
270 | if ( vga_hasmode(mode) ) { | ||
271 | if ( SVGA_AddMode(this, mode, 0) ) { | ||
272 | ++total_modes; | ||
273 | } | ||
274 | } | ||
275 | } | ||
276 | if ( SVGA_AddMode(this, G320x200x256, 0) ) ++total_modes; | ||
277 | if ( total_modes == 0 ) { | ||
278 | SDL_SetError("No linear video modes available"); | ||
279 | return(-1); | ||
280 | } | ||
281 | for ( i=0; i<NUM_MODELISTS; ++i ) { | ||
282 | SDL_vgamode[i] = (int *)SDL_malloc(SDL_nummodes[i]*sizeof(int)); | ||
283 | if ( SDL_vgamode[i] == NULL ) { | ||
284 | SDL_OutOfMemory(); | ||
285 | return(-1); | ||
286 | } | ||
287 | SDL_modelist[i] = (SDL_Rect **) | ||
288 | SDL_malloc((SDL_nummodes[i]+1)*sizeof(SDL_Rect *)); | ||
289 | if ( SDL_modelist[i] == NULL ) { | ||
290 | SDL_OutOfMemory(); | ||
291 | return(-1); | ||
292 | } | ||
293 | for ( j=0; j<SDL_nummodes[i]; ++j ) { | ||
294 | SDL_modelist[i][j]=(SDL_Rect *)SDL_malloc(sizeof(SDL_Rect)); | ||
295 | if ( SDL_modelist[i][j] == NULL ) { | ||
296 | SDL_OutOfMemory(); | ||
297 | return(-1); | ||
298 | } | ||
299 | SDL_memset(SDL_modelist[i][j], 0, sizeof(SDL_Rect)); | ||
300 | } | ||
301 | SDL_modelist[i][j] = NULL; | ||
302 | } | ||
303 | for ( mode=vga_lastmodenumber(); mode; --mode ) { | ||
304 | if ( vga_hasmode(mode) ) { | ||
305 | SVGA_AddMode(this, mode, 1); | ||
306 | } | ||
307 | } | ||
308 | SVGA_AddMode(this, G320x200x256, 1); | ||
309 | |||
310 | /* Free extra (duplicated) modes */ | ||
311 | for ( i=0; i<NUM_MODELISTS; ++i ) { | ||
312 | j = 0; | ||
313 | while ( SDL_modelist[i][j] && SDL_modelist[i][j]->w ) { | ||
314 | j++; | ||
315 | } | ||
316 | while ( SDL_modelist[i][j] ) { | ||
317 | SDL_free(SDL_modelist[i][j]); | ||
318 | SDL_modelist[i][j] = NULL; | ||
319 | j++; | ||
320 | } | ||
321 | } | ||
322 | |||
323 | /* Fill in our hardware acceleration capabilities */ | ||
324 | SVGA_UpdateVideoInfo(this); | ||
325 | |||
326 | /* We're done! */ | ||
327 | return(0); | ||
328 | } | ||
329 | |||
330 | SDL_Rect **SVGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | ||
331 | { | ||
332 | return(SDL_modelist[((format->BitsPerPixel+7)/8)-1]); | ||
333 | } | ||
334 | |||
335 | /* Various screen update functions available */ | ||
336 | static void SVGA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects); | ||
337 | static void SVGA_BankedUpdate(_THIS, int numrects, SDL_Rect *rects); | ||
338 | |||
339 | SDL_Surface *SVGA_SetVideoMode(_THIS, SDL_Surface *current, | ||
340 | int width, int height, int bpp, Uint32 flags) | ||
341 | { | ||
342 | int mode; | ||
343 | int vgamode; | ||
344 | vga_modeinfo *modeinfo; | ||
345 | int screenpage_len; | ||
346 | |||
347 | /* Free old pixels if we were in banked mode */ | ||
348 | if ( banked && current->pixels ) { | ||
349 | free(current->pixels); | ||
350 | current->pixels = NULL; | ||
351 | } | ||
352 | |||
353 | /* Try to set the requested linear video mode */ | ||
354 | bpp = (bpp+7)/8-1; | ||
355 | for ( mode=0; SDL_modelist[bpp][mode]; ++mode ) { | ||
356 | if ( (SDL_modelist[bpp][mode]->w == width) && | ||
357 | (SDL_modelist[bpp][mode]->h == height) ) { | ||
358 | break; | ||
359 | } | ||
360 | } | ||
361 | if ( SDL_modelist[bpp][mode] == NULL ) { | ||
362 | SDL_SetError("Couldn't find requested mode in list"); | ||
363 | return(NULL); | ||
364 | } | ||
365 | vgamode = SDL_vgamode[bpp][mode]; | ||
366 | vga_setmode(vgamode); | ||
367 | vga_setpage(0); | ||
368 | |||
369 | if ( (vga_setlinearaddressing() < 0) && (vgamode != G320x200x256) ) { | ||
370 | banked = 1; | ||
371 | } else { | ||
372 | banked = 0; | ||
373 | } | ||
374 | |||
375 | modeinfo = vga_getmodeinfo(SDL_vgamode[bpp][mode]); | ||
376 | |||
377 | /* Update hardware acceleration info */ | ||
378 | SVGA_UpdateVideoInfo(this); | ||
379 | |||
380 | /* Allocate the new pixel format for the screen */ | ||
381 | bpp = (bpp+1)*8; | ||
382 | if ( (bpp == 16) && (modeinfo->colors == 32768) ) { | ||
383 | bpp = 15; | ||
384 | } | ||
385 | if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) { | ||
386 | return(NULL); | ||
387 | } | ||
388 | |||
389 | /* Set up the new mode framebuffer */ | ||
390 | current->flags = SDL_FULLSCREEN; | ||
391 | if ( !banked ) { | ||
392 | current->flags |= SDL_HWSURFACE; | ||
393 | } | ||
394 | if ( bpp == 8 ) { | ||
395 | /* FIXME: What about DirectColor? */ | ||
396 | current->flags |= SDL_HWPALETTE; | ||
397 | } | ||
398 | current->w = width; | ||
399 | current->h = height; | ||
400 | current->pitch = modeinfo->linewidth; | ||
401 | if ( banked ) { | ||
402 | current->pixels = SDL_malloc(current->h * current->pitch); | ||
403 | if ( !current->pixels ) { | ||
404 | SDL_OutOfMemory(); | ||
405 | return(NULL); | ||
406 | } | ||
407 | } else { | ||
408 | current->pixels = vga_getgraphmem(); | ||
409 | } | ||
410 | |||
411 | /* set double-buffering */ | ||
412 | if ( (flags & SDL_DOUBLEBUF) && !banked ) | ||
413 | { | ||
414 | /* length of one screen page in bytes */ | ||
415 | screenpage_len=current->h*modeinfo->linewidth; | ||
416 | |||
417 | /* if start address should be aligned */ | ||
418 | if ( modeinfo->linewidth_unit ) | ||
419 | { | ||
420 | if ( screenpage_len % modeinfo->linewidth_unit ) | ||
421 | { | ||
422 | screenpage_len += modeinfo->linewidth_unit - ( screenpage_len % modeinfo->linewidth_unit ); | ||
423 | } | ||
424 | } | ||
425 | |||
426 | /* if we heve enough videomemory = ak je dost videopamete */ | ||
427 | if ( modeinfo->memory > ( screenpage_len * 2 / 1024 ) ) | ||
428 | { | ||
429 | current->flags |= SDL_DOUBLEBUF; | ||
430 | flip_page = 0; | ||
431 | flip_offset[0] = 0; | ||
432 | flip_offset[1] = screenpage_len; | ||
433 | flip_address[0] = vga_getgraphmem(); | ||
434 | flip_address[1] = flip_address[0]+screenpage_len; | ||
435 | SVGA_FlipHWSurface(this,current); | ||
436 | } | ||
437 | } | ||
438 | |||
439 | /* Set the blit function */ | ||
440 | if ( banked ) { | ||
441 | this->UpdateRects = SVGA_BankedUpdate; | ||
442 | } else { | ||
443 | this->UpdateRects = SVGA_DirectUpdate; | ||
444 | } | ||
445 | |||
446 | /* Set up the mouse handler again (buggy SVGAlib 1.40) */ | ||
447 | mouse_seteventhandler(SVGA_mousecallback); | ||
448 | |||
449 | /* We're done */ | ||
450 | return(current); | ||
451 | } | ||
452 | |||
453 | /* We don't actually allow hardware surfaces other than the main one */ | ||
454 | static int SVGA_AllocHWSurface(_THIS, SDL_Surface *surface) | ||
455 | { | ||
456 | return(-1); | ||
457 | } | ||
458 | static void SVGA_FreeHWSurface(_THIS, SDL_Surface *surface) | ||
459 | { | ||
460 | return; | ||
461 | } | ||
462 | |||
463 | /* We need to wait for vertical retrace on page flipped displays */ | ||
464 | static int SVGA_LockHWSurface(_THIS, SDL_Surface *surface) | ||
465 | { | ||
466 | /* The waiting is done in SVGA_FlipHWSurface() */ | ||
467 | return(0); | ||
468 | } | ||
469 | static void SVGA_UnlockHWSurface(_THIS, SDL_Surface *surface) | ||
470 | { | ||
471 | return; | ||
472 | } | ||
473 | |||
474 | static int SVGA_FlipHWSurface(_THIS, SDL_Surface *surface) | ||
475 | { | ||
476 | if ( !banked ) { | ||
477 | vga_setdisplaystart(flip_offset[flip_page]); | ||
478 | flip_page=!flip_page; | ||
479 | surface->pixels=flip_address[flip_page]; | ||
480 | vga_waitretrace(); | ||
481 | } | ||
482 | return(0); | ||
483 | } | ||
484 | |||
485 | static void SVGA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) | ||
486 | { | ||
487 | return; | ||
488 | } | ||
489 | |||
490 | static void SVGA_BankedUpdate(_THIS, int numrects, SDL_Rect *rects) | ||
491 | { | ||
492 | int i, j; | ||
493 | SDL_Rect *rect; | ||
494 | int page, vp; | ||
495 | int x, y, w, h; | ||
496 | unsigned char *src; | ||
497 | unsigned char *dst; | ||
498 | int bpp = this->screen->format->BytesPerPixel; | ||
499 | int pitch = this->screen->pitch; | ||
500 | |||
501 | dst = vga_getgraphmem(); | ||
502 | for ( i=0; i < numrects; ++i ) { | ||
503 | rect = &rects[i]; | ||
504 | x = rect->x; | ||
505 | y = rect->y; | ||
506 | w = rect->w * bpp; | ||
507 | h = rect->h; | ||
508 | |||
509 | vp = y * pitch + x * bpp; | ||
510 | src = (unsigned char *)this->screen->pixels + vp; | ||
511 | page = vp >> 16; | ||
512 | vp &= 0xffff; | ||
513 | vga_setpage(page); | ||
514 | for (j = 0; j < h; j++) { | ||
515 | if (vp + w > 0x10000) { | ||
516 | if (vp >= 0x10000) { | ||
517 | page++; | ||
518 | vga_setpage(page); | ||
519 | vp &= 0xffff; | ||
520 | } else { | ||
521 | SDL_memcpy(dst + vp, src, 0x10000 - vp); | ||
522 | page++; | ||
523 | vga_setpage(page); | ||
524 | SDL_memcpy(dst, src + 0x10000 - vp, | ||
525 | (vp + w) & 0xffff); | ||
526 | vp = (vp + pitch) & 0xffff; | ||
527 | src += pitch; | ||
528 | continue; | ||
529 | } | ||
530 | } | ||
531 | SDL_memcpy(dst + vp, src, w); | ||
532 | src += pitch; | ||
533 | vp += pitch; | ||
534 | } | ||
535 | } | ||
536 | } | ||
537 | |||
538 | int SVGA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | ||
539 | { | ||
540 | int i; | ||
541 | |||
542 | for(i = 0; i < ncolors; i++) { | ||
543 | vga_setpalette(firstcolor + i, | ||
544 | colors[i].r>>2, | ||
545 | colors[i].g>>2, | ||
546 | colors[i].b>>2); | ||
547 | } | ||
548 | return(1); | ||
549 | } | ||
550 | |||
551 | /* Note: If we are terminated, this could be called in the middle of | ||
552 | another SDL video routine -- notably UpdateRects. | ||
553 | */ | ||
554 | void SVGA_VideoQuit(_THIS) | ||
555 | { | ||
556 | int i, j; | ||
557 | |||
558 | /* Reset the console video mode */ | ||
559 | if ( this->screen && (this->screen->w && this->screen->h) ) { | ||
560 | vga_setmode(TEXT); | ||
561 | } | ||
562 | keyboard_close(); | ||
563 | |||
564 | /* Free video mode lists */ | ||
565 | for ( i=0; i<NUM_MODELISTS; ++i ) { | ||
566 | if ( SDL_modelist[i] != NULL ) { | ||
567 | for ( j=0; SDL_modelist[i][j]; ++j ) | ||
568 | SDL_free(SDL_modelist[i][j]); | ||
569 | SDL_free(SDL_modelist[i]); | ||
570 | SDL_modelist[i] = NULL; | ||
571 | } | ||
572 | if ( SDL_vgamode[i] != NULL ) { | ||
573 | SDL_free(SDL_vgamode[i]); | ||
574 | SDL_vgamode[i] = NULL; | ||
575 | } | ||
576 | } | ||
577 | if ( this->screen ) { | ||
578 | if ( banked && this->screen->pixels ) { | ||
579 | SDL_free(this->screen->pixels); | ||
580 | } | ||
581 | this->screen->pixels = NULL; | ||
582 | } | ||
583 | } | ||
584 | |||
diff --git a/apps/plugins/sdl/src/video/svga/SDL_svgavideo.h b/apps/plugins/sdl/src/video/svga/SDL_svgavideo.h deleted file mode 100644 index 7fb86cbbbe..0000000000 --- a/apps/plugins/sdl/src/video/svga/SDL_svgavideo.h +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #ifndef _SDL_svgavideo_h | ||
25 | #define _SDL_svgavideo_h | ||
26 | |||
27 | #include "SDL_mouse.h" | ||
28 | #include "../SDL_sysvideo.h" | ||
29 | |||
30 | /* Hidden "this" pointer for the video functions */ | ||
31 | #define _THIS SDL_VideoDevice *this | ||
32 | |||
33 | /* Private display data */ | ||
34 | struct SDL_PrivateVideoData { | ||
35 | #define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */ | ||
36 | int SDL_nummodes[NUM_MODELISTS]; | ||
37 | SDL_Rect **SDL_modelist[NUM_MODELISTS]; | ||
38 | int *SDL_vgamode[NUM_MODELISTS]; | ||
39 | |||
40 | /* information for double-buffering */ | ||
41 | int flip_page; | ||
42 | int flip_offset[2]; | ||
43 | Uint8 *flip_address[2]; | ||
44 | |||
45 | /* Set to 1 if we're in banked video mode */ | ||
46 | int banked; | ||
47 | }; | ||
48 | /* Old variable names */ | ||
49 | #define SDL_nummodes (this->hidden->SDL_nummodes) | ||
50 | #define SDL_modelist (this->hidden->SDL_modelist) | ||
51 | #define SDL_vgamode (this->hidden->SDL_vgamode) | ||
52 | #define flip_page (this->hidden->flip_page) | ||
53 | #define flip_offset (this->hidden->flip_offset) | ||
54 | #define flip_address (this->hidden->flip_address) | ||
55 | #define banked (this->hidden->banked) | ||
56 | |||
57 | #endif /* _SDL_svgavideo_h */ | ||
58 | |||