diff options
-rw-r--r-- | apps/plugins/sdl/main.c | 120 | ||||
-rw-r--r-- | apps/plugins/sdl/src/timer/rockbox/SDL_systimer.c | 2 |
2 files changed, 21 insertions, 101 deletions
diff --git a/apps/plugins/sdl/main.c b/apps/plugins/sdl/main.c index f679867a17..384055e660 100644 --- a/apps/plugins/sdl/main.c +++ b/apps/plugins/sdl/main.c | |||
@@ -8,62 +8,13 @@ | |||
8 | #include "SDL.h" | 8 | #include "SDL.h" |
9 | #include "SDL_video.h" | 9 | #include "SDL_video.h" |
10 | 10 | ||
11 | #ifndef COMBINED_SDL | 11 | #ifdef COMBINED_SDL |
12 | extern int my_main(int argc, char *argv[]); | 12 | #error deprecated |
13 | #else | ||
14 | //#if 0 | ||
15 | extern int SDLBlock_main(int argc, char *argv[]); | ||
16 | extern int ballfield_main(int argc, char *argv[]); | ||
17 | extern int parallax3_main(int argc, char *argv[]); | ||
18 | extern int parallax4_main(int argc, char *argv[]); | ||
19 | extern int testbitmap_main(int argc, char *argv[]); | ||
20 | extern int testcursor_main(int argc, char *argv[]); | ||
21 | extern int testhread_main(int argc, char *argv[]); | ||
22 | extern int testplatform_main(int argc, char *argv[]); | ||
23 | extern int testsprite_main(int argc, char *argv[]); | ||
24 | extern int testwin_main(int argc, char *argv[]); | ||
25 | //#endif | ||
26 | extern int abe_main(int argc, char *argv[]); | ||
27 | extern int ballerburg_main(int argc, char **argv); | ||
28 | extern int raytrace_main(int argc, char *argv[]); | ||
29 | extern int wolf3d_main(int argc, char *argv[]); | ||
30 | extern int testsound_main(int argc, char *argv[]); | ||
31 | extern int duke3d_main(int argc,char **argv); | ||
32 | extern int quake_main (int c, char **v); | ||
33 | |||
34 | char *wolf3d_argv[] = { "wolf3d", "--audiobuffer", "2048" }; | ||
35 | char *duke3d_argv[] = { "duke3d" }; | ||
36 | char *quake_argv[] = { "quake", "-basedir", "/.rockbox/quake" }; | ||
37 | |||
38 | struct prog_t { | ||
39 | const char *name; | ||
40 | int (*main)(int argc, char *argv[]); | ||
41 | bool printf_enabled; | ||
42 | int argc; | ||
43 | char **argv; | ||
44 | } programs[] = { | ||
45 | #if 0 | ||
46 | { "Abe's Amazing Adventure", abe_main, true }, | ||
47 | { "Ballerburg", ballerburg_main, false }, | ||
48 | { "Screensaver", SDLBlock_main, false }, | ||
49 | { "Ball Field", ballfield_main, false }, | ||
50 | { "Parallax v.3", parallax3_main, false }, | ||
51 | { "Parallax v.4", parallax4_main, false }, | ||
52 | { "Raytrace", raytrace_main, false }, | ||
53 | { "Test Bitmap", testbitmap_main, false }, | ||
54 | { "Test Cursor", testcursor_main, false }, | ||
55 | { "Test Thread", testhread_main, true }, | ||
56 | { "Test Platform", testplatform_main, true }, | ||
57 | { "Test Sprite", testsprite_main, false }, | ||
58 | { "Test Window", testwin_main, false }, | ||
59 | #endif | ||
60 | { "Duke3D", duke3d_main, true, ARRAYLEN(duke3d_argv), duke3d_argv }, | ||
61 | { "Wolf3D", wolf3d_main, false, ARRAYLEN(wolf3d_argv), wolf3d_argv }, | ||
62 | { "Quake", quake_main, true, ARRAYLEN(quake_argv), quake_argv }, | ||
63 | { "Test sound", testsound_main, true, 0, NULL }, | ||
64 | }; | ||
65 | #endif | 13 | #endif |
66 | 14 | ||
15 | /* SDL program */ | ||
16 | extern int my_main(int argc, char *argv[]); | ||
17 | |||
67 | void *audiobuf = NULL; | 18 | void *audiobuf = NULL; |
68 | 19 | ||
69 | unsigned int sdl_thread_id, main_thread_id; | 20 | unsigned int sdl_thread_id, main_thread_id; |
@@ -72,7 +23,7 @@ bool printf_enabled = true; | |||
72 | 23 | ||
73 | static void (*exit_cb)(void) = NULL; | 24 | static void (*exit_cb)(void) = NULL; |
74 | 25 | ||
75 | /* sets "our" exit handler */ | 26 | /* sets the exit handler presented to the program */ |
76 | void rbsdl_atexit(void (*cb)(void)) | 27 | void rbsdl_atexit(void (*cb)(void)) |
77 | { | 28 | { |
78 | if(exit_cb) | 29 | if(exit_cb) |
@@ -100,6 +51,16 @@ void cleanup(void) | |||
100 | if(exit_cb != SDL_Quit) | 51 | if(exit_cb != SDL_Quit) |
101 | SDL_Quit(); | 52 | SDL_Quit(); |
102 | 53 | ||
54 | #if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE) | ||
55 | #define USE_TIMER | ||
56 | #endif | ||
57 | |||
58 | #ifdef USE_TIMER | ||
59 | /* stop timer callback if there is one, since the memory it | ||
60 | * resides in could be overwritten */ | ||
61 | rb->timer_unregister(); | ||
62 | #endif | ||
63 | |||
103 | if(audiobuf) | 64 | if(audiobuf) |
104 | memset(audiobuf, 0, 4); /* clear */ | 65 | memset(audiobuf, 0, 4); /* clear */ |
105 | 66 | ||
@@ -110,34 +71,7 @@ void cleanup(void) | |||
110 | #endif | 71 | #endif |
111 | } | 72 | } |
112 | 73 | ||
113 | #ifdef COMBINED_SDL | 74 | /* 256KB */ |
114 | const char *formatter(char *buf, size_t n, int i, const char *unit) | ||
115 | { | ||
116 | snprintf(buf, n, "%s", programs[i].name); | ||
117 | return buf; | ||
118 | } | ||
119 | #endif | ||
120 | |||
121 | #ifdef SIMULATOR | ||
122 | #include <signal.h> | ||
123 | |||
124 | void segv(int s, siginfo_t *si, void *ptr) | ||
125 | { | ||
126 | LOGF("SEGV: at address %llx (%d)", si->si_addr, si->si_code); | ||
127 | exit(1); | ||
128 | } | ||
129 | |||
130 | void install_segv(void) | ||
131 | { | ||
132 | struct sigaction act; | ||
133 | act.sa_handler = NULL; | ||
134 | sigemptyset(&act.sa_mask); | ||
135 | act.sa_flags = SA_SIGINFO; | ||
136 | act.sa_sigaction = segv; | ||
137 | sigaction(SIGSEGV, &act, NULL); | ||
138 | } | ||
139 | #endif | ||
140 | |||
141 | static long main_stack[1024 * 1024 / 4]; | 75 | static long main_stack[1024 * 1024 / 4]; |
142 | int (*main_fn)(int argc, char *argv[]); | 76 | int (*main_fn)(int argc, char *argv[]); |
143 | int prog_idx; | 77 | int prog_idx; |
@@ -266,36 +200,22 @@ enum plugin_status plugin_start(const void *param) | |||
266 | return PLUGIN_ERROR; | 200 | return PLUGIN_ERROR; |
267 | } | 201 | } |
268 | 202 | ||
269 | #ifdef SIMULATOR | ||
270 | install_segv(); | ||
271 | #endif | ||
272 | |||
273 | #ifdef COMBINED_SDL | ||
274 | int prog = 0; | ||
275 | |||
276 | rb->set_int("Choose SDL Program", "", UNIT_INT, &prog, NULL, 1, 0, ARRAYLEN(programs) - 1, formatter); | ||
277 | prog_idx = prog; | ||
278 | |||
279 | main_fn = programs[prog].main; | ||
280 | printf_enabled = programs[prog].printf_enabled; | ||
281 | #else | ||
282 | main_fn = my_main; | 203 | main_fn = my_main; |
283 | #endif | ||
284 | 204 | ||
285 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 205 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
286 | rb->cpu_boost(true); | 206 | rb->cpu_boost(true); |
287 | #endif | 207 | #endif |
288 | 208 | ||
289 | backlight_ignore_timeout(); | 209 | backlight_ignore_timeout(); |
290 | /* real exit handler */ | 210 | /* set the real exit handler */ |
291 | #undef rb_atexit | 211 | #undef rb_atexit |
292 | rb_atexit(cleanup); | 212 | rb_atexit(cleanup); |
293 | 213 | ||
294 | /* make a new thread to use a bigger stack */ | 214 | /* make a new thread to use a bigger stack than otherwise accessible */ |
295 | sdl_thread_id = rb->create_thread(main_thread, main_stack, sizeof(main_stack), 0, "sdl_main" IF_PRIO(, PRIORITY_USER_INTERFACE) IF_COP(, CPU)); | 215 | sdl_thread_id = rb->create_thread(main_thread, main_stack, sizeof(main_stack), 0, "sdl_main" IF_PRIO(, PRIORITY_USER_INTERFACE) IF_COP(, CPU)); |
296 | rb->thread_wait(sdl_thread_id); | 216 | rb->thread_wait(sdl_thread_id); |
297 | 217 | ||
298 | rb->sleep(HZ); /* wait a second... */ | 218 | rb->sleep(HZ); /* wait a second in case there's an error message on screen */ |
299 | 219 | ||
300 | return PLUGIN_OK; | 220 | return PLUGIN_OK; |
301 | } | 221 | } |
diff --git a/apps/plugins/sdl/src/timer/rockbox/SDL_systimer.c b/apps/plugins/sdl/src/timer/rockbox/SDL_systimer.c index 5769a87662..f4e886260c 100644 --- a/apps/plugins/sdl/src/timer/rockbox/SDL_systimer.c +++ b/apps/plugins/sdl/src/timer/rockbox/SDL_systimer.c | |||
@@ -114,4 +114,4 @@ void SDL_SYS_StopTimer(void) | |||
114 | return; | 114 | return; |
115 | } | 115 | } |
116 | 116 | ||
117 | #endif /* SDL_TIMER_DUMMY || SDL_TIMERS_DISABLED */ | 117 | #endif |