diff options
Diffstat (limited to 'apps/plugins/sdl/wrappers.c')
-rw-r--r-- | apps/plugins/sdl/wrappers.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/plugins/sdl/wrappers.c b/apps/plugins/sdl/wrappers.c index 02e9db1992..efa29ea7b8 100644 --- a/apps/plugins/sdl/wrappers.c +++ b/apps/plugins/sdl/wrappers.c | |||
@@ -333,11 +333,24 @@ int fscanf_wrapper(FILE *f, const char *fmt, ...) | |||
333 | return 1; | 333 | return 1; |
334 | } | 334 | } |
335 | 335 | ||
336 | |||
336 | /* stolen from doom */ | 337 | /* stolen from doom */ |
337 | // Here is a hacked up printf command to get the output from the game. | 338 | // Here is a hacked up printf command to get the output from the game. |
338 | int printf_wrapper(const char *fmt, ...) | 339 | int printf_wrapper(const char *fmt, ...) |
339 | { | 340 | { |
340 | static int p_xtpt; | 341 | static volatile struct mutex printf_mutex; |
342 | static volatile int mutex_init = 0; | ||
343 | |||
344 | if(!mutex_init) | ||
345 | { | ||
346 | rb->mutex_init(&printf_mutex); | ||
347 | mutex_init = 1; | ||
348 | } | ||
349 | |||
350 | static volatile int p_xtpt; | ||
351 | |||
352 | rb->mutex_lock(&printf_mutex); | ||
353 | |||
341 | char p_buf[256]; | 354 | char p_buf[256]; |
342 | rb->yield(); | 355 | rb->yield(); |
343 | va_list ap; | 356 | va_list ap; |
@@ -362,6 +375,9 @@ int printf_wrapper(const char *fmt, ...) | |||
362 | rb->lcd_clear_display(); | 375 | rb->lcd_clear_display(); |
363 | } | 376 | } |
364 | } | 377 | } |
378 | |||
379 | rb->mutex_unlock(&printf_mutex); | ||
380 | |||
365 | return 1; | 381 | return 1; |
366 | } | 382 | } |
367 | 383 | ||