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/gem | |
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/gem')
-rw-r--r-- | apps/plugins/sdl/src/video/gem/SDL_gemevents.c | 375 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/gem/SDL_gemevents_c.h | 33 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/gem/SDL_gemmouse.c | 205 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/gem/SDL_gemmouse_c.h | 34 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/gem/SDL_gemvideo.c | 1337 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/gem/SDL_gemvideo.h | 191 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/gem/SDL_gemwm.c | 116 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/gem/SDL_gemwm_c.h | 37 |
8 files changed, 0 insertions, 2328 deletions
diff --git a/apps/plugins/sdl/src/video/gem/SDL_gemevents.c b/apps/plugins/sdl/src/video/gem/SDL_gemevents.c deleted file mode 100644 index c5a505de14..0000000000 --- a/apps/plugins/sdl/src/video/gem/SDL_gemevents.c +++ /dev/null | |||
@@ -1,375 +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 | /* | ||
25 | * GEM SDL video driver implementation | ||
26 | * inspired from the Dummy SDL driver | ||
27 | * | ||
28 | * Patrice Mandin | ||
29 | * and work from | ||
30 | * Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard | ||
31 | */ | ||
32 | |||
33 | #include <gem.h> | ||
34 | |||
35 | #include "../../events/SDL_sysevents.h" | ||
36 | #include "../../events/SDL_events_c.h" | ||
37 | #include "SDL_gemvideo.h" | ||
38 | #include "SDL_gemevents_c.h" | ||
39 | #include "SDL_gemmouse_c.h" | ||
40 | #include "../ataricommon/SDL_atarikeys.h" /* for keyboard scancodes */ | ||
41 | #include "../ataricommon/SDL_atarievents_c.h" | ||
42 | #include "../ataricommon/SDL_xbiosevents_c.h" | ||
43 | #include "../ataricommon/SDL_ataridevmouse_c.h" | ||
44 | |||
45 | /* Variables */ | ||
46 | |||
47 | static unsigned char gem_currentkeyboard[ATARIBIOS_MAXKEYS]; | ||
48 | static unsigned char gem_previouskeyboard[ATARIBIOS_MAXKEYS]; | ||
49 | |||
50 | /* Functions prototypes */ | ||
51 | |||
52 | static int do_messages(_THIS, short *message); | ||
53 | static void do_keyboard(short kc, short ks); | ||
54 | static void do_mouse(_THIS, short mx, short my, short mb, short ks); | ||
55 | |||
56 | /* Functions */ | ||
57 | |||
58 | void GEM_InitOSKeymap(_THIS) | ||
59 | { | ||
60 | SDL_memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard)); | ||
61 | SDL_memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard)); | ||
62 | |||
63 | /* Mouse init */ | ||
64 | GEM_mouse_relative = SDL_FALSE; | ||
65 | |||
66 | SDL_Atari_InitInternalKeymap(this); | ||
67 | } | ||
68 | |||
69 | void GEM_PumpEvents(_THIS) | ||
70 | { | ||
71 | short prevkc, prevks; | ||
72 | static short maskmouseb=0; | ||
73 | int i; | ||
74 | SDL_keysym keysym; | ||
75 | |||
76 | SDL_memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard)); | ||
77 | prevkc = prevks = 0; | ||
78 | |||
79 | for (;;) | ||
80 | { | ||
81 | int quit, resultat, event_mask, mouse_event; | ||
82 | short buffer[8], kc; | ||
83 | short x2,y2,w2,h2; | ||
84 | short mousex, mousey, mouseb, dummy; | ||
85 | short kstate; | ||
86 | |||
87 | quit = | ||
88 | mouse_event = | ||
89 | x2=y2=w2=h2 = 0; | ||
90 | |||
91 | event_mask = MU_MESAG|MU_TIMER|MU_KEYBD|MU_BUTTON; | ||
92 | if (!GEM_fullscreen && (GEM_handle>=0)) { | ||
93 | wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); | ||
94 | event_mask |= MU_M1; | ||
95 | mouse_event = ( (SDL_GetAppState() & SDL_APPMOUSEFOCUS) | ||
96 | == SDL_APPMOUSEFOCUS) ? MO_LEAVE : MO_ENTER; | ||
97 | } | ||
98 | |||
99 | resultat = evnt_multi( | ||
100 | event_mask, | ||
101 | 0x101,7,maskmouseb, | ||
102 | mouse_event,x2,y2,w2,h2, | ||
103 | 0,0,0,0,0, | ||
104 | buffer, | ||
105 | 10, | ||
106 | &mousex,&mousey,&mouseb,&kstate,&kc,&dummy | ||
107 | ); | ||
108 | |||
109 | /* Message event ? */ | ||
110 | if (resultat & MU_MESAG) | ||
111 | quit = do_messages(this, buffer); | ||
112 | |||
113 | /* Keyboard event ? */ | ||
114 | if (resultat & MU_KEYBD) { | ||
115 | if ((prevkc != kc) || (prevks != kstate)) { | ||
116 | do_keyboard(kc,kstate); | ||
117 | } else { | ||
118 | /* Avoid looping, if repeating same key */ | ||
119 | break; | ||
120 | } | ||
121 | } | ||
122 | |||
123 | /* Mouse entering/leaving window */ | ||
124 | if (resultat & MU_M1) { | ||
125 | if (this->input_grab == SDL_GRAB_OFF) { | ||
126 | /* Switch mouse focus state */ | ||
127 | SDL_PrivateAppActive((mouse_event == MO_ENTER), | ||
128 | SDL_APPMOUSEFOCUS); | ||
129 | } | ||
130 | GEM_CheckMouseMode(this); | ||
131 | } | ||
132 | |||
133 | /* Mouse button event ? */ | ||
134 | if (resultat & MU_BUTTON) { | ||
135 | do_mouse(this, mousex, mousey, mouseb, kstate); | ||
136 | maskmouseb = mouseb & 7; | ||
137 | } | ||
138 | |||
139 | /* Timer event ? */ | ||
140 | if ((resultat & MU_TIMER) || quit) | ||
141 | break; | ||
142 | } | ||
143 | |||
144 | /* Now generate keyboard events */ | ||
145 | for (i=0; i<ATARIBIOS_MAXKEYS; i++) { | ||
146 | /* Key pressed ? */ | ||
147 | if (gem_currentkeyboard[i] && !gem_previouskeyboard[i]) | ||
148 | SDL_PrivateKeyboard(SDL_PRESSED, | ||
149 | SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE)); | ||
150 | |||
151 | /* Key unpressed ? */ | ||
152 | if (gem_previouskeyboard[i] && !gem_currentkeyboard[i]) | ||
153 | SDL_PrivateKeyboard(SDL_RELEASED, | ||
154 | SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE)); | ||
155 | } | ||
156 | |||
157 | SDL_memcpy(gem_previouskeyboard,gem_currentkeyboard,sizeof(gem_previouskeyboard)); | ||
158 | |||
159 | /* Refresh window name ? */ | ||
160 | if (GEM_refresh_name) { | ||
161 | const char *window_name = | ||
162 | (SDL_GetAppState() & SDL_APPACTIVE) | ||
163 | ? GEM_title_name : GEM_icon_name; | ||
164 | if (window_name) { | ||
165 | wind_set(GEM_handle,WF_NAME, | ||
166 | (short)(((unsigned long)window_name)>>16), | ||
167 | (short)(((unsigned long)window_name) & 0xffff), | ||
168 | 0,0); | ||
169 | } | ||
170 | GEM_refresh_name = SDL_FALSE; | ||
171 | } | ||
172 | } | ||
173 | |||
174 | static int do_messages(_THIS, short *message) | ||
175 | { | ||
176 | int quit, check_mouse_mode; | ||
177 | short x2,y2,w2,h2; | ||
178 | |||
179 | quit = check_mouse_mode = 0; | ||
180 | switch (message[0]) { | ||
181 | case WM_CLOSED: | ||
182 | case AP_TERM: | ||
183 | SDL_PrivateQuit(); | ||
184 | quit=1; | ||
185 | break; | ||
186 | case WM_MOVED: | ||
187 | wind_set(message[3],WF_CURRXYWH,message[4],message[5],message[6],message[7]); | ||
188 | break; | ||
189 | case WM_TOPPED: | ||
190 | wind_set(message[3],WF_TOP,message[4],0,0,0); | ||
191 | /* Continue with TOP event processing */ | ||
192 | case WM_ONTOP: | ||
193 | SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); | ||
194 | if (VDI_setpalette) { | ||
195 | VDI_setpalette(this, VDI_curpalette); | ||
196 | } | ||
197 | check_mouse_mode = 1; | ||
198 | break; | ||
199 | case WM_REDRAW: | ||
200 | if (!GEM_lock_redraw) { | ||
201 | GEM_wind_redraw(this, message[3],&message[4]); | ||
202 | } | ||
203 | break; | ||
204 | case WM_ICONIFY: | ||
205 | case WM_ALLICONIFY: | ||
206 | wind_set(message[3],WF_ICONIFY,message[4],message[5],message[6],message[7]); | ||
207 | /* If we're active, make ourselves inactive */ | ||
208 | if ( SDL_GetAppState() & SDL_APPACTIVE ) { | ||
209 | /* Send an internal deactivate event */ | ||
210 | SDL_PrivateAppActive(0, SDL_APPACTIVE); | ||
211 | } | ||
212 | /* Update window title */ | ||
213 | if (GEM_refresh_name && GEM_icon_name) { | ||
214 | wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_icon_name)>>16),(short)(((unsigned long)GEM_icon_name) & 0xffff),0,0); | ||
215 | GEM_refresh_name = SDL_FALSE; | ||
216 | } | ||
217 | check_mouse_mode = 1; | ||
218 | break; | ||
219 | case WM_UNICONIFY: | ||
220 | wind_set(message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]); | ||
221 | /* If we're not active, make ourselves active */ | ||
222 | if ( !(SDL_GetAppState() & SDL_APPACTIVE) ) { | ||
223 | /* Send an internal activate event */ | ||
224 | SDL_PrivateAppActive(1, SDL_APPACTIVE); | ||
225 | } | ||
226 | if (GEM_refresh_name && GEM_title_name) { | ||
227 | wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0); | ||
228 | GEM_refresh_name = SDL_FALSE; | ||
229 | } | ||
230 | check_mouse_mode = 1; | ||
231 | break; | ||
232 | case WM_SIZED: | ||
233 | wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]); | ||
234 | wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2); | ||
235 | GEM_win_fulled = SDL_FALSE; /* Cancel maximized flag */ | ||
236 | GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers resized */ | ||
237 | SDL_PrivateResize(w2, h2); | ||
238 | break; | ||
239 | case WM_FULLED: | ||
240 | { | ||
241 | short x,y,w,h; | ||
242 | |||
243 | if (GEM_win_fulled) { | ||
244 | wind_get (message[3], WF_PREVXYWH, &x, &y, &w, &h); | ||
245 | GEM_win_fulled = SDL_FALSE; | ||
246 | } else { | ||
247 | x = GEM_desk_x; | ||
248 | y = GEM_desk_y; | ||
249 | w = GEM_desk_w; | ||
250 | h = GEM_desk_h; | ||
251 | GEM_win_fulled = SDL_TRUE; | ||
252 | } | ||
253 | wind_set (message[3], WF_CURRXYWH, x, y, w, h); | ||
254 | wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2); | ||
255 | GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers resized */ | ||
256 | SDL_PrivateResize(w2, h2); | ||
257 | } | ||
258 | break; | ||
259 | case WM_BOTTOMED: | ||
260 | wind_set(message[3],WF_BOTTOM,0,0,0,0); | ||
261 | /* Continue with BOTTOM event processing */ | ||
262 | case WM_UNTOPPED: | ||
263 | SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); | ||
264 | if (VDI_setpalette) { | ||
265 | VDI_setpalette(this, VDI_oldpalette); | ||
266 | } | ||
267 | check_mouse_mode = 1; | ||
268 | break; | ||
269 | } | ||
270 | |||
271 | if (check_mouse_mode) { | ||
272 | GEM_CheckMouseMode(this); | ||
273 | } | ||
274 | |||
275 | return quit; | ||
276 | } | ||
277 | |||
278 | static void do_keyboard(short kc, short ks) | ||
279 | { | ||
280 | int scancode; | ||
281 | |||
282 | if (kc) { | ||
283 | scancode=(kc>>8) & (ATARIBIOS_MAXKEYS-1); | ||
284 | gem_currentkeyboard[scancode]=0xFF; | ||
285 | } | ||
286 | |||
287 | /* Read special keys */ | ||
288 | if (ks & K_RSHIFT) | ||
289 | gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF; | ||
290 | if (ks & K_LSHIFT) | ||
291 | gem_currentkeyboard[SCANCODE_LEFTSHIFT]=0xFF; | ||
292 | if (ks & K_CTRL) | ||
293 | gem_currentkeyboard[SCANCODE_LEFTCONTROL]=0xFF; | ||
294 | if (ks & K_ALT) | ||
295 | gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF; | ||
296 | } | ||
297 | |||
298 | static void do_mouse(_THIS, short mx, short my, short mb, short ks) | ||
299 | { | ||
300 | static short prevmousex=0, prevmousey=0, prevmouseb=0; | ||
301 | short x2, y2, w2, h2; | ||
302 | |||
303 | /* Don't return mouse events if out of window */ | ||
304 | if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS)==0) { | ||
305 | return; | ||
306 | } | ||
307 | |||
308 | /* Retrieve window coords, and generate mouse events accordingly */ | ||
309 | x2 = y2 = 0; | ||
310 | w2 = VDI_w; | ||
311 | h2 = VDI_h; | ||
312 | if ((!GEM_fullscreen) && (GEM_handle>=0)) { | ||
313 | wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); | ||
314 | |||
315 | /* Do not generate mouse button event if out of window working area */ | ||
316 | if ((mx<x2) || (mx>=x2+w2) || (my<y2) || (my>=y2+h2)) { | ||
317 | mb=prevmouseb; | ||
318 | } | ||
319 | } | ||
320 | |||
321 | /* Mouse motion ? */ | ||
322 | if (GEM_mouse_relative) { | ||
323 | if (GEM_usedevmouse) { | ||
324 | SDL_AtariDevMouse_PostMouseEvents(this, SDL_FALSE); | ||
325 | } else { | ||
326 | SDL_AtariXbios_PostMouseEvents(this, SDL_FALSE); | ||
327 | } | ||
328 | } else { | ||
329 | if ((prevmousex!=mx) || (prevmousey!=my)) { | ||
330 | int posx, posy; | ||
331 | |||
332 | /* Give mouse position relative to window position */ | ||
333 | posx = mx - x2; | ||
334 | if (posx<0) posx = 0; | ||
335 | if (posx>w2) posx = w2-1; | ||
336 | posy = my - y2; | ||
337 | if (posy<0) posy = 0; | ||
338 | if (posy>h2) posy = h2-1; | ||
339 | |||
340 | SDL_PrivateMouseMotion(0, 0, posx, posy); | ||
341 | } | ||
342 | prevmousex = mx; | ||
343 | prevmousey = my; | ||
344 | } | ||
345 | |||
346 | /* Mouse button ? */ | ||
347 | if (prevmouseb!=mb) { | ||
348 | int i; | ||
349 | |||
350 | for (i=0;i<3;i++) { | ||
351 | int curbutton, prevbutton; | ||
352 | |||
353 | curbutton = mb & (1<<i); | ||
354 | prevbutton = prevmouseb & (1<<i); | ||
355 | |||
356 | if (curbutton && !prevbutton) { | ||
357 | SDL_PrivateMouseButton(SDL_PRESSED, i+1, 0, 0); | ||
358 | } | ||
359 | if (!curbutton && prevbutton) { | ||
360 | SDL_PrivateMouseButton(SDL_RELEASED, i+1, 0, 0); | ||
361 | } | ||
362 | } | ||
363 | prevmouseb = mb; | ||
364 | } | ||
365 | |||
366 | /* Read special keys */ | ||
367 | if (ks & K_RSHIFT) | ||
368 | gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF; | ||
369 | if (ks & K_LSHIFT) | ||
370 | gem_currentkeyboard[SCANCODE_LEFTSHIFT]=0xFF; | ||
371 | if (ks & K_CTRL) | ||
372 | gem_currentkeyboard[SCANCODE_LEFTCONTROL]=0xFF; | ||
373 | if (ks & K_ALT) | ||
374 | gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF; | ||
375 | } | ||
diff --git a/apps/plugins/sdl/src/video/gem/SDL_gemevents_c.h b/apps/plugins/sdl/src/video/gem/SDL_gemevents_c.h deleted file mode 100644 index 7d5d9b3a1d..0000000000 --- a/apps/plugins/sdl/src/video/gem/SDL_gemevents_c.h +++ /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_gemvideo.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 void GEM_InitOSKeymap(_THIS); | ||
30 | extern void GEM_PumpEvents(_THIS); | ||
31 | |||
32 | /* end of SDL_gemevents_c.h */ | ||
33 | |||
diff --git a/apps/plugins/sdl/src/video/gem/SDL_gemmouse.c b/apps/plugins/sdl/src/video/gem/SDL_gemmouse.c deleted file mode 100644 index c876cffe57..0000000000 --- a/apps/plugins/sdl/src/video/gem/SDL_gemmouse.c +++ /dev/null | |||
@@ -1,205 +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 | /* | ||
25 | * GEM Mouse manager | ||
26 | * | ||
27 | * Patrice Mandin | ||
28 | */ | ||
29 | |||
30 | #include <gem.h> | ||
31 | |||
32 | #include "SDL_mouse.h" | ||
33 | #include "../../events/SDL_events_c.h" | ||
34 | #include "../SDL_cursor_c.h" | ||
35 | #include "SDL_gemmouse_c.h" | ||
36 | #include "SDL_gemvideo.h" | ||
37 | #include "../ataricommon/SDL_xbiosevents_c.h" | ||
38 | |||
39 | /* Defines */ | ||
40 | |||
41 | /*#define DEBUG_VIDEO_GEM 1*/ | ||
42 | |||
43 | #define MAXCURWIDTH 16 | ||
44 | #define MAXCURHEIGHT 16 | ||
45 | |||
46 | void GEM_FreeWMCursor(_THIS, WMcursor *cursor) | ||
47 | { | ||
48 | #ifdef DEBUG_VIDEO_GEM | ||
49 | printf("sdl:video:gem: free cursor\n"); | ||
50 | #endif | ||
51 | |||
52 | if (cursor == NULL) | ||
53 | return; | ||
54 | |||
55 | graf_mouse(ARROW, NULL); | ||
56 | |||
57 | if (cursor->mform_p != NULL) | ||
58 | SDL_free(cursor->mform_p); | ||
59 | |||
60 | SDL_free(cursor); | ||
61 | } | ||
62 | |||
63 | WMcursor *GEM_CreateWMCursor(_THIS, | ||
64 | Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) | ||
65 | { | ||
66 | WMcursor *cursor; | ||
67 | MFORM *new_mform; | ||
68 | int i; | ||
69 | |||
70 | #ifdef DEBUG_VIDEO_GEM | ||
71 | Uint16 *data1, *mask1; | ||
72 | |||
73 | printf("sdl:video:gem: create cursor\n"); | ||
74 | #endif | ||
75 | |||
76 | /* Check the size */ | ||
77 | if ( (w > MAXCURWIDTH) || (h > MAXCURHEIGHT) ) { | ||
78 | SDL_SetError("Only cursors of dimension (%dx%d) are allowed", | ||
79 | MAXCURWIDTH, MAXCURHEIGHT); | ||
80 | return(NULL); | ||
81 | } | ||
82 | |||
83 | /* Allocate the cursor memory */ | ||
84 | cursor = (WMcursor *)SDL_malloc(sizeof(WMcursor)); | ||
85 | if ( cursor == NULL ) { | ||
86 | SDL_OutOfMemory(); | ||
87 | return(NULL); | ||
88 | } | ||
89 | |||
90 | /* Allocate mform */ | ||
91 | new_mform = (MFORM *)SDL_malloc(sizeof(MFORM)); | ||
92 | if (new_mform == NULL) { | ||
93 | SDL_free(cursor); | ||
94 | SDL_OutOfMemory(); | ||
95 | return(NULL); | ||
96 | } | ||
97 | |||
98 | cursor->mform_p = new_mform; | ||
99 | |||
100 | new_mform->mf_xhot = hot_x; | ||
101 | new_mform->mf_yhot = hot_y; | ||
102 | new_mform->mf_nplanes = 1; | ||
103 | new_mform->mf_fg = 0; | ||
104 | new_mform->mf_bg = 1; | ||
105 | |||
106 | for (i=0;i<MAXCURHEIGHT;i++) { | ||
107 | new_mform->mf_mask[i]=0; | ||
108 | new_mform->mf_data[i]=0; | ||
109 | #ifdef DEBUG_VIDEO_GEM | ||
110 | data1 = (Uint16 *) &data[i<<1]; | ||
111 | mask1 = (Uint16 *) &mask[i<<1]; | ||
112 | printf("sdl:video:gem: source: line %d: data=0x%04x, mask=0x%04x\n", | ||
113 | i, data1[i], mask1[i]); | ||
114 | #endif | ||
115 | } | ||
116 | |||
117 | if (w<=8) { | ||
118 | for (i=0;i<h;i++) { | ||
119 | new_mform->mf_mask[i]= mask[i]<<8; | ||
120 | new_mform->mf_data[i]= data[i]<<8; | ||
121 | } | ||
122 | } else { | ||
123 | for (i=0;i<h;i++) { | ||
124 | new_mform->mf_mask[i]= (mask[i<<1]<<8) | mask[(i<<1)+1]; | ||
125 | new_mform->mf_data[i]= (data[i<<1]<<8) | data[(i<<1)+1]; | ||
126 | } | ||
127 | } | ||
128 | |||
129 | #ifdef DEBUG_VIDEO_GEM | ||
130 | for (i=0; i<h ;i++) { | ||
131 | printf("sdl:video:gem: cursor: line %d: data=0x%04x, mask=0x%04x\n", | ||
132 | i, new_mform->mf_data[i], new_mform->mf_mask[i]); | ||
133 | } | ||
134 | |||
135 | printf("sdl:video:gem: CreateWMCursor(): done\n"); | ||
136 | #endif | ||
137 | |||
138 | return cursor; | ||
139 | } | ||
140 | |||
141 | int GEM_ShowWMCursor(_THIS, WMcursor *cursor) | ||
142 | { | ||
143 | GEM_cursor = cursor; | ||
144 | |||
145 | GEM_CheckMouseMode(this); | ||
146 | |||
147 | #ifdef DEBUG_VIDEO_GEM | ||
148 | printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor); | ||
149 | #endif | ||
150 | |||
151 | return 1; | ||
152 | } | ||
153 | |||
154 | #if 0 | ||
155 | void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y) | ||
156 | { | ||
157 | /* This seems to work only on AES 3.4 (Falcon) */ | ||
158 | |||
159 | EVNTREC warpevent; | ||
160 | |||
161 | warpevent.ap_event = APPEVNT_MOUSE; | ||
162 | warpevent.ap_value = (x << 16) | y; | ||
163 | |||
164 | appl_tplay(&warpevent, 1, 1000); | ||
165 | } | ||
166 | #endif | ||
167 | |||
168 | void GEM_CheckMouseMode(_THIS) | ||
169 | { | ||
170 | const Uint8 full_focus = (SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); | ||
171 | int set_system_cursor = 1, show_system_cursor = 1; | ||
172 | |||
173 | #ifdef DEBUG_VIDEO_GEM | ||
174 | printf("sdl:video:gem: check mouse mode\n"); | ||
175 | #endif | ||
176 | |||
177 | /* If the mouse is hidden and input is grabbed, we use relative mode */ | ||
178 | GEM_mouse_relative = (!(SDL_cursorstate & CURSOR_VISIBLE)) | ||
179 | && (this->input_grab != SDL_GRAB_OFF) | ||
180 | && (SDL_GetAppState() & SDL_APPACTIVE); | ||
181 | SDL_AtariXbios_LockMousePosition(GEM_mouse_relative); | ||
182 | |||
183 | if (SDL_cursorstate & CURSOR_VISIBLE) { | ||
184 | /* Application defined cursor only over the application window */ | ||
185 | if ((SDL_GetAppState() & full_focus) == full_focus) { | ||
186 | if (GEM_cursor) { | ||
187 | graf_mouse(USER_DEF, GEM_cursor->mform_p); | ||
188 | set_system_cursor = 0; | ||
189 | } else { | ||
190 | show_system_cursor = 0; | ||
191 | } | ||
192 | } | ||
193 | } else { | ||
194 | /* Mouse cursor hidden only over the application window */ | ||
195 | if ((SDL_GetAppState() & full_focus) == full_focus) { | ||
196 | set_system_cursor = 0; | ||
197 | show_system_cursor = 0; | ||
198 | } | ||
199 | } | ||
200 | |||
201 | graf_mouse(show_system_cursor ? M_ON : M_OFF, NULL); | ||
202 | if (set_system_cursor) { | ||
203 | graf_mouse(ARROW, NULL); | ||
204 | } | ||
205 | } | ||
diff --git a/apps/plugins/sdl/src/video/gem/SDL_gemmouse_c.h b/apps/plugins/sdl/src/video/gem/SDL_gemmouse_c.h deleted file mode 100644 index 06f90ba5e5..0000000000 --- a/apps/plugins/sdl/src/video/gem/SDL_gemmouse_c.h +++ /dev/null | |||
@@ -1,34 +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_gemvideo.h" | ||
25 | |||
26 | /* Functions to be exported */ | ||
27 | extern void GEM_FreeWMCursor(_THIS, WMcursor *cursor); | ||
28 | extern WMcursor *GEM_CreateWMCursor(_THIS, | ||
29 | Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); | ||
30 | extern int GEM_ShowWMCursor(_THIS, WMcursor *cursor); | ||
31 | #if 0 | ||
32 | extern void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y); | ||
33 | #endif | ||
34 | extern void GEM_CheckMouseMode(_THIS); | ||
diff --git a/apps/plugins/sdl/src/video/gem/SDL_gemvideo.c b/apps/plugins/sdl/src/video/gem/SDL_gemvideo.c deleted file mode 100644 index 2ce9151c1d..0000000000 --- a/apps/plugins/sdl/src/video/gem/SDL_gemvideo.c +++ /dev/null | |||
@@ -1,1337 +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 | /* | ||
25 | GEM video driver | ||
26 | |||
27 | Patrice Mandin | ||
28 | and work from | ||
29 | Olivier Landemarre, Johan Klockars, Xavier Joubert, Claude Attard | ||
30 | */ | ||
31 | |||
32 | /* Mint includes */ | ||
33 | #include <gem.h> | ||
34 | #include <gemx.h> | ||
35 | #include <mint/osbind.h> | ||
36 | #include <mint/cookie.h> | ||
37 | |||
38 | #include "SDL_endian.h" | ||
39 | #include "SDL_video.h" | ||
40 | #include "SDL_mouse.h" | ||
41 | #include "../SDL_sysvideo.h" | ||
42 | #include "../SDL_pixels_c.h" | ||
43 | #include "../../events/SDL_events_c.h" | ||
44 | #include "../SDL_cursor_c.h" | ||
45 | |||
46 | #include "../ataricommon/SDL_ataric2p_s.h" | ||
47 | #include "../ataricommon/SDL_atarieddi_s.h" | ||
48 | #include "../ataricommon/SDL_atarimxalloc_c.h" | ||
49 | #include "../ataricommon/SDL_atarigl_c.h" | ||
50 | |||
51 | #include "SDL_gemvideo.h" | ||
52 | #include "SDL_gemevents_c.h" | ||
53 | #include "SDL_gemmouse_c.h" | ||
54 | #include "SDL_gemwm_c.h" | ||
55 | #include "../ataricommon/SDL_xbiosevents_c.h" | ||
56 | #include "../ataricommon/SDL_ataridevmouse_c.h" | ||
57 | |||
58 | /* Defines */ | ||
59 | |||
60 | /*#define DEBUG_VIDEO_GEM 1*/ | ||
61 | |||
62 | #define GEM_VID_DRIVER_NAME "gem" | ||
63 | |||
64 | #undef MIN | ||
65 | #define MIN(a,b) (((a)<(b)) ? (a) : (b)) | ||
66 | #undef MAX | ||
67 | #define MAX(a,b) (((a)>(b)) ? (a) : (b)) | ||
68 | |||
69 | /* Variables */ | ||
70 | |||
71 | static unsigned char vdi_index[256] = { | ||
72 | 0, 2, 3, 6, 4, 7, 5, 8, | ||
73 | 9, 10, 11, 14, 12, 15, 13, 255 | ||
74 | }; | ||
75 | |||
76 | static const char empty_name[]=""; | ||
77 | |||
78 | /* Initialization/Query functions */ | ||
79 | static int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat); | ||
80 | static SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | ||
81 | static SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | ||
82 | static int GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); | ||
83 | static void GEM_VideoQuit(_THIS); | ||
84 | |||
85 | /* Hardware surface functions */ | ||
86 | static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface); | ||
87 | static int GEM_LockHWSurface(_THIS, SDL_Surface *surface); | ||
88 | static int GEM_FlipHWSurface(_THIS, SDL_Surface *surface); | ||
89 | static void GEM_UnlockHWSurface(_THIS, SDL_Surface *surface); | ||
90 | static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface); | ||
91 | static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect *rects); | ||
92 | #if 0 | ||
93 | static int GEM_ToggleFullScreen(_THIS, int on); | ||
94 | #endif | ||
95 | |||
96 | /* Internal functions */ | ||
97 | static void GEM_FreeBuffers(_THIS); | ||
98 | static void GEM_ClearScreen(_THIS); | ||
99 | static void GEM_ClearRect(_THIS, short *rect); | ||
100 | static void GEM_SetNewPalette(_THIS, Uint16 newpal[256][3]); | ||
101 | static void GEM_LockScreen(_THIS); | ||
102 | static void GEM_UnlockScreen(_THIS); | ||
103 | static void refresh_window(_THIS, int winhandle, short *rect); | ||
104 | |||
105 | #if SDL_VIDEO_OPENGL | ||
106 | /* OpenGL functions */ | ||
107 | static void GEM_GL_SwapBuffers(_THIS); | ||
108 | #endif | ||
109 | |||
110 | /* GEM driver bootstrap functions */ | ||
111 | |||
112 | static int GEM_Available(void) | ||
113 | { | ||
114 | /* Test if AES available */ | ||
115 | if (appl_init() == -1) | ||
116 | return 0; | ||
117 | |||
118 | appl_exit(); | ||
119 | return 1; | ||
120 | } | ||
121 | |||
122 | static void GEM_DeleteDevice(SDL_VideoDevice *device) | ||
123 | { | ||
124 | SDL_free(device->hidden); | ||
125 | SDL_free(device); | ||
126 | } | ||
127 | |||
128 | static SDL_VideoDevice *GEM_CreateDevice(int devindex) | ||
129 | { | ||
130 | SDL_VideoDevice *device; | ||
131 | int vectors_mask; | ||
132 | /* unsigned long dummy;*/ | ||
133 | |||
134 | /* Initialize all variables that we clean on shutdown */ | ||
135 | device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); | ||
136 | if ( device ) { | ||
137 | SDL_memset(device, 0, (sizeof *device)); | ||
138 | device->hidden = (struct SDL_PrivateVideoData *) | ||
139 | SDL_malloc((sizeof *device->hidden)); | ||
140 | device->gl_data = (struct SDL_PrivateGLData *) | ||
141 | SDL_malloc((sizeof *device->gl_data)); | ||
142 | } | ||
143 | if ( (device == NULL) || (device->hidden == NULL) ) { | ||
144 | SDL_OutOfMemory(); | ||
145 | if ( device ) { | ||
146 | SDL_free(device); | ||
147 | } | ||
148 | return(0); | ||
149 | } | ||
150 | SDL_memset(device->hidden, 0, (sizeof *device->hidden)); | ||
151 | SDL_memset(device->gl_data, 0, sizeof(*device->gl_data)); | ||
152 | |||
153 | /* Set the function pointers */ | ||
154 | device->VideoInit = GEM_VideoInit; | ||
155 | device->ListModes = GEM_ListModes; | ||
156 | device->SetVideoMode = GEM_SetVideoMode; | ||
157 | device->SetColors = GEM_SetColors; | ||
158 | device->UpdateRects = NULL /*GEM_UpdateRects*/; | ||
159 | device->VideoQuit = GEM_VideoQuit; | ||
160 | device->AllocHWSurface = GEM_AllocHWSurface; | ||
161 | device->LockHWSurface = GEM_LockHWSurface; | ||
162 | device->UnlockHWSurface = GEM_UnlockHWSurface; | ||
163 | device->FlipHWSurface = GEM_FlipHWSurface; | ||
164 | device->FreeHWSurface = GEM_FreeHWSurface; | ||
165 | device->ToggleFullScreen = NULL /*GEM_ToggleFullScreen*/; | ||
166 | |||
167 | /* Window manager */ | ||
168 | device->SetCaption = GEM_SetCaption; | ||
169 | device->SetIcon = GEM_SetIcon; | ||
170 | device->IconifyWindow = GEM_IconifyWindow; | ||
171 | device->GrabInput = GEM_GrabInput; | ||
172 | |||
173 | /* Events */ | ||
174 | device->InitOSKeymap = GEM_InitOSKeymap; | ||
175 | device->PumpEvents = GEM_PumpEvents; | ||
176 | |||
177 | /* Mouse */ | ||
178 | device->FreeWMCursor = GEM_FreeWMCursor; | ||
179 | device->CreateWMCursor = GEM_CreateWMCursor; | ||
180 | device->ShowWMCursor = GEM_ShowWMCursor; | ||
181 | device->WarpWMCursor = NULL /*GEM_WarpWMCursor*/; | ||
182 | device->CheckMouseMode = GEM_CheckMouseMode; | ||
183 | |||
184 | #if SDL_VIDEO_OPENGL | ||
185 | /* OpenGL functions */ | ||
186 | device->GL_LoadLibrary = SDL_AtariGL_LoadLibrary; | ||
187 | device->GL_GetProcAddress = SDL_AtariGL_GetProcAddress; | ||
188 | device->GL_GetAttribute = SDL_AtariGL_GetAttribute; | ||
189 | device->GL_MakeCurrent = SDL_AtariGL_MakeCurrent; | ||
190 | device->GL_SwapBuffers = GEM_GL_SwapBuffers; | ||
191 | #endif | ||
192 | |||
193 | device->hidden->use_dev_mouse = | ||
194 | (SDL_AtariDevMouse_Open()!=0) ? SDL_TRUE : SDL_FALSE; | ||
195 | |||
196 | vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS; /* XBIOS joystick events */ | ||
197 | if (!(device->hidden->use_dev_mouse)) { | ||
198 | vectors_mask |= ATARI_XBIOS_MOUSEEVENTS; /* XBIOS mouse events */ | ||
199 | } | ||
200 | /* if (Getcookie(C_MiNT, &dummy)==C_FOUND) { | ||
201 | vectors_mask = 0; | ||
202 | }*/ | ||
203 | |||
204 | SDL_AtariXbios_InstallVectors(vectors_mask); | ||
205 | |||
206 | device->free = GEM_DeleteDevice; | ||
207 | |||
208 | return device; | ||
209 | } | ||
210 | |||
211 | VideoBootStrap GEM_bootstrap = { | ||
212 | GEM_VID_DRIVER_NAME, "Atari GEM video driver", | ||
213 | GEM_Available, GEM_CreateDevice | ||
214 | }; | ||
215 | |||
216 | static void VDI_ReadExtInfo(_THIS, short *work_out) | ||
217 | { | ||
218 | unsigned long EdDI_version; | ||
219 | long cookie_EdDI; | ||
220 | Uint16 clut_type; | ||
221 | |||
222 | /* Read EdDI informations */ | ||
223 | if (Getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND) { | ||
224 | return; | ||
225 | } | ||
226 | |||
227 | EdDI_version = Atari_get_EdDI_version( (void *)cookie_EdDI); | ||
228 | |||
229 | vq_scrninfo(VDI_handle, work_out); | ||
230 | |||
231 | VDI_format = work_out[0]; | ||
232 | clut_type = work_out[1]; | ||
233 | |||
234 | /* With EdDI>=1.1, we can have screen pitch, address and format | ||
235 | * so we can directly write to screen without using vro_cpyfm | ||
236 | */ | ||
237 | if (EdDI_version >= EDDI_11) { | ||
238 | VDI_pitch = work_out[5]; | ||
239 | VDI_screen = (void *) *((unsigned long *) &work_out[6]); | ||
240 | } | ||
241 | |||
242 | switch(clut_type) { | ||
243 | case VDI_CLUT_HARDWARE: | ||
244 | { | ||
245 | int i; | ||
246 | Uint16 *tmp_p; | ||
247 | |||
248 | tmp_p = (Uint16 *)&work_out[16]; | ||
249 | |||
250 | for (i=0;i<256;i++) { | ||
251 | vdi_index[*tmp_p++] = i; | ||
252 | } | ||
253 | } | ||
254 | break; | ||
255 | case VDI_CLUT_SOFTWARE: | ||
256 | { | ||
257 | int component; /* red, green, blue, alpha, overlay */ | ||
258 | int num_bit; | ||
259 | unsigned short *tmp_p; | ||
260 | |||
261 | /* We can build masks with info here */ | ||
262 | tmp_p = (unsigned short *) &work_out[16]; | ||
263 | for (component=0;component<5;component++) { | ||
264 | for (num_bit=0;num_bit<16;num_bit++) { | ||
265 | unsigned short valeur; | ||
266 | |||
267 | valeur = *tmp_p++; | ||
268 | |||
269 | if (valeur == 0xffff) { | ||
270 | continue; | ||
271 | } | ||
272 | |||
273 | switch(component) { | ||
274 | case 0: | ||
275 | VDI_redmask |= 1<< valeur; | ||
276 | break; | ||
277 | case 1: | ||
278 | VDI_greenmask |= 1<< valeur; | ||
279 | break; | ||
280 | case 2: | ||
281 | VDI_bluemask |= 1<< valeur; | ||
282 | break; | ||
283 | case 3: | ||
284 | VDI_alphamask |= 1<< valeur; | ||
285 | break; | ||
286 | } | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | |||
291 | /* Remove lower green bits for Intel endian screen */ | ||
292 | if ((VDI_greenmask == ((7<<13)|3)) || (VDI_greenmask == ((7<<13)|7))) { | ||
293 | VDI_greenmask &= ~(7<<13); | ||
294 | } | ||
295 | break; | ||
296 | case VDI_CLUT_NONE: | ||
297 | break; | ||
298 | } | ||
299 | } | ||
300 | |||
301 | int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat) | ||
302 | { | ||
303 | int i, menubar_size; | ||
304 | short work_in[12], work_out[272], dummy; | ||
305 | |||
306 | /* Open AES (Application Environment Services) */ | ||
307 | if (appl_init() == -1) { | ||
308 | fprintf(stderr,"Can not open AES\n"); | ||
309 | return 1; | ||
310 | } | ||
311 | |||
312 | /* Read version and features */ | ||
313 | GEM_version = aes_global[0]; | ||
314 | if (GEM_version >= 0x0410) { | ||
315 | short ap_gout[4], errorcode; | ||
316 | |||
317 | GEM_wfeatures=0; | ||
318 | errorcode=appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2], &ap_gout[3]); | ||
319 | |||
320 | if (errorcode==0) { | ||
321 | GEM_wfeatures=ap_gout[0]; | ||
322 | } | ||
323 | } | ||
324 | |||
325 | /* Ask VDI physical workstation handle opened by AES */ | ||
326 | VDI_handle = graf_handle(&dummy, &dummy, &dummy, &dummy); | ||
327 | if (VDI_handle<1) { | ||
328 | fprintf(stderr,"Wrong VDI handle %d returned by AES\n",VDI_handle); | ||
329 | return 1; | ||
330 | } | ||
331 | |||
332 | /* Open virtual VDI workstation */ | ||
333 | work_in[0]=Getrez()+2; | ||
334 | for(i = 1; i < 10; i++) | ||
335 | work_in[i] = 1; | ||
336 | work_in[10] = 2; | ||
337 | |||
338 | v_opnvwk(work_in, &VDI_handle, work_out); | ||
339 | if (VDI_handle == 0) { | ||
340 | fprintf(stderr,"Can not open VDI virtual workstation\n"); | ||
341 | return 1; | ||
342 | } | ||
343 | |||
344 | /* Read fullscreen size */ | ||
345 | VDI_w = work_out[0] + 1; | ||
346 | VDI_h = work_out[1] + 1; | ||
347 | |||
348 | /* Read desktop size and position */ | ||
349 | if (!wind_get(DESKTOP_HANDLE, WF_WORKXYWH, &GEM_desk_x, &GEM_desk_y, &GEM_desk_w, &GEM_desk_h)) { | ||
350 | fprintf(stderr,"Can not read desktop properties\n"); | ||
351 | return 1; | ||
352 | } | ||
353 | |||
354 | /* Read bit depth */ | ||
355 | vq_extnd(VDI_handle, 1, work_out); | ||
356 | VDI_bpp = work_out[4]; | ||
357 | VDI_oldnumcolors=0; | ||
358 | |||
359 | switch(VDI_bpp) { | ||
360 | case 8: | ||
361 | VDI_pixelsize=1; | ||
362 | break; | ||
363 | case 15: | ||
364 | case 16: | ||
365 | VDI_pixelsize=2; | ||
366 | break; | ||
367 | case 24: | ||
368 | VDI_pixelsize=3; | ||
369 | break; | ||
370 | case 32: | ||
371 | VDI_pixelsize=4; | ||
372 | break; | ||
373 | default: | ||
374 | fprintf(stderr,"%d bits colour depth not supported\n",VDI_bpp); | ||
375 | return 1; | ||
376 | } | ||
377 | |||
378 | /* Setup hardware -> VDI palette mapping */ | ||
379 | for(i = 16; i < 255; i++) { | ||
380 | vdi_index[i] = i; | ||
381 | } | ||
382 | vdi_index[255] = 1; | ||
383 | |||
384 | /* Save current palette */ | ||
385 | if (VDI_bpp>8) { | ||
386 | VDI_oldnumcolors=1<<8; | ||
387 | } else { | ||
388 | VDI_oldnumcolors=1<<VDI_bpp; | ||
389 | } | ||
390 | |||
391 | for(i = 0; i < VDI_oldnumcolors; i++) { | ||
392 | short rgb[3]; | ||
393 | |||
394 | vq_color(VDI_handle, i, 0, rgb); | ||
395 | |||
396 | VDI_oldpalette[i][0] = rgb[0]; | ||
397 | VDI_oldpalette[i][1] = rgb[1]; | ||
398 | VDI_oldpalette[i][2] = rgb[2]; | ||
399 | } | ||
400 | VDI_setpalette = GEM_SetNewPalette; | ||
401 | SDL_memcpy(VDI_curpalette,VDI_oldpalette,sizeof(VDI_curpalette)); | ||
402 | |||
403 | /* Setup screen info */ | ||
404 | GEM_title_name = empty_name; | ||
405 | GEM_icon_name = empty_name; | ||
406 | |||
407 | GEM_handle = -1; | ||
408 | GEM_locked = SDL_FALSE; | ||
409 | GEM_win_fulled = SDL_FALSE; | ||
410 | GEM_fullscreen = SDL_FALSE; | ||
411 | GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers are setup */ | ||
412 | |||
413 | VDI_screen = NULL; | ||
414 | VDI_pitch = VDI_w * VDI_pixelsize; | ||
415 | VDI_format = ( (VDI_bpp <= 8) ? VDI_FORMAT_INTER : VDI_FORMAT_PACK); | ||
416 | VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0; | ||
417 | VDI_ReadExtInfo(this, work_out); | ||
418 | |||
419 | #ifdef DEBUG_VIDEO_GEM | ||
420 | printf("sdl:video:gem: screen: address=0x%08x, pitch=%d\n", VDI_screen, VDI_pitch); | ||
421 | printf("sdl:video:gem: format=%d\n", VDI_format); | ||
422 | printf("sdl:video:gem: masks: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", | ||
423 | VDI_alphamask, VDI_redmask, VDI_greenmask, VDI_bluemask | ||
424 | ); | ||
425 | #endif | ||
426 | |||
427 | /* Setup destination mfdb */ | ||
428 | VDI_dst_mfdb.fd_addr = NULL; | ||
429 | |||
430 | /* Determine the current screen size */ | ||
431 | this->info.current_w = VDI_w; | ||
432 | this->info.current_h = VDI_h; | ||
433 | |||
434 | /* Determine the screen depth */ | ||
435 | /* we change this during the SDL_SetVideoMode implementation... */ | ||
436 | vformat->BitsPerPixel = VDI_bpp; | ||
437 | |||
438 | /* Set mouse cursor to arrow */ | ||
439 | graf_mouse(ARROW, NULL); | ||
440 | GEM_cursor = NULL; | ||
441 | |||
442 | /* Init chunky to planar routine */ | ||
443 | SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8; | ||
444 | |||
445 | /* Setup VDI fill functions */ | ||
446 | vsf_color(VDI_handle,0); | ||
447 | vsf_interior(VDI_handle,1); | ||
448 | vsf_perimeter(VDI_handle,0); | ||
449 | |||
450 | /* Menu bar save buffer */ | ||
451 | menubar_size = GEM_desk_w * GEM_desk_y * VDI_pixelsize; | ||
452 | GEM_menubar=Atari_SysMalloc(menubar_size,MX_PREFTTRAM); | ||
453 | |||
454 | /* Fill video modes list */ | ||
455 | SDL_modelist[0] = SDL_malloc(sizeof(SDL_Rect)); | ||
456 | SDL_modelist[0]->x = 0; | ||
457 | SDL_modelist[0]->y = 0; | ||
458 | SDL_modelist[0]->w = VDI_w; | ||
459 | SDL_modelist[0]->h = VDI_h; | ||
460 | |||
461 | SDL_modelist[1] = NULL; | ||
462 | |||
463 | #if SDL_VIDEO_OPENGL | ||
464 | SDL_AtariGL_InitPointers(this); | ||
465 | #endif | ||
466 | |||
467 | this->info.wm_available = 1; | ||
468 | |||
469 | /* We're done! */ | ||
470 | return(0); | ||
471 | } | ||
472 | |||
473 | SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | ||
474 | { | ||
475 | if (format->BitsPerPixel != VDI_bpp) { | ||
476 | return ((SDL_Rect **)NULL); | ||
477 | } | ||
478 | |||
479 | if (flags & SDL_FULLSCREEN) { | ||
480 | return (SDL_modelist); | ||
481 | } | ||
482 | |||
483 | return((SDL_Rect **)-1); | ||
484 | } | ||
485 | |||
486 | static void GEM_FreeBuffers(_THIS) | ||
487 | { | ||
488 | /* Release buffer */ | ||
489 | if ( GEM_buffer2 ) { | ||
490 | Mfree( GEM_buffer2 ); | ||
491 | GEM_buffer2=NULL; | ||
492 | } | ||
493 | |||
494 | if ( GEM_buffer1 ) { | ||
495 | Mfree( GEM_buffer1 ); | ||
496 | GEM_buffer1=NULL; | ||
497 | } | ||
498 | } | ||
499 | |||
500 | static void GEM_ClearRect(_THIS, short *rect) | ||
501 | { | ||
502 | short oldrgb[3], rgb[3]={0,0,0}; | ||
503 | |||
504 | vq_color(VDI_handle, vdi_index[0], 0, oldrgb); | ||
505 | vs_color(VDI_handle, vdi_index[0], rgb); | ||
506 | |||
507 | vsf_color(VDI_handle,0); | ||
508 | vsf_interior(VDI_handle,1); | ||
509 | vsf_perimeter(VDI_handle,0); | ||
510 | v_bar(VDI_handle, rect); | ||
511 | |||
512 | vs_color(VDI_handle, vdi_index[0], oldrgb); | ||
513 | } | ||
514 | |||
515 | static void GEM_ClearScreen(_THIS) | ||
516 | { | ||
517 | short pxy[4]; | ||
518 | |||
519 | v_hide_c(VDI_handle); | ||
520 | |||
521 | pxy[0] = pxy[1] = 0; | ||
522 | pxy[2] = VDI_w - 1; | ||
523 | pxy[3] = VDI_h - 1; | ||
524 | GEM_ClearRect(this, pxy); | ||
525 | |||
526 | v_show_c(VDI_handle, 1); | ||
527 | } | ||
528 | |||
529 | static void GEM_SetNewPalette(_THIS, Uint16 newpal[256][3]) | ||
530 | { | ||
531 | int i; | ||
532 | short rgb[3]; | ||
533 | |||
534 | if (VDI_oldnumcolors==0) | ||
535 | return; | ||
536 | |||
537 | for(i = 0; i < VDI_oldnumcolors; i++) { | ||
538 | rgb[0] = newpal[i][0]; | ||
539 | rgb[1] = newpal[i][1]; | ||
540 | rgb[2] = newpal[i][2]; | ||
541 | |||
542 | vs_color(VDI_handle, i, rgb); | ||
543 | } | ||
544 | } | ||
545 | |||
546 | static void GEM_LockScreen(_THIS) | ||
547 | { | ||
548 | if (!GEM_locked) { | ||
549 | /* Lock AES */ | ||
550 | wind_update(BEG_UPDATE); | ||
551 | wind_update(BEG_MCTRL); | ||
552 | /* Reserve memory space, used to be sure of compatibility */ | ||
553 | form_dial( FMD_START, 0,0,0,0, 0,0,VDI_w,VDI_h); | ||
554 | |||
555 | /* Save menu bar */ | ||
556 | if (GEM_menubar) { | ||
557 | MFDB mfdb_src; | ||
558 | short blitcoords[8]; | ||
559 | |||
560 | mfdb_src.fd_addr=GEM_menubar; | ||
561 | mfdb_src.fd_w=GEM_desk_w; | ||
562 | mfdb_src.fd_h=GEM_desk_y; | ||
563 | mfdb_src.fd_wdwidth=GEM_desk_w>>4; | ||
564 | mfdb_src.fd_nplanes=VDI_bpp; | ||
565 | mfdb_src.fd_stand= | ||
566 | mfdb_src.fd_r1= | ||
567 | mfdb_src.fd_r2= | ||
568 | mfdb_src.fd_r3= 0; | ||
569 | |||
570 | blitcoords[0] = blitcoords[4] = 0; | ||
571 | blitcoords[1] = blitcoords[5] = 0; | ||
572 | blitcoords[2] = blitcoords[6] = GEM_desk_w-1; | ||
573 | blitcoords[3] = blitcoords[7] = GEM_desk_y-1; | ||
574 | |||
575 | vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &VDI_dst_mfdb, &mfdb_src); | ||
576 | } | ||
577 | |||
578 | GEM_locked=SDL_TRUE; | ||
579 | } | ||
580 | } | ||
581 | |||
582 | static void GEM_UnlockScreen(_THIS) | ||
583 | { | ||
584 | if (GEM_locked) { | ||
585 | /* Restore menu bar */ | ||
586 | if (GEM_menubar) { | ||
587 | MFDB mfdb_src; | ||
588 | short blitcoords[8]; | ||
589 | |||
590 | mfdb_src.fd_addr=GEM_menubar; | ||
591 | mfdb_src.fd_w=GEM_desk_w; | ||
592 | mfdb_src.fd_h=GEM_desk_y; | ||
593 | mfdb_src.fd_wdwidth=GEM_desk_w>>4; | ||
594 | mfdb_src.fd_nplanes=VDI_bpp; | ||
595 | mfdb_src.fd_stand= | ||
596 | mfdb_src.fd_r1= | ||
597 | mfdb_src.fd_r2= | ||
598 | mfdb_src.fd_r3= 0; | ||
599 | |||
600 | blitcoords[0] = blitcoords[4] = 0; | ||
601 | blitcoords[1] = blitcoords[5] = 0; | ||
602 | blitcoords[2] = blitcoords[6] = GEM_desk_w-1; | ||
603 | blitcoords[3] = blitcoords[7] = GEM_desk_y-1; | ||
604 | |||
605 | vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); | ||
606 | } | ||
607 | |||
608 | /* Restore screen memory, and send REDRAW to all apps */ | ||
609 | form_dial( FMD_FINISH, 0,0,0,0, 0,0,VDI_w,VDI_h); | ||
610 | /* Unlock AES */ | ||
611 | wind_update(END_MCTRL); | ||
612 | wind_update(END_UPDATE); | ||
613 | |||
614 | GEM_locked=SDL_FALSE; | ||
615 | } | ||
616 | } | ||
617 | |||
618 | SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, | ||
619 | int width, int height, int bpp, Uint32 flags) | ||
620 | { | ||
621 | Uint32 modeflags, screensize; | ||
622 | SDL_bool use_shadow1, use_shadow2; | ||
623 | |||
624 | /* width must be multiple of 16, for vro_cpyfm() and c2p_convert() */ | ||
625 | if ((width & 15) != 0) { | ||
626 | width = (width | 15) +1; | ||
627 | } | ||
628 | |||
629 | /*--- Verify if asked mode can be used ---*/ | ||
630 | if (VDI_bpp != bpp) { | ||
631 | SDL_SetError("%d bpp mode not supported", bpp); | ||
632 | return(NULL); | ||
633 | } | ||
634 | |||
635 | if (flags & SDL_FULLSCREEN) { | ||
636 | if ((VDI_w < width) || (VDI_h < height)) { | ||
637 | SDL_SetError("%dx%d mode is too large", width, height); | ||
638 | return(NULL); | ||
639 | } | ||
640 | } | ||
641 | |||
642 | /*--- Allocate the new pixel format for the screen ---*/ | ||
643 | if ( ! SDL_ReallocFormat(current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, VDI_alphamask) ) { | ||
644 | SDL_SetError("Couldn't allocate new pixel format for requested mode"); | ||
645 | return(NULL); | ||
646 | } | ||
647 | |||
648 | screensize = width * height * VDI_pixelsize; | ||
649 | |||
650 | #ifdef DEBUG_VIDEO_GEM | ||
651 | printf("sdl:video:gem: setvideomode(): %dx%dx%d = %d\n", width, height, bpp, screensize); | ||
652 | #endif | ||
653 | |||
654 | /*--- Allocate shadow buffers if needed, and conversion operations ---*/ | ||
655 | GEM_FreeBuffers(this); | ||
656 | |||
657 | GEM_bufops=0; | ||
658 | use_shadow1=use_shadow2=SDL_FALSE; | ||
659 | if (VDI_screen && (flags & SDL_FULLSCREEN)) { | ||
660 | if (VDI_format==VDI_FORMAT_INTER) { | ||
661 | use_shadow1=SDL_TRUE; | ||
662 | GEM_bufops = B2S_C2P_1TOS; | ||
663 | } | ||
664 | } else { | ||
665 | use_shadow1=SDL_TRUE; | ||
666 | if (VDI_format==VDI_FORMAT_PACK) { | ||
667 | GEM_bufops = B2S_VROCPYFM_1TOS; | ||
668 | } else { | ||
669 | use_shadow2=SDL_TRUE; | ||
670 | GEM_bufops = B2S_C2P_1TO2|B2S_VROCPYFM_2TOS; | ||
671 | } | ||
672 | } | ||
673 | |||
674 | if (use_shadow1) { | ||
675 | GEM_buffer1 = Atari_SysMalloc(screensize, MX_PREFTTRAM); | ||
676 | if (GEM_buffer1==NULL) { | ||
677 | SDL_SetError("Can not allocate %d KB for frame buffer", screensize>>10); | ||
678 | return NULL; | ||
679 | } | ||
680 | SDL_memset(GEM_buffer1, 0, screensize); | ||
681 | #ifdef DEBUG_VIDEO_GEM | ||
682 | printf("sdl:video:gem: setvideomode(): allocated buffer 1\n"); | ||
683 | #endif | ||
684 | } | ||
685 | |||
686 | if (use_shadow2) { | ||
687 | GEM_buffer2 = Atari_SysMalloc(screensize, MX_PREFTTRAM); | ||
688 | if (GEM_buffer2==NULL) { | ||
689 | SDL_SetError("Can not allocate %d KB for shadow buffer", screensize>>10); | ||
690 | return NULL; | ||
691 | } | ||
692 | SDL_memset(GEM_buffer2, 0, screensize); | ||
693 | #ifdef DEBUG_VIDEO_GEM | ||
694 | printf("sdl:video:gem: setvideomode(): allocated buffer 2\n"); | ||
695 | #endif | ||
696 | } | ||
697 | |||
698 | /*--- Initialize screen ---*/ | ||
699 | modeflags = SDL_PREALLOC; | ||
700 | if (VDI_bpp == 8) { | ||
701 | modeflags |= SDL_HWPALETTE; | ||
702 | } | ||
703 | |||
704 | if (flags & SDL_FULLSCREEN) { | ||
705 | GEM_LockScreen(this); | ||
706 | |||
707 | GEM_ClearScreen(this); | ||
708 | |||
709 | modeflags |= SDL_FULLSCREEN; | ||
710 | if (VDI_screen && (VDI_format==VDI_FORMAT_PACK) && !use_shadow1) { | ||
711 | modeflags |= SDL_HWSURFACE; | ||
712 | } else { | ||
713 | modeflags |= SDL_SWSURFACE; | ||
714 | } | ||
715 | |||
716 | GEM_fullscreen = SDL_TRUE; | ||
717 | } else { | ||
718 | int old_win_type; | ||
719 | short x2,y2,w2,h2; | ||
720 | |||
721 | GEM_UnlockScreen(this); | ||
722 | |||
723 | /* Set window gadgets */ | ||
724 | old_win_type = GEM_win_type; | ||
725 | if (!(flags & SDL_NOFRAME)) { | ||
726 | GEM_win_type=NAME|MOVER|CLOSER|SMALLER; | ||
727 | if (flags & SDL_RESIZABLE) { | ||
728 | GEM_win_type |= FULLER|SIZER; | ||
729 | modeflags |= SDL_RESIZABLE; | ||
730 | } | ||
731 | } else { | ||
732 | GEM_win_type=0; | ||
733 | modeflags |= SDL_NOFRAME; | ||
734 | } | ||
735 | modeflags |= SDL_SWSURFACE; | ||
736 | |||
737 | /* Recreate window ? only for different widget or non-created window */ | ||
738 | if ((old_win_type != GEM_win_type) || (GEM_handle < 0)) { | ||
739 | /* Calculate window size */ | ||
740 | if (!wind_calc(WC_BORDER, GEM_win_type, 0,0,width,height, &x2,&y2,&w2,&h2)) { | ||
741 | GEM_FreeBuffers(this); | ||
742 | SDL_SetError("Can not calculate window attributes"); | ||
743 | return NULL; | ||
744 | } | ||
745 | |||
746 | /* Center window */ | ||
747 | x2 = (GEM_desk_w-w2)>>1; | ||
748 | y2 = (GEM_desk_h-h2)>>1; | ||
749 | if (x2<0) { | ||
750 | x2 = 0; | ||
751 | } | ||
752 | if (y2<0) { | ||
753 | y2 = 0; | ||
754 | } | ||
755 | x2 += GEM_desk_x; | ||
756 | y2 += GEM_desk_y; | ||
757 | |||
758 | /* Destroy existing window */ | ||
759 | if (GEM_handle >= 0) { | ||
760 | wind_close(GEM_handle); | ||
761 | wind_delete(GEM_handle); | ||
762 | } | ||
763 | |||
764 | /* Create window */ | ||
765 | GEM_handle=wind_create(GEM_win_type, x2,y2,w2,h2); | ||
766 | if (GEM_handle<0) { | ||
767 | GEM_FreeBuffers(this); | ||
768 | SDL_SetError("Can not create window"); | ||
769 | return NULL; | ||
770 | } | ||
771 | |||
772 | #ifdef DEBUG_VIDEO_GEM | ||
773 | printf("sdl:video:gem: handle=%d\n", GEM_handle); | ||
774 | #endif | ||
775 | |||
776 | /* Setup window name */ | ||
777 | wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0); | ||
778 | GEM_refresh_name = SDL_FALSE; | ||
779 | |||
780 | /* Open the window */ | ||
781 | wind_open(GEM_handle,x2,y2,w2,h2); | ||
782 | } else { | ||
783 | /* Resize window to fit asked video mode */ | ||
784 | wind_get (GEM_handle, WF_WORKXYWH, &x2,&y2,&w2,&h2); | ||
785 | if (wind_calc(WC_BORDER, GEM_win_type, x2,y2,width,height, &x2,&y2,&w2,&h2)) { | ||
786 | wind_set (GEM_handle, WF_CURRXYWH, x2,y2,w2,h2); | ||
787 | } | ||
788 | } | ||
789 | |||
790 | GEM_fullscreen = SDL_FALSE; | ||
791 | } | ||
792 | |||
793 | /* Set up the new mode framebuffer */ | ||
794 | current->w = width; | ||
795 | current->h = height; | ||
796 | if (use_shadow1) { | ||
797 | current->pixels = GEM_buffer1; | ||
798 | current->pitch = width * VDI_pixelsize; | ||
799 | } else { | ||
800 | current->pixels = VDI_screen; | ||
801 | current->pitch = VDI_pitch; | ||
802 | } | ||
803 | |||
804 | #if SDL_VIDEO_OPENGL | ||
805 | if (flags & SDL_OPENGL) { | ||
806 | if (!SDL_AtariGL_Init(this, current)) { | ||
807 | GEM_FreeBuffers(this); | ||
808 | SDL_SetError("Can not create OpenGL context"); | ||
809 | return NULL; | ||
810 | } | ||
811 | |||
812 | modeflags |= SDL_OPENGL; | ||
813 | } | ||
814 | #endif | ||
815 | |||
816 | current->flags = modeflags; | ||
817 | |||
818 | #ifdef DEBUG_VIDEO_GEM | ||
819 | printf("sdl:video:gem: surface: %dx%d\n", current->w, current->h); | ||
820 | #endif | ||
821 | |||
822 | this->UpdateRects = GEM_UpdateRects; | ||
823 | GEM_lock_redraw = SDL_FALSE; /* Enable redraw */ | ||
824 | |||
825 | /* We're done */ | ||
826 | return(current); | ||
827 | } | ||
828 | |||
829 | static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface) | ||
830 | { | ||
831 | return -1; | ||
832 | } | ||
833 | |||
834 | static void GEM_FreeHWSurface(_THIS, SDL_Surface *surface) | ||
835 | { | ||
836 | return; | ||
837 | } | ||
838 | |||
839 | static int GEM_LockHWSurface(_THIS, SDL_Surface *surface) | ||
840 | { | ||
841 | return(0); | ||
842 | } | ||
843 | |||
844 | static void GEM_UnlockHWSurface(_THIS, SDL_Surface *surface) | ||
845 | { | ||
846 | return; | ||
847 | } | ||
848 | |||
849 | static void GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect *rects) | ||
850 | { | ||
851 | SDL_Surface *surface; | ||
852 | int i, surf_width; | ||
853 | |||
854 | surface = this->screen; | ||
855 | /* Need to be a multiple of 16 pixels */ | ||
856 | surf_width=surface->w; | ||
857 | if ((surf_width & 15) != 0) { | ||
858 | surf_width = (surf_width | 15) + 1; | ||
859 | } | ||
860 | |||
861 | if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) { | ||
862 | void *destscr; | ||
863 | int destpitch; | ||
864 | |||
865 | if (GEM_bufops & B2S_C2P_1TOS) { | ||
866 | destscr = VDI_screen; | ||
867 | destpitch = VDI_pitch; | ||
868 | } else { | ||
869 | destscr = GEM_buffer2; | ||
870 | destpitch = surface->pitch; | ||
871 | } | ||
872 | |||
873 | for (i=0;i<numrects;i++) { | ||
874 | void *source,*destination; | ||
875 | int x1,x2; | ||
876 | |||
877 | x1 = rects[i].x & ~15; | ||
878 | x2 = rects[i].x+rects[i].w; | ||
879 | if (x2 & 15) { | ||
880 | x2 = (x2 | 15) +1; | ||
881 | } | ||
882 | |||
883 | source = surface->pixels; | ||
884 | source += surface->pitch * rects[i].y; | ||
885 | source += x1; | ||
886 | |||
887 | destination = destscr; | ||
888 | destination += destpitch * rects[i].y; | ||
889 | destination += x1; | ||
890 | |||
891 | SDL_Atari_C2pConvert( | ||
892 | source, destination, | ||
893 | x2-x1, rects[i].h, | ||
894 | SDL_FALSE, | ||
895 | surface->pitch, destpitch | ||
896 | ); | ||
897 | } | ||
898 | } | ||
899 | |||
900 | if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) { | ||
901 | MFDB mfdb_src; | ||
902 | short blitcoords[8]; | ||
903 | |||
904 | mfdb_src.fd_addr=surface->pixels; | ||
905 | mfdb_src.fd_w=surf_width; | ||
906 | mfdb_src.fd_h=surface->h; | ||
907 | mfdb_src.fd_wdwidth= (surface->pitch/VDI_pixelsize) >> 4; | ||
908 | mfdb_src.fd_nplanes=surface->format->BitsPerPixel; | ||
909 | mfdb_src.fd_stand= | ||
910 | mfdb_src.fd_r1= | ||
911 | mfdb_src.fd_r2= | ||
912 | mfdb_src.fd_r3= 0; | ||
913 | if (GEM_bufops & B2S_VROCPYFM_2TOS) { | ||
914 | mfdb_src.fd_addr=GEM_buffer2; | ||
915 | } | ||
916 | |||
917 | for ( i=0; i<numrects; ++i ) { | ||
918 | blitcoords[0] = blitcoords[4] = rects[i].x; | ||
919 | blitcoords[1] = blitcoords[5] = rects[i].y; | ||
920 | blitcoords[2] = blitcoords[6] = rects[i].x + rects[i].w - 1; | ||
921 | blitcoords[3] = blitcoords[7] = rects[i].y + rects[i].h - 1; | ||
922 | |||
923 | vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); | ||
924 | } | ||
925 | } | ||
926 | } | ||
927 | |||
928 | static void GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect *rects) | ||
929 | { | ||
930 | short pxy[4], wind_pxy[4]; | ||
931 | int i; | ||
932 | |||
933 | if (wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) { | ||
934 | return; | ||
935 | } | ||
936 | |||
937 | for ( i=0; i<numrects; ++i ) { | ||
938 | pxy[0] = wind_pxy[0] + rects[i].x; | ||
939 | pxy[1] = wind_pxy[1] + rects[i].y; | ||
940 | pxy[2] = rects[i].w; | ||
941 | pxy[3] = rects[i].h; | ||
942 | |||
943 | GEM_wind_redraw(this, GEM_handle, pxy); | ||
944 | } | ||
945 | } | ||
946 | |||
947 | static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect *rects) | ||
948 | { | ||
949 | SDL_Surface *surface; | ||
950 | |||
951 | if (GEM_lock_redraw) { | ||
952 | return; | ||
953 | } | ||
954 | |||
955 | surface = this->screen; | ||
956 | |||
957 | if (surface->flags & SDL_FULLSCREEN) { | ||
958 | GEM_UpdateRectsFullscreen(this, numrects, rects); | ||
959 | } else { | ||
960 | GEM_UpdateRectsWindowed(this, numrects, rects); | ||
961 | } | ||
962 | } | ||
963 | |||
964 | static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface) | ||
965 | { | ||
966 | int surf_width; | ||
967 | |||
968 | /* Need to be a multiple of 16 pixels */ | ||
969 | surf_width=surface->w; | ||
970 | if ((surf_width & 15) != 0) { | ||
971 | surf_width = (surf_width | 15) + 1; | ||
972 | } | ||
973 | |||
974 | if (GEM_bufops & (B2S_C2P_1TO2|B2S_C2P_1TOS)) { | ||
975 | void *destscr; | ||
976 | int destpitch; | ||
977 | |||
978 | if (GEM_bufops & B2S_C2P_1TOS) { | ||
979 | destscr = VDI_screen; | ||
980 | destpitch = VDI_pitch; | ||
981 | } else { | ||
982 | destscr = GEM_buffer2; | ||
983 | destpitch = surface->pitch; | ||
984 | } | ||
985 | |||
986 | SDL_Atari_C2pConvert( | ||
987 | surface->pixels, destscr, | ||
988 | surf_width, surface->h, | ||
989 | SDL_FALSE, | ||
990 | surface->pitch, destpitch | ||
991 | ); | ||
992 | } | ||
993 | |||
994 | if (GEM_bufops & (B2S_VROCPYFM_1TOS|B2S_VROCPYFM_2TOS)) { | ||
995 | MFDB mfdb_src; | ||
996 | short blitcoords[8]; | ||
997 | |||
998 | mfdb_src.fd_w=surf_width; | ||
999 | mfdb_src.fd_h=surface->h; | ||
1000 | mfdb_src.fd_wdwidth=mfdb_src.fd_w >> 4; | ||
1001 | mfdb_src.fd_nplanes=surface->format->BitsPerPixel; | ||
1002 | mfdb_src.fd_stand= | ||
1003 | mfdb_src.fd_r1= | ||
1004 | mfdb_src.fd_r2= | ||
1005 | mfdb_src.fd_r3= 0; | ||
1006 | if (GEM_bufops & B2S_VROCPYFM_1TOS) { | ||
1007 | mfdb_src.fd_addr=surface->pixels; | ||
1008 | } else { | ||
1009 | mfdb_src.fd_addr=GEM_buffer2; | ||
1010 | } | ||
1011 | |||
1012 | blitcoords[0] = blitcoords[4] = 0; | ||
1013 | blitcoords[1] = blitcoords[5] = 0; | ||
1014 | blitcoords[2] = blitcoords[6] = surface->w - 1; | ||
1015 | blitcoords[3] = blitcoords[7] = surface->h - 1; | ||
1016 | |||
1017 | vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb); | ||
1018 | } | ||
1019 | |||
1020 | return(0); | ||
1021 | } | ||
1022 | |||
1023 | static int GEM_FlipHWSurfaceWindowed(_THIS, SDL_Surface *surface) | ||
1024 | { | ||
1025 | short pxy[8]; | ||
1026 | |||
1027 | /* Update the whole window */ | ||
1028 | wind_get(GEM_handle, WF_WORKXYWH, &pxy[0], &pxy[1], &pxy[2], &pxy[3]); | ||
1029 | |||
1030 | GEM_wind_redraw(this, GEM_handle, pxy); | ||
1031 | |||
1032 | return(0); | ||
1033 | } | ||
1034 | |||
1035 | static int GEM_FlipHWSurface(_THIS, SDL_Surface *surface) | ||
1036 | { | ||
1037 | if (GEM_lock_redraw) { | ||
1038 | return(0); | ||
1039 | } | ||
1040 | |||
1041 | if (surface->flags & SDL_FULLSCREEN) { | ||
1042 | return GEM_FlipHWSurfaceFullscreen(this, surface); | ||
1043 | } else { | ||
1044 | return GEM_FlipHWSurfaceWindowed(this, surface); | ||
1045 | } | ||
1046 | } | ||
1047 | |||
1048 | static int GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | ||
1049 | { | ||
1050 | int i; | ||
1051 | SDL_Surface *surface; | ||
1052 | |||
1053 | #ifdef DEBUG_VIDEO_GEM | ||
1054 | printf("sdl:video:gem: setcolors()\n"); | ||
1055 | #endif | ||
1056 | |||
1057 | /* Do not change palette in True Colour */ | ||
1058 | surface = this->screen; | ||
1059 | if (surface->format->BitsPerPixel > 8) { | ||
1060 | return 1; | ||
1061 | } | ||
1062 | |||
1063 | for(i = 0; i < ncolors; i++) | ||
1064 | { | ||
1065 | int r, g, b; | ||
1066 | short rgb[3]; | ||
1067 | |||
1068 | r = colors[i].r; | ||
1069 | g = colors[i].g; | ||
1070 | b = colors[i].b; | ||
1071 | |||
1072 | rgb[0] = VDI_curpalette[i][0] = (1000 * r) / 255; | ||
1073 | rgb[1] = VDI_curpalette[i][1] =(1000 * g) / 255; | ||
1074 | rgb[2] = VDI_curpalette[i][2] =(1000 * b) / 255; | ||
1075 | |||
1076 | vs_color(VDI_handle, vdi_index[firstcolor+i], rgb); | ||
1077 | } | ||
1078 | |||
1079 | return(1); | ||
1080 | } | ||
1081 | |||
1082 | #if 0 | ||
1083 | static int GEM_ToggleFullScreen(_THIS, int on) | ||
1084 | { | ||
1085 | if (on) { | ||
1086 | GEM_LockScreen(this); | ||
1087 | } else { | ||
1088 | GEM_UnlockScreen(this); | ||
1089 | } | ||
1090 | |||
1091 | return(1); | ||
1092 | } | ||
1093 | #endif | ||
1094 | |||
1095 | /* Note: If we are terminated, this could be called in the middle of | ||
1096 | another SDL video routine -- notably UpdateRects. | ||
1097 | */ | ||
1098 | void GEM_VideoQuit(_THIS) | ||
1099 | { | ||
1100 | SDL_AtariXbios_RestoreVectors(); | ||
1101 | if (GEM_usedevmouse) { | ||
1102 | SDL_AtariDevMouse_Close(); | ||
1103 | } | ||
1104 | |||
1105 | GEM_FreeBuffers(this); | ||
1106 | |||
1107 | #if SDL_VIDEO_OPENGL | ||
1108 | if (gl_active) { | ||
1109 | SDL_AtariGL_Quit(this, SDL_TRUE); | ||
1110 | } | ||
1111 | #endif | ||
1112 | |||
1113 | /* Destroy window */ | ||
1114 | if (GEM_handle>=0) { | ||
1115 | wind_close(GEM_handle); | ||
1116 | wind_delete(GEM_handle); | ||
1117 | GEM_handle=-1; | ||
1118 | } | ||
1119 | |||
1120 | GEM_UnlockScreen(this); | ||
1121 | if (GEM_menubar) { | ||
1122 | Mfree(GEM_menubar); | ||
1123 | GEM_menubar=NULL; | ||
1124 | } | ||
1125 | |||
1126 | appl_exit(); | ||
1127 | |||
1128 | GEM_SetNewPalette(this, VDI_oldpalette); | ||
1129 | |||
1130 | /* Close VDI workstation */ | ||
1131 | if (VDI_handle) { | ||
1132 | v_clsvwk(VDI_handle); | ||
1133 | } | ||
1134 | |||
1135 | /* Free mode list */ | ||
1136 | if (SDL_modelist[0]) { | ||
1137 | SDL_free(SDL_modelist[0]); | ||
1138 | SDL_modelist[0]=NULL; | ||
1139 | } | ||
1140 | |||
1141 | this->screen->pixels = NULL; | ||
1142 | } | ||
1143 | |||
1144 | void GEM_wind_redraw(_THIS, int winhandle, short *inside) | ||
1145 | { | ||
1146 | short todo[4]; | ||
1147 | |||
1148 | /* Tell AES we are going to update */ | ||
1149 | wind_update(BEG_UPDATE); | ||
1150 | |||
1151 | v_hide_c(VDI_handle); | ||
1152 | |||
1153 | /* Browse the rectangle list to redraw */ | ||
1154 | if (wind_get(winhandle, WF_FIRSTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])!=0) { | ||
1155 | |||
1156 | while (todo[2] && todo[3]) { | ||
1157 | |||
1158 | if (rc_intersect((GRECT *)inside,(GRECT *)todo)) { | ||
1159 | todo[2] += todo[0]-1; | ||
1160 | todo[3] += todo[1]-1; | ||
1161 | refresh_window(this, winhandle, todo); | ||
1162 | } | ||
1163 | |||
1164 | if (wind_get(winhandle, WF_NEXTXYWH, &todo[0], &todo[1], &todo[2], &todo[3])==0) { | ||
1165 | break; | ||
1166 | } | ||
1167 | } | ||
1168 | |||
1169 | } | ||
1170 | |||
1171 | /* Update finished */ | ||
1172 | wind_update(END_UPDATE); | ||
1173 | |||
1174 | v_show_c(VDI_handle,1); | ||
1175 | } | ||
1176 | |||
1177 | static void refresh_window(_THIS, int winhandle, short *rect) | ||
1178 | { | ||
1179 | MFDB mfdb_src; | ||
1180 | short pxy[8],wind_pxy[8]; | ||
1181 | SDL_Surface *surface; | ||
1182 | int iconified; | ||
1183 | |||
1184 | /* Is window iconified ? */ | ||
1185 | iconified = 0; | ||
1186 | /* if (GEM_wfeatures & (1<<WF_ICONIFY))*/ { | ||
1187 | if (wind_get(winhandle, WF_ICONIFY, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])!=0) { | ||
1188 | iconified = wind_pxy[0]; | ||
1189 | } | ||
1190 | } | ||
1191 | |||
1192 | if (wind_get(winhandle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) { | ||
1193 | return; | ||
1194 | } | ||
1195 | |||
1196 | if (iconified && GEM_icon) { | ||
1197 | short icon_rect[4], dst_rect[4]; | ||
1198 | short iconx,icony; | ||
1199 | |||
1200 | surface = GEM_icon; | ||
1201 | |||
1202 | GEM_ClearRect(this, rect); | ||
1203 | |||
1204 | /* Calculate centered icon(x,y,w,h) relative to window */ | ||
1205 | iconx = (wind_pxy[2]-surface->w)>>1; | ||
1206 | icony = (wind_pxy[3]-surface->h)>>1; | ||
1207 | |||
1208 | icon_rect[0] = iconx; | ||
1209 | icon_rect[1] = icony; | ||
1210 | icon_rect[2] = surface->w; | ||
1211 | icon_rect[3] = surface->h; | ||
1212 | |||
1213 | /* Calculate redraw rectangle(x,y,w,h) relative to window */ | ||
1214 | dst_rect[0] = rect[0]-wind_pxy[0]; | ||
1215 | dst_rect[1] = rect[1]-wind_pxy[1]; | ||
1216 | dst_rect[2] = rect[2]-rect[0]+1; | ||
1217 | dst_rect[3] = rect[3]-rect[1]+1; | ||
1218 | |||
1219 | /* Does the icon rectangle must be redrawn ? */ | ||
1220 | if (!rc_intersect((GRECT *)icon_rect, (GRECT *)dst_rect)) { | ||
1221 | return; | ||
1222 | } | ||
1223 | |||
1224 | #if DEBUG_VIDEO_GEM | ||
1225 | printf("sdl:video:gem: clip(0,0,%d,%d) to (%d,%d,%d,%d)\n", | ||
1226 | surface->w-1,surface->h-1, dst_rect[0],dst_rect[1],dst_rect[2],dst_rect[3]); | ||
1227 | printf("sdl:video:gem: icon(%d,%d,%d,%d)\n", | ||
1228 | icon_rect[0], icon_rect[1], icon_rect[2], icon_rect[3]); | ||
1229 | printf("sdl:video:gem: refresh_window(): draw icon\n"); | ||
1230 | #endif | ||
1231 | |||
1232 | /* Calculate icon(x1,y1,x2,y2) relative to screen */ | ||
1233 | icon_rect[0] += wind_pxy[0]; | ||
1234 | icon_rect[1] += wind_pxy[1]; | ||
1235 | icon_rect[2] += icon_rect[0]-1; | ||
1236 | icon_rect[3] += icon_rect[1]-1; | ||
1237 | |||
1238 | /* Calculate intersection rectangle to redraw */ | ||
1239 | pxy[4]=pxy[0]=MAX(icon_rect[0],rect[0]); | ||
1240 | pxy[5]=pxy[1]=MAX(icon_rect[1],rect[1]); | ||
1241 | pxy[6]=pxy[2]=MIN(icon_rect[2],rect[2]); | ||
1242 | pxy[7]=pxy[3]=MIN(icon_rect[3],rect[3]); | ||
1243 | |||
1244 | /* Calculate icon source image pos relative to window */ | ||
1245 | pxy[0] -= wind_pxy[0]+iconx; | ||
1246 | pxy[1] -= wind_pxy[1]+icony; | ||
1247 | pxy[2] -= wind_pxy[0]+iconx; | ||
1248 | pxy[3] -= wind_pxy[1]+icony; | ||
1249 | |||
1250 | } else { | ||
1251 | surface = this->screen; | ||
1252 | |||
1253 | #if DEBUG_VIDEO_GEM | ||
1254 | printf("sdl:video:gem: refresh_window(): draw frame buffer\n"); | ||
1255 | #endif | ||
1256 | |||
1257 | /* Redraw all window content */ | ||
1258 | pxy[0] = rect[0]-wind_pxy[0]; | ||
1259 | pxy[1] = rect[1]-wind_pxy[1]; | ||
1260 | pxy[2] = rect[2]-wind_pxy[0]; | ||
1261 | pxy[3] = rect[3]-wind_pxy[1]; | ||
1262 | |||
1263 | pxy[4] = rect[0]; | ||
1264 | pxy[5] = rect[1]; | ||
1265 | pxy[6] = rect[2]; | ||
1266 | pxy[7] = rect[3]; | ||
1267 | } | ||
1268 | |||
1269 | if (GEM_bufops & B2S_C2P_1TO2) { | ||
1270 | void *src, *dest; | ||
1271 | int x1,x2; | ||
1272 | |||
1273 | x1 = (rect[0]-wind_pxy[0]) & ~15; | ||
1274 | x2 = rect[2]-wind_pxy[0]; | ||
1275 | if (x2 & 15) { | ||
1276 | x2 = (x2 | 15) +1; | ||
1277 | } | ||
1278 | |||
1279 | src = surface->pixels; | ||
1280 | src += surface->pitch * (rect[1]-wind_pxy[1]); | ||
1281 | src += x1; | ||
1282 | |||
1283 | dest = GEM_buffer2; | ||
1284 | dest += surface->pitch * (rect[1]-wind_pxy[1]); | ||
1285 | dest += x1; | ||
1286 | |||
1287 | SDL_Atari_C2pConvert( | ||
1288 | src, dest, | ||
1289 | x2-x1, rect[3]-rect[1]+1, | ||
1290 | SDL_FALSE, | ||
1291 | surface->pitch, surface->pitch | ||
1292 | ); | ||
1293 | } | ||
1294 | |||
1295 | mfdb_src.fd_addr=surface->pixels; | ||
1296 | { | ||
1297 | int width; | ||
1298 | |||
1299 | /* Need to be a multiple of 16 pixels */ | ||
1300 | width=surface->w; | ||
1301 | if ((width & 15) != 0) { | ||
1302 | width = (width | 15) + 1; | ||
1303 | } | ||
1304 | mfdb_src.fd_w=width; | ||
1305 | } | ||
1306 | mfdb_src.fd_h=surface->h; | ||
1307 | mfdb_src.fd_nplanes=surface->format->BitsPerPixel; | ||
1308 | mfdb_src.fd_wdwidth=mfdb_src.fd_w>>4; | ||
1309 | mfdb_src.fd_stand= | ||
1310 | mfdb_src.fd_r1= | ||
1311 | mfdb_src.fd_r2= | ||
1312 | mfdb_src.fd_r3= 0; | ||
1313 | |||
1314 | if (GEM_bufops & B2S_VROCPYFM_2TOS) { | ||
1315 | mfdb_src.fd_addr=GEM_buffer2; | ||
1316 | } | ||
1317 | |||
1318 | #if DEBUG_VIDEO_GEM | ||
1319 | printf("sdl:video:gem: redraw %dx%d: (%d,%d,%d,%d) to (%d,%d,%d,%d)\n", | ||
1320 | surface->w, surface->h, | ||
1321 | pxy[0],pxy[1],pxy[2],pxy[3], | ||
1322 | pxy[4],pxy[5],pxy[6],pxy[7] | ||
1323 | ); | ||
1324 | #endif | ||
1325 | |||
1326 | vro_cpyfm( VDI_handle, S_ONLY, pxy, &mfdb_src, &VDI_dst_mfdb); | ||
1327 | } | ||
1328 | |||
1329 | #if SDL_VIDEO_OPENGL | ||
1330 | |||
1331 | static void GEM_GL_SwapBuffers(_THIS) | ||
1332 | { | ||
1333 | SDL_AtariGL_SwapBuffers(this); | ||
1334 | GEM_FlipHWSurface(this, this->screen); | ||
1335 | } | ||
1336 | |||
1337 | #endif | ||
diff --git a/apps/plugins/sdl/src/video/gem/SDL_gemvideo.h b/apps/plugins/sdl/src/video/gem/SDL_gemvideo.h deleted file mode 100644 index f3a195453e..0000000000 --- a/apps/plugins/sdl/src/video/gem/SDL_gemvideo.h +++ /dev/null | |||
@@ -1,191 +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_gemvideo_h | ||
25 | #define _SDL_gemvideo_h | ||
26 | |||
27 | #include "SDL_mutex.h" | ||
28 | #include "../SDL_sysvideo.h" | ||
29 | |||
30 | /* The implementation dependent data for the window manager cursor */ | ||
31 | struct WMcursor { | ||
32 | MFORM *mform_p; | ||
33 | }; | ||
34 | |||
35 | /* Hidden "this" pointer for the video functions */ | ||
36 | #define _THIS SDL_VideoDevice *this | ||
37 | |||
38 | /* Functions prototypes */ | ||
39 | void GEM_wind_redraw(_THIS, int winhandle, short *inside); | ||
40 | |||
41 | /* Private display data */ | ||
42 | |||
43 | #define B2S_C2P_1TO2 (1<<0) /* C2P convert buffer 1 to buffer 2 */ | ||
44 | #define B2S_C2P_1TOS (1<<1) /* C2P convert buffer 1 to screen */ | ||
45 | #define B2S_VROCPYFM_1TOS (1<<2) /* vro_cpyfm() buffer 1 to screen */ | ||
46 | #define B2S_VROCPYFM_2TOS (1<<3) /* vro_cpyfm() buffer 2 to screen */ | ||
47 | |||
48 | #define SDL_NUMMODES 1 /* Fullscreen */ | ||
49 | |||
50 | struct SDL_PrivateVideoData { | ||
51 | Uint16 buf2scr_ops; /* Operations to get buffer to screen */ | ||
52 | void *buffer1; /* Our shadow buffers */ | ||
53 | void *buffer2; | ||
54 | |||
55 | /* VDI infos */ | ||
56 | short vdi_handle; /* VDI handle */ | ||
57 | short full_w, full_h; /* Fullscreen size */ | ||
58 | short bpp; /* Colour depth */ | ||
59 | short pixelsize; /* Bytes per pixel */ | ||
60 | short old_numcolors; /* Number of colors in saved palette */ | ||
61 | Uint16 pitch; /* Line length */ | ||
62 | Uint16 format; /* Screen format */ | ||
63 | void *screen; /* Screen address */ | ||
64 | Uint32 red, green, blue, alpha; /* Screen components */ | ||
65 | Uint32 screensize; | ||
66 | short blit_coords[8]; /* Coordinates for bitblt */ | ||
67 | MFDB src_mfdb, dst_mfdb; /* VDI MFDB for bitblt */ | ||
68 | Uint16 old_palette[256][3]; /* Saved current palette */ | ||
69 | Uint16 cur_palette[256][3]; /* SDL application palette */ | ||
70 | /* Function to set/restore palette */ | ||
71 | void (*setpalette)(_THIS, Uint16 newpal[256][3]); | ||
72 | |||
73 | /* GEM infos */ | ||
74 | short desk_x, desk_y; /* Desktop properties */ | ||
75 | short desk_w, desk_h; | ||
76 | short win_handle; /* Our window handle */ | ||
77 | int window_type; /* Window type */ | ||
78 | const char *title_name; /* Window title */ | ||
79 | const char *icon_name; /* Icon title */ | ||
80 | short version; /* AES version */ | ||
81 | short wfeatures; /* AES window features */ | ||
82 | SDL_bool refresh_name; /* Change window title ? */ | ||
83 | SDL_bool window_fulled; /* Window maximized ? */ | ||
84 | SDL_bool mouse_relative; /* Report relative mouse movement */ | ||
85 | SDL_bool locked; /* AES locked for fullscreen ? */ | ||
86 | SDL_bool lock_redraw; /* Prevent redraw till buffers are setup */ | ||
87 | short message[8]; /* To self-send an AES message */ | ||
88 | void *menubar; /* Menu bar save buffer when going fullscreen */ | ||
89 | SDL_bool use_dev_mouse; /* Use /dev/mouse ? */ | ||
90 | WMcursor *cursor; /* To restore cursor when leaving/entering window */ | ||
91 | |||
92 | SDL_bool fullscreen; /* Fullscreen or windowed mode ? */ | ||
93 | SDL_Rect *SDL_modelist[SDL_NUMMODES+1]; /* Mode list */ | ||
94 | SDL_Surface *icon; /* The icon */ | ||
95 | }; | ||
96 | |||
97 | /* Hidden structure -> variables names */ | ||
98 | #define VDI_handle (this->hidden->vdi_handle) | ||
99 | #define VDI_w (this->hidden->full_w) | ||
100 | #define VDI_h (this->hidden->full_h) | ||
101 | #define VDI_bpp (this->hidden->bpp) | ||
102 | #define VDI_pixelsize (this->hidden->pixelsize) | ||
103 | #define VDI_oldnumcolors (this->hidden->old_numcolors) | ||
104 | #define VDI_oldpalette (this->hidden->old_palette) | ||
105 | #define VDI_curpalette (this->hidden->cur_palette) | ||
106 | #define VDI_setpalette (this->hidden->setpalette) | ||
107 | #define VDI_pitch (this->hidden->pitch) | ||
108 | #define VDI_format (this->hidden->format) | ||
109 | #define VDI_screen (this->hidden->screen) | ||
110 | #define VDI_redmask (this->hidden->red) | ||
111 | #define VDI_greenmask (this->hidden->green) | ||
112 | #define VDI_bluemask (this->hidden->blue) | ||
113 | #define VDI_alphamask (this->hidden->alpha) | ||
114 | #define VDI_screensize (this->hidden->screensize) | ||
115 | #define VDI_src_mfdb (this->hidden->src_mfdb) | ||
116 | #define VDI_dst_mfdb (this->hidden->dst_mfdb) | ||
117 | #define VDI_blit_coords (this->hidden->blit_coords) | ||
118 | |||
119 | #define GEM_desk_x (this->hidden->desk_x) | ||
120 | #define GEM_desk_y (this->hidden->desk_y) | ||
121 | #define GEM_desk_w (this->hidden->desk_w) | ||
122 | #define GEM_desk_h (this->hidden->desk_h) | ||
123 | #define GEM_handle (this->hidden->win_handle) | ||
124 | #define GEM_win_type (this->hidden->window_type) | ||
125 | #define GEM_title_name (this->hidden->title_name) | ||
126 | #define GEM_icon_name (this->hidden->icon_name) | ||
127 | #define GEM_refresh_name (this->hidden->refresh_name) | ||
128 | #define GEM_version (this->hidden->version) | ||
129 | #define GEM_wfeatures (this->hidden->wfeatures) | ||
130 | #define GEM_win_fulled (this->hidden->window_fulled) | ||
131 | #define GEM_mouse_relative (this->hidden->mouse_relative) | ||
132 | #define GEM_locked (this->hidden->locked) | ||
133 | #define GEM_lock_redraw (this->hidden->lock_redraw) | ||
134 | #define GEM_message (this->hidden->message) | ||
135 | #define SDL_modelist (this->hidden->SDL_modelist) | ||
136 | #define GEM_icon (this->hidden->icon) | ||
137 | #define GEM_fullscreen (this->hidden->fullscreen) | ||
138 | #define GEM_menubar (this->hidden->menubar) | ||
139 | #define GEM_usedevmouse (this->hidden->use_dev_mouse) | ||
140 | #define GEM_cursor (this->hidden->cursor) | ||
141 | |||
142 | #define GEM_buffer1 (this->hidden->buffer1) | ||
143 | #define GEM_buffer2 (this->hidden->buffer2) | ||
144 | #define GEM_bufops (this->hidden->buf2scr_ops) | ||
145 | |||
146 | #define VDI_FBMASK(amask, rmask, gmask, bmask) \ | ||
147 | VDI_alphamask = (amask); \ | ||
148 | VDI_redmask = (rmask); \ | ||
149 | VDI_greenmask = (gmask); \ | ||
150 | VDI_bluemask = (bmask); | ||
151 | |||
152 | /* | ||
153 | Possible buffer to screen operations: | ||
154 | |||
155 | TC: 8 (chunky),15,16,24,32 bpp | ||
156 | 8I: 8 bpp planes | ||
157 | FB: screen framebuffer address available | ||
158 | FS: fullscreen | ||
159 | |||
160 | TC, FB, FS: | ||
161 | - draw to screen | ||
162 | 8I, FB, FS: | ||
163 | - draw to buffer 1 | ||
164 | - C2P from buffer 1 to screen | ||
165 | |||
166 | TC, !FB, FS: | ||
167 | - draw to buffer 1 | ||
168 | - vro_cpyfm() from buffer 1 to screen | ||
169 | 8I, !FB, FS: | ||
170 | - draw to buffer 1 | ||
171 | - C2P from buffer 1 to buffer 2 | ||
172 | - vro_cpyfm() from buffer 2 to screen | ||
173 | |||
174 | TC, FB, !FS: | ||
175 | - draw to buffer 1 | ||
176 | - vro_cpyfm() from buffer 1 to screen | ||
177 | 8I, FB, !FS: | ||
178 | - draw to buffer 1 | ||
179 | - C2P from buffer 1 to buffer 2 | ||
180 | - vro_cpyfm() from buffer 2 to screen | ||
181 | |||
182 | TC, !FB, !FS: | ||
183 | - draw to buffer 1 | ||
184 | - vro_cpyfm() from buffer 1 to screen | ||
185 | 8I, !FB, !FS: | ||
186 | - draw to buffer 1 | ||
187 | - C2P from buffer 1 to buffer 2 | ||
188 | - vro_cpyfm() from buffer 2 to screen | ||
189 | */ | ||
190 | |||
191 | #endif /* _SDL_gemvideo_h */ | ||
diff --git a/apps/plugins/sdl/src/video/gem/SDL_gemwm.c b/apps/plugins/sdl/src/video/gem/SDL_gemwm.c deleted file mode 100644 index 10776fd2e6..0000000000 --- a/apps/plugins/sdl/src/video/gem/SDL_gemwm.c +++ /dev/null | |||
@@ -1,116 +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 | /* | ||
25 | GEM SDL video driver | ||
26 | Window manager functions | ||
27 | |||
28 | Patrice Mandin | ||
29 | */ | ||
30 | |||
31 | /* Mint includes */ | ||
32 | #include <gem.h> | ||
33 | |||
34 | #include "SDL_gemwm_c.h" | ||
35 | |||
36 | /* Defines */ | ||
37 | |||
38 | #define ICONWIDTH 64 | ||
39 | #define ICONHEIGHT 64 | ||
40 | |||
41 | /* Functions */ | ||
42 | |||
43 | void GEM_SetCaption(_THIS, const char *title, const char *icon) | ||
44 | { | ||
45 | if (title) { | ||
46 | GEM_title_name = title; | ||
47 | GEM_refresh_name = SDL_TRUE; | ||
48 | } | ||
49 | |||
50 | if (icon) { | ||
51 | GEM_icon_name = icon; | ||
52 | GEM_refresh_name = SDL_TRUE; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | void GEM_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) | ||
57 | { | ||
58 | SDL_Surface *sicon; | ||
59 | SDL_Rect bounds; | ||
60 | |||
61 | #if 0 | ||
62 | if ((GEM_wfeatures & (1<<WF_ICONIFY))==0) { | ||
63 | return; | ||
64 | } | ||
65 | #endif | ||
66 | |||
67 | if (icon == NULL) { | ||
68 | return; | ||
69 | } | ||
70 | |||
71 | /* Convert icon to the screen format */ | ||
72 | sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h, | ||
73 | VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, 0); | ||
74 | if ( sicon == NULL ) { | ||
75 | return; | ||
76 | } | ||
77 | |||
78 | bounds.x = 0; | ||
79 | bounds.y = 0; | ||
80 | bounds.w = icon->w; | ||
81 | bounds.h = icon->h; | ||
82 | if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 ) { | ||
83 | SDL_FreeSurface(sicon); | ||
84 | return; | ||
85 | } | ||
86 | |||
87 | GEM_icon = sicon; | ||
88 | } | ||
89 | |||
90 | int GEM_IconifyWindow(_THIS) | ||
91 | { | ||
92 | if ((GEM_wfeatures & (1<<WF_ICONIFY))==0) | ||
93 | return 0; | ||
94 | |||
95 | GEM_message[0] = WM_ICONIFY; | ||
96 | GEM_message[1] = gl_apid; | ||
97 | GEM_message[2] = 0; | ||
98 | GEM_message[3] = GEM_handle; | ||
99 | GEM_message[4] = 0; | ||
100 | GEM_message[5] = GEM_desk_h-ICONHEIGHT; | ||
101 | GEM_message[6] = ICONWIDTH; | ||
102 | GEM_message[7] = ICONHEIGHT; | ||
103 | |||
104 | appl_write(gl_apid, sizeof(GEM_message), GEM_message); | ||
105 | |||
106 | return 1; | ||
107 | } | ||
108 | |||
109 | SDL_GrabMode GEM_GrabInput(_THIS, SDL_GrabMode mode) | ||
110 | { | ||
111 | if (this->screen == NULL) { | ||
112 | return SDL_GRAB_OFF; | ||
113 | } | ||
114 | |||
115 | return mode; | ||
116 | } | ||
diff --git a/apps/plugins/sdl/src/video/gem/SDL_gemwm_c.h b/apps/plugins/sdl/src/video/gem/SDL_gemwm_c.h deleted file mode 100644 index 59828b7eea..0000000000 --- a/apps/plugins/sdl/src/video/gem/SDL_gemwm_c.h +++ /dev/null | |||
@@ -1,37 +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 | /* | ||
25 | * GEM SDL video driver implementation | ||
26 | * Window manager functions | ||
27 | * | ||
28 | * Patrice Mandin | ||
29 | */ | ||
30 | |||
31 | #include "SDL_gemvideo.h" | ||
32 | |||
33 | /* Functions prototypes */ | ||
34 | extern void GEM_SetCaption(_THIS, const char *title, const char *icon); | ||
35 | extern void GEM_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask); | ||
36 | extern int GEM_IconifyWindow(_THIS); | ||
37 | extern SDL_GrabMode GEM_GrabInput(_THIS, SDL_GrabMode mode); | ||