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/aalib | |
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/aalib')
-rw-r--r-- | apps/plugins/sdl/src/video/aalib/SDL_aaevents.c | 202 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/aalib/SDL_aaevents_c.h | 35 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/aalib/SDL_aamouse.c | 35 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/aalib/SDL_aamouse_c.h | 26 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/aalib/SDL_aavideo.c | 388 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/aalib/SDL_aavideo.h | 66 |
6 files changed, 0 insertions, 752 deletions
diff --git a/apps/plugins/sdl/src/video/aalib/SDL_aaevents.c b/apps/plugins/sdl/src/video/aalib/SDL_aaevents.c deleted file mode 100644 index a26ab2d0e1..0000000000 --- a/apps/plugins/sdl/src/video/aalib/SDL_aaevents.c +++ /dev/null | |||
@@ -1,202 +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 AA events into SDL events */ | ||
25 | |||
26 | #include <stdio.h> | ||
27 | |||
28 | #include <aalib.h> | ||
29 | |||
30 | #include "SDL.h" | ||
31 | #include "../../events/SDL_sysevents.h" | ||
32 | #include "../../events/SDL_events_c.h" | ||
33 | #include "SDL_aavideo.h" | ||
34 | #include "SDL_aaevents_c.h" | ||
35 | |||
36 | /* The translation tables from a console scancode to a SDL keysym */ | ||
37 | static SDLKey keymap[401]; | ||
38 | |||
39 | static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym); | ||
40 | |||
41 | |||
42 | void AA_PumpEvents(_THIS) | ||
43 | { | ||
44 | int posted = 0; | ||
45 | int mouse_button, mouse_x, mouse_y; | ||
46 | int evt; | ||
47 | SDL_keysym keysym; | ||
48 | |||
49 | static int prev_button = -1, prev_x = -1, prev_y = -1; | ||
50 | |||
51 | if( ! this->screen ) /* Wait till we got the screen initialized */ | ||
52 | return; | ||
53 | |||
54 | do { | ||
55 | posted = 0; | ||
56 | /* Gather events */ | ||
57 | |||
58 | /* Get mouse status */ | ||
59 | SDL_mutexP(AA_mutex); | ||
60 | aa_getmouse (AA_context, &mouse_x, &mouse_y, &mouse_button); | ||
61 | SDL_mutexV(AA_mutex); | ||
62 | mouse_x = mouse_x * this->screen->w / aa_scrwidth (AA_context); | ||
63 | mouse_y = mouse_y * this->screen->h / aa_scrheight (AA_context); | ||
64 | |||
65 | /* Compare against previous state and generate events */ | ||
66 | if( prev_button != mouse_button ) { | ||
67 | if( mouse_button & AA_BUTTON1 ) { | ||
68 | if ( ! (prev_button & AA_BUTTON1) ) { | ||
69 | posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0); | ||
70 | } | ||
71 | } else { | ||
72 | if ( prev_button & AA_BUTTON1 ) { | ||
73 | posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0); | ||
74 | } | ||
75 | } | ||
76 | if( mouse_button & AA_BUTTON2 ) { | ||
77 | if ( ! (prev_button & AA_BUTTON2) ) { | ||
78 | posted += SDL_PrivateMouseButton(SDL_PRESSED, 2, 0, 0); | ||
79 | } | ||
80 | } else { | ||
81 | if ( prev_button & AA_BUTTON2 ) { | ||
82 | posted += SDL_PrivateMouseButton(SDL_RELEASED, 2, 0, 0); | ||
83 | } | ||
84 | } | ||
85 | if( mouse_button & AA_BUTTON3 ) { | ||
86 | if ( ! (prev_button & AA_BUTTON3) ) { | ||
87 | posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0); | ||
88 | } | ||
89 | } else { | ||
90 | if ( prev_button & AA_BUTTON3 ) { | ||
91 | posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | if ( prev_x != mouse_x || prev_y != mouse_y ) { | ||
96 | posted += SDL_PrivateMouseMotion(0, 0, mouse_x, mouse_y); | ||
97 | } | ||
98 | |||
99 | prev_button = mouse_button; | ||
100 | prev_x = mouse_x; prev_y = mouse_y; | ||
101 | |||
102 | /* Get keyboard event */ | ||
103 | SDL_mutexP(AA_mutex); | ||
104 | evt = aa_getevent(AA_context, 0); | ||
105 | SDL_mutexV(AA_mutex); | ||
106 | if ( (evt > AA_NONE) && (evt < AA_RELEASE) && (evt != AA_MOUSE) && (evt != AA_RESIZE) ) { | ||
107 | /* Key pressed */ | ||
108 | /* printf("Key pressed: %d (%c)\n", evt, evt); */ | ||
109 | posted += SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(evt, &keysym)); | ||
110 | } else if ( evt >= AA_RELEASE ) { | ||
111 | /* Key released */ | ||
112 | evt &= ~AA_RELEASE; | ||
113 | /* printf("Key released: %d (%c)\n", evt, evt); */ | ||
114 | posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(evt, &keysym)); | ||
115 | } | ||
116 | } while ( posted ); | ||
117 | } | ||
118 | |||
119 | void AA_InitOSKeymap(_THIS) | ||
120 | { | ||
121 | int i; | ||
122 | static const char *std_keys = " 01234567890&#'()_-|$*+-=/\\:;.,!?<>{}[]@~%^\x9"; | ||
123 | const char *std; | ||
124 | |||
125 | /* Initialize the AAlib key translation table */ | ||
126 | for ( i=0; i<SDL_arraysize(keymap); ++i ) | ||
127 | keymap[i] = SDLK_UNKNOWN; | ||
128 | |||
129 | /* Alphabet keys */ | ||
130 | for ( i = 0; i<26; ++i ){ | ||
131 | keymap['a' + i] = SDLK_a+i; | ||
132 | keymap['A' + i] = SDLK_a+i; | ||
133 | } | ||
134 | /* Function keys */ | ||
135 | for ( i = 0; i<12; ++i ){ | ||
136 | keymap[334 + i] = SDLK_F1+i; | ||
137 | } | ||
138 | /* Keys that have the same symbols and don't have to be translated */ | ||
139 | for( std = std_keys; *std; std ++ ) { | ||
140 | keymap[*std] = *std; | ||
141 | } | ||
142 | |||
143 | keymap[13] = SDLK_RETURN; | ||
144 | keymap[AA_BACKSPACE] = SDLK_BACKSPACE; | ||
145 | |||
146 | keymap[369] = SDLK_LSHIFT; | ||
147 | keymap[370] = SDLK_RSHIFT; | ||
148 | keymap[371] = SDLK_LCTRL; | ||
149 | keymap[372] = SDLK_RCTRL; | ||
150 | keymap[377] = SDLK_LALT; | ||
151 | keymap[270] = SDLK_RALT; | ||
152 | keymap[271] = SDLK_NUMLOCK; | ||
153 | keymap[373] = SDLK_CAPSLOCK; | ||
154 | keymap[164] = SDLK_SCROLLOCK; | ||
155 | |||
156 | keymap[243] = SDLK_INSERT; | ||
157 | keymap[304] = SDLK_DELETE; | ||
158 | keymap[224] = SDLK_HOME; | ||
159 | keymap[231] = SDLK_END; | ||
160 | keymap[229] = SDLK_PAGEUP; | ||
161 | keymap[230] = SDLK_PAGEDOWN; | ||
162 | |||
163 | keymap[241] = SDLK_PRINT; | ||
164 | keymap[163] = SDLK_BREAK; | ||
165 | |||
166 | keymap[302] = SDLK_KP0; | ||
167 | keymap[300] = SDLK_KP1; | ||
168 | keymap[297] = SDLK_KP2; | ||
169 | keymap[299] = SDLK_KP3; | ||
170 | keymap[294] = SDLK_KP4; | ||
171 | keymap[301] = SDLK_KP5; | ||
172 | keymap[296] = SDLK_KP6; | ||
173 | keymap[293] = SDLK_KP7; | ||
174 | keymap[295] = SDLK_KP8; | ||
175 | keymap[298] = SDLK_KP9; | ||
176 | |||
177 | keymap[AA_ESC] = SDLK_ESCAPE; | ||
178 | keymap[AA_UP] = SDLK_UP; | ||
179 | keymap[AA_DOWN] = SDLK_DOWN; | ||
180 | keymap[AA_LEFT] = SDLK_LEFT; | ||
181 | keymap[AA_RIGHT] = SDLK_RIGHT; | ||
182 | } | ||
183 | |||
184 | static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym) | ||
185 | { | ||
186 | /* Sanity check */ | ||
187 | if ( scancode >= SDL_arraysize(keymap) ) | ||
188 | scancode = AA_UNKNOWN; | ||
189 | |||
190 | /* Set the keysym information */ | ||
191 | keysym->scancode = scancode; | ||
192 | keysym->sym = keymap[scancode]; | ||
193 | keysym->mod = KMOD_NONE; | ||
194 | |||
195 | /* If UNICODE is on, get the UNICODE value for the key */ | ||
196 | keysym->unicode = 0; | ||
197 | if ( SDL_TranslateUNICODE ) { | ||
198 | /* Populate the unicode field with the ASCII value */ | ||
199 | keysym->unicode = scancode; | ||
200 | } | ||
201 | return(keysym); | ||
202 | } | ||
diff --git a/apps/plugins/sdl/src/video/aalib/SDL_aaevents_c.h b/apps/plugins/sdl/src/video/aalib/SDL_aaevents_c.h deleted file mode 100644 index 6dbc9f691f..0000000000 --- a/apps/plugins/sdl/src/video/aalib/SDL_aaevents_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_aavideo.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 AA_initkeymaps(int fd); | ||
30 | extern void AA_mousecallback(int button, int dx, int dy, | ||
31 | int u1,int u2,int u3, int u4); | ||
32 | extern void AA_keyboardcallback(int scancode, int pressed); | ||
33 | |||
34 | extern void AA_InitOSKeymap(_THIS); | ||
35 | extern void AA_PumpEvents(_THIS); | ||
diff --git a/apps/plugins/sdl/src/video/aalib/SDL_aamouse.c b/apps/plugins/sdl/src/video/aalib/SDL_aamouse.c deleted file mode 100644 index dc784a56f9..0000000000 --- a/apps/plugins/sdl/src/video/aalib/SDL_aamouse.c +++ /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 <stdio.h> | ||
25 | |||
26 | #include "SDL_mouse.h" | ||
27 | #include "../../events/SDL_events_c.h" | ||
28 | |||
29 | #include "SDL_aamouse_c.h" | ||
30 | |||
31 | |||
32 | /* The implementation dependent data for the window manager cursor */ | ||
33 | struct WMcursor { | ||
34 | int unused; | ||
35 | }; | ||
diff --git a/apps/plugins/sdl/src/video/aalib/SDL_aamouse_c.h b/apps/plugins/sdl/src/video/aalib/SDL_aamouse_c.h deleted file mode 100644 index 6ce3d9863b..0000000000 --- a/apps/plugins/sdl/src/video/aalib/SDL_aamouse_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_aavideo.h" | ||
25 | |||
26 | /* Functions to be exported */ | ||
diff --git a/apps/plugins/sdl/src/video/aalib/SDL_aavideo.c b/apps/plugins/sdl/src/video/aalib/SDL_aavideo.c deleted file mode 100644 index e6d5d3e4ce..0000000000 --- a/apps/plugins/sdl/src/video/aalib/SDL_aavideo.c +++ /dev/null | |||
@@ -1,388 +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 | /* AAlib based SDL video driver implementation. | ||
25 | */ | ||
26 | |||
27 | #include <unistd.h> | ||
28 | #include <sys/stat.h> | ||
29 | |||
30 | |||
31 | #include "SDL_video.h" | ||
32 | #include "SDL_mouse.h" | ||
33 | #include "../SDL_sysvideo.h" | ||
34 | #include "../SDL_pixels_c.h" | ||
35 | #include "../../events/SDL_events_c.h" | ||
36 | |||
37 | #include "SDL_aavideo.h" | ||
38 | #include "SDL_aaevents_c.h" | ||
39 | #include "SDL_aamouse_c.h" | ||
40 | |||
41 | #include <aalib.h> | ||
42 | |||
43 | /* Initialization/Query functions */ | ||
44 | static int AA_VideoInit(_THIS, SDL_PixelFormat *vformat); | ||
45 | static SDL_Rect **AA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | ||
46 | static SDL_Surface *AA_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | ||
47 | static int AA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); | ||
48 | static void AA_VideoQuit(_THIS); | ||
49 | |||
50 | /* Hardware surface functions */ | ||
51 | static int AA_AllocHWSurface(_THIS, SDL_Surface *surface); | ||
52 | static int AA_LockHWSurface(_THIS, SDL_Surface *surface); | ||
53 | static int AA_FlipHWSurface(_THIS, SDL_Surface *surface); | ||
54 | static void AA_UnlockHWSurface(_THIS, SDL_Surface *surface); | ||
55 | static void AA_FreeHWSurface(_THIS, SDL_Surface *surface); | ||
56 | |||
57 | /* Cache the VideoDevice struct */ | ||
58 | static struct SDL_VideoDevice *local_this; | ||
59 | |||
60 | /* AAlib driver bootstrap functions */ | ||
61 | |||
62 | static int AA_Available(void) | ||
63 | { | ||
64 | return 1; /* Always available ! */ | ||
65 | } | ||
66 | |||
67 | static void AA_DeleteDevice(SDL_VideoDevice *device) | ||
68 | { | ||
69 | SDL_free(device->hidden); | ||
70 | SDL_free(device); | ||
71 | } | ||
72 | |||
73 | static SDL_VideoDevice *AA_CreateDevice(int devindex) | ||
74 | { | ||
75 | SDL_VideoDevice *device; | ||
76 | |||
77 | /* Initialize all variables that we clean on shutdown */ | ||
78 | device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); | ||
79 | if ( device ) { | ||
80 | SDL_memset(device, 0, (sizeof *device)); | ||
81 | device->hidden = (struct SDL_PrivateVideoData *) | ||
82 | SDL_malloc((sizeof *device->hidden)); | ||
83 | } | ||
84 | if ( (device == NULL) || (device->hidden == NULL) ) { | ||
85 | SDL_OutOfMemory(); | ||
86 | if ( device ) { | ||
87 | SDL_free(device); | ||
88 | } | ||
89 | return(0); | ||
90 | } | ||
91 | SDL_memset(device->hidden, 0, (sizeof *device->hidden)); | ||
92 | |||
93 | /* Set the function pointers */ | ||
94 | device->VideoInit = AA_VideoInit; | ||
95 | device->ListModes = AA_ListModes; | ||
96 | device->SetVideoMode = AA_SetVideoMode; | ||
97 | device->CreateYUVOverlay = NULL; | ||
98 | device->SetColors = AA_SetColors; | ||
99 | device->UpdateRects = NULL; | ||
100 | device->VideoQuit = AA_VideoQuit; | ||
101 | device->AllocHWSurface = AA_AllocHWSurface; | ||
102 | device->CheckHWBlit = NULL; | ||
103 | device->FillHWRect = NULL; | ||
104 | device->SetHWColorKey = NULL; | ||
105 | device->SetHWAlpha = NULL; | ||
106 | device->LockHWSurface = AA_LockHWSurface; | ||
107 | device->UnlockHWSurface = AA_UnlockHWSurface; | ||
108 | device->FlipHWSurface = NULL; | ||
109 | device->FreeHWSurface = AA_FreeHWSurface; | ||
110 | device->SetCaption = NULL; | ||
111 | device->SetIcon = NULL; | ||
112 | device->IconifyWindow = NULL; | ||
113 | device->GrabInput = NULL; | ||
114 | device->GetWMInfo = NULL; | ||
115 | device->InitOSKeymap = AA_InitOSKeymap; | ||
116 | device->PumpEvents = AA_PumpEvents; | ||
117 | |||
118 | device->free = AA_DeleteDevice; | ||
119 | |||
120 | return device; | ||
121 | } | ||
122 | |||
123 | VideoBootStrap AALIB_bootstrap = { | ||
124 | "aalib", "ASCII Art Library", | ||
125 | AA_Available, AA_CreateDevice | ||
126 | }; | ||
127 | |||
128 | static void AA_ResizeHandler(aa_context *); | ||
129 | |||
130 | int AA_VideoInit(_THIS, SDL_PixelFormat *vformat) | ||
131 | { | ||
132 | int keyboard; | ||
133 | int i; | ||
134 | |||
135 | /* Initialize all variables that we clean on shutdown */ | ||
136 | for ( i=0; i<SDL_NUMMODES; ++i ) { | ||
137 | SDL_modelist[i] = SDL_malloc(sizeof(SDL_Rect)); | ||
138 | SDL_modelist[i]->x = SDL_modelist[i]->y = 0; | ||
139 | } | ||
140 | /* Modes sorted largest to smallest */ | ||
141 | SDL_modelist[0]->w = 1024; SDL_modelist[0]->h = 768; | ||
142 | SDL_modelist[1]->w = 800; SDL_modelist[1]->h = 600; | ||
143 | SDL_modelist[2]->w = 640; SDL_modelist[2]->h = 480; | ||
144 | SDL_modelist[3]->w = 320; SDL_modelist[3]->h = 400; | ||
145 | SDL_modelist[4]->w = 320; SDL_modelist[4]->h = 240; | ||
146 | SDL_modelist[5]->w = 320; SDL_modelist[5]->h = 200; | ||
147 | SDL_modelist[6] = NULL; | ||
148 | |||
149 | /* Initialize the library */ | ||
150 | |||
151 | AA_mutex = SDL_CreateMutex(); | ||
152 | |||
153 | aa_parseoptions (NULL, NULL, NULL, NULL); | ||
154 | |||
155 | AA_context = aa_autoinit(&aa_defparams); | ||
156 | if ( ! AA_context ) { | ||
157 | SDL_SetError("Unable to initialize AAlib"); | ||
158 | return(-1); | ||
159 | } | ||
160 | |||
161 | /* Enable mouse and keyboard support */ | ||
162 | |||
163 | if ( ! aa_autoinitkbd (AA_context, AA_SENDRELEASE) ) { | ||
164 | SDL_SetError("Unable to initialize AAlib keyboard"); | ||
165 | return(-1); | ||
166 | } | ||
167 | if ( ! aa_autoinitmouse (AA_context, AA_SENDRELEASE) ) { | ||
168 | fprintf(stderr,"Warning: Unable to initialize AAlib mouse"); | ||
169 | } | ||
170 | AA_rparams = aa_getrenderparams(); | ||
171 | |||
172 | local_this = this; | ||
173 | |||
174 | aa_resizehandler(AA_context, AA_ResizeHandler); | ||
175 | |||
176 | fprintf(stderr,"Using AAlib driver: %s (%s)\n", AA_context->driver->name, AA_context->driver->shortname); | ||
177 | |||
178 | AA_in_x11 = (SDL_strcmp(AA_context->driver->shortname,"X11") == 0); | ||
179 | /* Determine the screen depth (use default 8-bit depth) */ | ||
180 | vformat->BitsPerPixel = 8; | ||
181 | vformat->BytesPerPixel = 1; | ||
182 | |||
183 | /* We're done! */ | ||
184 | return(0); | ||
185 | } | ||
186 | |||
187 | SDL_Rect **AA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | ||
188 | { | ||
189 | if(format->BitsPerPixel != 8) | ||
190 | return NULL; | ||
191 | |||
192 | if ( flags & SDL_FULLSCREEN ) { | ||
193 | return SDL_modelist; | ||
194 | } else { | ||
195 | return (SDL_Rect **) -1; | ||
196 | } | ||
197 | } | ||
198 | |||
199 | /* From aavga.c | ||
200 | AAlib does not give us the choice of the actual resolution, thus we have to simulate additional | ||
201 | resolution by scaling down manually each frame | ||
202 | */ | ||
203 | static void fastscale (register char *b1, register char *b2, int x1, int x2, int y1, int y2) | ||
204 | { | ||
205 | register int ex, spx = 0, ddx, ddx1; | ||
206 | int ddy1, ddy, spy = 0, ey; | ||
207 | int x; | ||
208 | char *bb1 = b1; | ||
209 | if (!x1 || !x2 || !y1 || !y2) | ||
210 | return; | ||
211 | ddx = x1 + x1; | ||
212 | ddx1 = x2 + x2; | ||
213 | if (ddx1 < ddx) | ||
214 | spx = ddx / ddx1, ddx %= ddx1; | ||
215 | ddy = y1 + y1; | ||
216 | ddy1 = y2 + y2; | ||
217 | if (ddy1 < ddy) | ||
218 | spy = (ddy / ddy1) * x1, ddy %= ddy1; | ||
219 | ey = -ddy1; | ||
220 | for (; y2; y2--) { | ||
221 | ex = -ddx1; | ||
222 | for (x = x2; x; x--) { | ||
223 | *b2 = *b1; | ||
224 | b2++; | ||
225 | b1 += spx; | ||
226 | ex += ddx; | ||
227 | if (ex > 0) { | ||
228 | b1++; | ||
229 | ex -= ddx1; | ||
230 | } | ||
231 | } | ||
232 | bb1 += spy; | ||
233 | ey += ddy; | ||
234 | if (ey > 0) { | ||
235 | bb1 += x1; | ||
236 | ey -= ddy1; | ||
237 | } | ||
238 | b1 = bb1; | ||
239 | } | ||
240 | } | ||
241 | |||
242 | /* Various screen update functions available */ | ||
243 | static void AA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects); | ||
244 | |||
245 | SDL_Surface *AA_SetVideoMode(_THIS, SDL_Surface *current, | ||
246 | int width, int height, int bpp, Uint32 flags) | ||
247 | { | ||
248 | int mode; | ||
249 | |||
250 | if ( AA_buffer ) { | ||
251 | SDL_free( AA_buffer ); | ||
252 | } | ||
253 | |||
254 | AA_buffer = SDL_malloc(width * height); | ||
255 | if ( ! AA_buffer ) { | ||
256 | SDL_SetError("Couldn't allocate buffer for requested mode"); | ||
257 | return(NULL); | ||
258 | } | ||
259 | |||
260 | /* printf("Setting mode %dx%d\n", width, height); */ | ||
261 | |||
262 | SDL_memset(aa_image(AA_context), 0, aa_imgwidth(AA_context) * aa_imgheight(AA_context)); | ||
263 | SDL_memset(AA_buffer, 0, width * height); | ||
264 | |||
265 | /* Allocate the new pixel format for the screen */ | ||
266 | if ( ! SDL_ReallocFormat(current, 8, 0, 0, 0, 0) ) { | ||
267 | return(NULL); | ||
268 | } | ||
269 | |||
270 | /* Set up the new mode framebuffer */ | ||
271 | current->flags = SDL_FULLSCREEN; | ||
272 | AA_w = current->w = width; | ||
273 | AA_h = current->h = height; | ||
274 | current->pitch = current->w; | ||
275 | current->pixels = AA_buffer; | ||
276 | |||
277 | AA_x_ratio = ((double)aa_imgwidth(AA_context)) / ((double)width); | ||
278 | AA_y_ratio = ((double)aa_imgheight(AA_context)) / ((double)height); | ||
279 | |||
280 | /* Set the blit function */ | ||
281 | this->UpdateRects = AA_DirectUpdate; | ||
282 | |||
283 | /* We're done */ | ||
284 | return(current); | ||
285 | } | ||
286 | |||
287 | static void AA_ResizeHandler(aa_context *context) | ||
288 | { | ||
289 | aa_resize(context); | ||
290 | local_this->hidden->x_ratio = ((double)aa_imgwidth(context)) / ((double)local_this->screen->w); | ||
291 | local_this->hidden->y_ratio = ((double)aa_imgheight(context)) / ((double)local_this->screen->h); | ||
292 | |||
293 | fastscale (local_this->hidden->buffer, aa_image(context), local_this->hidden->w, aa_imgwidth (context), local_this->hidden->h, aa_imgheight (context)); | ||
294 | aa_renderpalette(context, local_this->hidden->palette, local_this->hidden->rparams, 0, 0, aa_scrwidth(context), aa_scrheight(context)); | ||
295 | aa_flush(context); | ||
296 | } | ||
297 | |||
298 | /* We don't actually allow hardware surfaces other than the main one */ | ||
299 | static int AA_AllocHWSurface(_THIS, SDL_Surface *surface) | ||
300 | { | ||
301 | return(-1); | ||
302 | } | ||
303 | static void AA_FreeHWSurface(_THIS, SDL_Surface *surface) | ||
304 | { | ||
305 | return; | ||
306 | } | ||
307 | |||
308 | /* We need to wait for vertical retrace on page flipped displays */ | ||
309 | static int AA_LockHWSurface(_THIS, SDL_Surface *surface) | ||
310 | { | ||
311 | /* TODO ? */ | ||
312 | return(0); | ||
313 | } | ||
314 | static void AA_UnlockHWSurface(_THIS, SDL_Surface *surface) | ||
315 | { | ||
316 | return; | ||
317 | } | ||
318 | |||
319 | /* FIXME: How is this done with AAlib? */ | ||
320 | static int AA_FlipHWSurface(_THIS, SDL_Surface *surface) | ||
321 | { | ||
322 | SDL_mutexP(AA_mutex); | ||
323 | aa_flush(AA_context); | ||
324 | SDL_mutexV(AA_mutex); | ||
325 | return(0); | ||
326 | } | ||
327 | |||
328 | static void AA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) | ||
329 | { | ||
330 | int i; | ||
331 | SDL_Rect *rect; | ||
332 | |||
333 | fastscale (AA_buffer, aa_image(AA_context), AA_w, aa_imgwidth (AA_context), AA_h, aa_imgheight (AA_context)); | ||
334 | #if 1 | ||
335 | aa_renderpalette(AA_context, AA_palette, AA_rparams, 0, 0, aa_scrwidth(AA_context), aa_scrheight(AA_context)); | ||
336 | #else | ||
337 | /* Render only the rectangles in the list */ | ||
338 | printf("Update rects : "); | ||
339 | for ( i=0; i < numrects; ++i ) { | ||
340 | rect = &rects[i]; | ||
341 | printf("(%d,%d-%d,%d)", rect->x, rect->y, rect->w, rect->h); | ||
342 | aa_renderpalette(AA_context, AA_palette, AA_rparams, rect->x * AA_x_ratio, rect->y * AA_y_ratio, rect->w * AA_x_ratio, rect->h * AA_y_ratio); | ||
343 | } | ||
344 | printf("\n"); | ||
345 | #endif | ||
346 | SDL_mutexP(AA_mutex); | ||
347 | aa_flush(AA_context); | ||
348 | SDL_mutexV(AA_mutex); | ||
349 | return; | ||
350 | } | ||
351 | |||
352 | int AA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | ||
353 | { | ||
354 | int i; | ||
355 | |||
356 | for ( i=0; i < ncolors; i++ ) { | ||
357 | aa_setpalette(AA_palette, firstcolor + i, | ||
358 | colors[i].r>>2, | ||
359 | colors[i].g>>2, | ||
360 | colors[i].b>>2); | ||
361 | } | ||
362 | return(1); | ||
363 | } | ||
364 | |||
365 | /* Note: If we are terminated, this could be called in the middle of | ||
366 | another SDL video routine -- notably UpdateRects. | ||
367 | */ | ||
368 | void AA_VideoQuit(_THIS) | ||
369 | { | ||
370 | int i; | ||
371 | |||
372 | aa_uninitkbd(AA_context); | ||
373 | aa_uninitmouse(AA_context); | ||
374 | |||
375 | /* Free video mode lists */ | ||
376 | for ( i=0; i<SDL_NUMMODES; ++i ) { | ||
377 | if ( SDL_modelist[i] != NULL ) { | ||
378 | SDL_free(SDL_modelist[i]); | ||
379 | SDL_modelist[i] = NULL; | ||
380 | } | ||
381 | } | ||
382 | |||
383 | aa_close(AA_context); | ||
384 | |||
385 | SDL_DestroyMutex(AA_mutex); | ||
386 | |||
387 | this->screen->pixels = NULL; | ||
388 | } | ||
diff --git a/apps/plugins/sdl/src/video/aalib/SDL_aavideo.h b/apps/plugins/sdl/src/video/aalib/SDL_aavideo.h deleted file mode 100644 index 987edc9768..0000000000 --- a/apps/plugins/sdl/src/video/aalib/SDL_aavideo.h +++ /dev/null | |||
@@ -1,66 +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_aavideo_h | ||
25 | #define _SDL_aavideo_h | ||
26 | |||
27 | #include "SDL_mouse.h" | ||
28 | #include "SDL_mutex.h" | ||
29 | #include "../SDL_sysvideo.h" | ||
30 | |||
31 | #include <aalib.h> | ||
32 | |||
33 | /* Hidden "this" pointer for the video functions */ | ||
34 | #define _THIS SDL_VideoDevice *this | ||
35 | |||
36 | #define SDL_NUMMODES 6 | ||
37 | |||
38 | /* Private display data */ | ||
39 | struct SDL_PrivateVideoData { | ||
40 | SDL_Rect *SDL_modelist[SDL_NUMMODES+1]; | ||
41 | aa_context *context; | ||
42 | aa_palette palette; | ||
43 | aa_renderparams *rparams; | ||
44 | double x_ratio, y_ratio; | ||
45 | int w, h; | ||
46 | SDL_mutex *mutex; | ||
47 | int in_x11; | ||
48 | void *buffer; | ||
49 | }; | ||
50 | |||
51 | /* Old variable names */ | ||
52 | #define SDL_modelist (this->hidden->SDL_modelist) | ||
53 | #define AA_context (this->hidden->context) | ||
54 | #define AA_palette (this->hidden->palette) | ||
55 | #define AA_rparams (this->hidden->rparams) | ||
56 | #define AA_buffer (this->hidden->buffer) | ||
57 | |||
58 | #define AA_x_ratio (this->hidden->x_ratio) | ||
59 | #define AA_y_ratio (this->hidden->y_ratio) | ||
60 | |||
61 | #define AA_mutex (this->hidden->mutex) | ||
62 | #define AA_in_x11 (this->hidden->in_x11) | ||
63 | #define AA_w (this->hidden->w) | ||
64 | #define AA_h (this->hidden->h) | ||
65 | |||
66 | #endif /* _SDL_aavideo_h */ | ||