diff options
author | Franklin Wei <git@fwei.tk> | 2017-01-21 15:18:31 -0500 |
---|---|---|
committer | Franklin Wei <git@fwei.tk> | 2017-12-23 21:01:26 -0500 |
commit | a855d6202536ff28e5aae4f22a0f31d8f5b325d0 (patch) | |
tree | 8c75f224dd64ed360505afa8843d016b0d75000b /apps/plugins/sdl/src/video/dummy | |
parent | 01c6dcf6c7b9bb1ad2fa0450f99bacc5f3d3e04b (diff) | |
download | rockbox-a855d6202536ff28e5aae4f22a0f31d8f5b325d0.tar.gz rockbox-a855d6202536ff28e5aae4f22a0f31d8f5b325d0.zip |
Port of Duke Nukem 3D
This ports Fabien Sanglard's Chocolate Duke to run on a version of SDL
for Rockbox.
Change-Id: I8f2c4c78af19de10c1633ed7bb7a997b43256dd9
Diffstat (limited to 'apps/plugins/sdl/src/video/dummy')
-rw-r--r-- | apps/plugins/sdl/src/video/dummy/SDL_nullevents.c | 45 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/dummy/SDL_nullevents_c.h | 33 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/dummy/SDL_nullmouse.c | 33 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/dummy/SDL_nullmouse_c.h | 26 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/dummy/SDL_nullvideo.c | 239 | ||||
-rw-r--r-- | apps/plugins/sdl/src/video/dummy/SDL_nullvideo.h | 40 |
6 files changed, 416 insertions, 0 deletions
diff --git a/apps/plugins/sdl/src/video/dummy/SDL_nullevents.c b/apps/plugins/sdl/src/video/dummy/SDL_nullevents.c new file mode 100644 index 0000000000..177fc3f14c --- /dev/null +++ b/apps/plugins/sdl/src/video/dummy/SDL_nullevents.c | |||
@@ -0,0 +1,45 @@ | |||
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 | /* Being a null driver, there's no event stream. We just define stubs for | ||
25 | most of the API. */ | ||
26 | |||
27 | #include "SDL.h" | ||
28 | #include "../../events/SDL_sysevents.h" | ||
29 | #include "../../events/SDL_events_c.h" | ||
30 | |||
31 | #include "SDL_nullvideo.h" | ||
32 | #include "SDL_nullevents_c.h" | ||
33 | |||
34 | void DUMMY_PumpEvents(_THIS) | ||
35 | { | ||
36 | /* do nothing. */ | ||
37 | } | ||
38 | |||
39 | void DUMMY_InitOSKeymap(_THIS) | ||
40 | { | ||
41 | /* do nothing. */ | ||
42 | } | ||
43 | |||
44 | /* end of SDL_nullevents.c ... */ | ||
45 | |||
diff --git a/apps/plugins/sdl/src/video/dummy/SDL_nullevents_c.h b/apps/plugins/sdl/src/video/dummy/SDL_nullevents_c.h new file mode 100644 index 0000000000..3b657945e0 --- /dev/null +++ b/apps/plugins/sdl/src/video/dummy/SDL_nullevents_c.h | |||
@@ -0,0 +1,33 @@ | |||
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_nullvideo.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 DUMMY_InitOSKeymap(_THIS); | ||
30 | extern void DUMMY_PumpEvents(_THIS); | ||
31 | |||
32 | /* end of SDL_nullevents_c.h ... */ | ||
33 | |||
diff --git a/apps/plugins/sdl/src/video/dummy/SDL_nullmouse.c b/apps/plugins/sdl/src/video/dummy/SDL_nullmouse.c new file mode 100644 index 0000000000..47daea8a27 --- /dev/null +++ b/apps/plugins/sdl/src/video/dummy/SDL_nullmouse.c | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | SDL - Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2012 Sam Lantinga | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2.1 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | |||
19 | Sam Lantinga | ||
20 | slouken@libsdl.org | ||
21 | */ | ||
22 | #include "SDL_config.h" | ||
23 | |||
24 | #include "SDL_mouse.h" | ||
25 | #include "../../events/SDL_events_c.h" | ||
26 | |||
27 | #include "SDL_nullmouse_c.h" | ||
28 | |||
29 | |||
30 | /* The implementation dependent data for the window manager cursor */ | ||
31 | struct WMcursor { | ||
32 | int unused; | ||
33 | }; | ||
diff --git a/apps/plugins/sdl/src/video/dummy/SDL_nullmouse_c.h b/apps/plugins/sdl/src/video/dummy/SDL_nullmouse_c.h new file mode 100644 index 0000000000..479eb0e0bb --- /dev/null +++ b/apps/plugins/sdl/src/video/dummy/SDL_nullmouse_c.h | |||
@@ -0,0 +1,26 @@ | |||
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_nullvideo.h" | ||
25 | |||
26 | /* Functions to be exported */ | ||
diff --git a/apps/plugins/sdl/src/video/dummy/SDL_nullvideo.c b/apps/plugins/sdl/src/video/dummy/SDL_nullvideo.c new file mode 100644 index 0000000000..7e096e2f7f --- /dev/null +++ b/apps/plugins/sdl/src/video/dummy/SDL_nullvideo.c | |||
@@ -0,0 +1,239 @@ | |||
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 | /* Dummy SDL video driver implementation; this is just enough to make an | ||
25 | * SDL-based application THINK it's got a working video driver, for | ||
26 | * applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it, | ||
27 | * and also for use as a collection of stubs when porting SDL to a new | ||
28 | * platform for which you haven't yet written a valid video driver. | ||
29 | * | ||
30 | * This is also a great way to determine bottlenecks: if you think that SDL | ||
31 | * is a performance problem for a given platform, enable this driver, and | ||
32 | * then see if your application runs faster without video overhead. | ||
33 | * | ||
34 | * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion | ||
35 | * of this was cut-and-pasted from Stephane Peter's work in the AAlib | ||
36 | * SDL video driver. Renamed to "DUMMY" by Sam Lantinga. | ||
37 | */ | ||
38 | |||
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 | |||
45 | #include "SDL_nullvideo.h" | ||
46 | #include "SDL_nullevents_c.h" | ||
47 | #include "SDL_nullmouse_c.h" | ||
48 | |||
49 | #define DUMMYVID_DRIVER_NAME "dummy" | ||
50 | |||
51 | /* Initialization/Query functions */ | ||
52 | static int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat); | ||
53 | static SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | ||
54 | static SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | ||
55 | static int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); | ||
56 | static void DUMMY_VideoQuit(_THIS); | ||
57 | |||
58 | /* Hardware surface functions */ | ||
59 | static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface); | ||
60 | static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface); | ||
61 | static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface); | ||
62 | static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface); | ||
63 | |||
64 | /* etc. */ | ||
65 | static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects); | ||
66 | |||
67 | /* DUMMY driver bootstrap functions */ | ||
68 | |||
69 | static int DUMMY_Available(void) | ||
70 | { | ||
71 | const char *envr = SDL_getenv("SDL_VIDEODRIVER"); | ||
72 | if ((envr) && (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) { | ||
73 | return(1); | ||
74 | } | ||
75 | |||
76 | return(0); | ||
77 | } | ||
78 | |||
79 | static void DUMMY_DeleteDevice(SDL_VideoDevice *device) | ||
80 | { | ||
81 | SDL_free(device->hidden); | ||
82 | SDL_free(device); | ||
83 | } | ||
84 | |||
85 | static SDL_VideoDevice *DUMMY_CreateDevice(int devindex) | ||
86 | { | ||
87 | SDL_VideoDevice *device; | ||
88 | |||
89 | /* Initialize all variables that we clean on shutdown */ | ||
90 | device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); | ||
91 | if ( device ) { | ||
92 | SDL_memset(device, 0, (sizeof *device)); | ||
93 | device->hidden = (struct SDL_PrivateVideoData *) | ||
94 | SDL_malloc((sizeof *device->hidden)); | ||
95 | } | ||
96 | if ( (device == NULL) || (device->hidden == NULL) ) { | ||
97 | SDL_OutOfMemory(); | ||
98 | if ( device ) { | ||
99 | SDL_free(device); | ||
100 | } | ||
101 | return(0); | ||
102 | } | ||
103 | SDL_memset(device->hidden, 0, (sizeof *device->hidden)); | ||
104 | |||
105 | /* Set the function pointers */ | ||
106 | device->VideoInit = DUMMY_VideoInit; | ||
107 | device->ListModes = DUMMY_ListModes; | ||
108 | device->SetVideoMode = DUMMY_SetVideoMode; | ||
109 | device->CreateYUVOverlay = NULL; | ||
110 | device->SetColors = DUMMY_SetColors; | ||
111 | device->UpdateRects = DUMMY_UpdateRects; | ||
112 | device->VideoQuit = DUMMY_VideoQuit; | ||
113 | device->AllocHWSurface = DUMMY_AllocHWSurface; | ||
114 | device->CheckHWBlit = NULL; | ||
115 | device->FillHWRect = NULL; | ||
116 | device->SetHWColorKey = NULL; | ||
117 | device->SetHWAlpha = NULL; | ||
118 | device->LockHWSurface = DUMMY_LockHWSurface; | ||
119 | device->UnlockHWSurface = DUMMY_UnlockHWSurface; | ||
120 | device->FlipHWSurface = NULL; | ||
121 | device->FreeHWSurface = DUMMY_FreeHWSurface; | ||
122 | device->SetCaption = NULL; | ||
123 | device->SetIcon = NULL; | ||
124 | device->IconifyWindow = NULL; | ||
125 | device->GrabInput = NULL; | ||
126 | device->GetWMInfo = NULL; | ||
127 | device->InitOSKeymap = DUMMY_InitOSKeymap; | ||
128 | device->PumpEvents = DUMMY_PumpEvents; | ||
129 | |||
130 | device->free = DUMMY_DeleteDevice; | ||
131 | |||
132 | return device; | ||
133 | } | ||
134 | |||
135 | VideoBootStrap DUMMY_bootstrap = { | ||
136 | DUMMYVID_DRIVER_NAME, "SDL dummy video driver", | ||
137 | DUMMY_Available, DUMMY_CreateDevice | ||
138 | }; | ||
139 | |||
140 | |||
141 | int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat) | ||
142 | { | ||
143 | /* | ||
144 | fprintf(stderr, "WARNING: You are using the SDL dummy video driver!\n"); | ||
145 | */ | ||
146 | |||
147 | /* Determine the screen depth (use default 8-bit depth) */ | ||
148 | /* we change this during the SDL_SetVideoMode implementation... */ | ||
149 | vformat->BitsPerPixel = 8; | ||
150 | vformat->BytesPerPixel = 1; | ||
151 | |||
152 | /* We're done! */ | ||
153 | return(0); | ||
154 | } | ||
155 | |||
156 | SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | ||
157 | { | ||
158 | return (SDL_Rect **) -1; | ||
159 | } | ||
160 | |||
161 | SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current, | ||
162 | int width, int height, int bpp, Uint32 flags) | ||
163 | { | ||
164 | if ( this->hidden->buffer ) { | ||
165 | SDL_free( this->hidden->buffer ); | ||
166 | } | ||
167 | |||
168 | this->hidden->buffer = SDL_malloc(width * height * (bpp / 8)); | ||
169 | if ( ! this->hidden->buffer ) { | ||
170 | SDL_SetError("Couldn't allocate buffer for requested mode"); | ||
171 | return(NULL); | ||
172 | } | ||
173 | |||
174 | /* printf("Setting mode %dx%d\n", width, height); */ | ||
175 | |||
176 | SDL_memset(this->hidden->buffer, 0, width * height * (bpp / 8)); | ||
177 | |||
178 | /* Allocate the new pixel format for the screen */ | ||
179 | if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) { | ||
180 | SDL_free(this->hidden->buffer); | ||
181 | this->hidden->buffer = NULL; | ||
182 | SDL_SetError("Couldn't allocate new pixel format for requested mode"); | ||
183 | return(NULL); | ||
184 | } | ||
185 | |||
186 | /* Set up the new mode framebuffer */ | ||
187 | current->flags = flags & SDL_FULLSCREEN; | ||
188 | this->hidden->w = current->w = width; | ||
189 | this->hidden->h = current->h = height; | ||
190 | current->pitch = current->w * (bpp / 8); | ||
191 | current->pixels = this->hidden->buffer; | ||
192 | |||
193 | /* We're done */ | ||
194 | return(current); | ||
195 | } | ||
196 | |||
197 | /* We don't actually allow hardware surfaces other than the main one */ | ||
198 | static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface) | ||
199 | { | ||
200 | return(-1); | ||
201 | } | ||
202 | static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface) | ||
203 | { | ||
204 | return; | ||
205 | } | ||
206 | |||
207 | /* We need to wait for vertical retrace on page flipped displays */ | ||
208 | static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface) | ||
209 | { | ||
210 | return(0); | ||
211 | } | ||
212 | |||
213 | static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface) | ||
214 | { | ||
215 | return; | ||
216 | } | ||
217 | |||
218 | static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects) | ||
219 | { | ||
220 | /* do nothing. */ | ||
221 | } | ||
222 | |||
223 | int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | ||
224 | { | ||
225 | /* do nothing of note. */ | ||
226 | return(1); | ||
227 | } | ||
228 | |||
229 | /* Note: If we are terminated, this could be called in the middle of | ||
230 | another SDL video routine -- notably UpdateRects. | ||
231 | */ | ||
232 | void DUMMY_VideoQuit(_THIS) | ||
233 | { | ||
234 | if (this->screen->pixels != NULL) | ||
235 | { | ||
236 | SDL_free(this->screen->pixels); | ||
237 | this->screen->pixels = NULL; | ||
238 | } | ||
239 | } | ||
diff --git a/apps/plugins/sdl/src/video/dummy/SDL_nullvideo.h b/apps/plugins/sdl/src/video/dummy/SDL_nullvideo.h new file mode 100644 index 0000000000..05c19e3441 --- /dev/null +++ b/apps/plugins/sdl/src/video/dummy/SDL_nullvideo.h | |||
@@ -0,0 +1,40 @@ | |||
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_nullvideo_h | ||
25 | #define _SDL_nullvideo_h | ||
26 | |||
27 | #include "../SDL_sysvideo.h" | ||
28 | |||
29 | /* Hidden "this" pointer for the video functions */ | ||
30 | #define _THIS SDL_VideoDevice *this | ||
31 | |||
32 | |||
33 | /* Private display data */ | ||
34 | |||
35 | struct SDL_PrivateVideoData { | ||
36 | int w, h; | ||
37 | void *buffer; | ||
38 | }; | ||
39 | |||
40 | #endif /* _SDL_nullvideo_h */ | ||