127 |
|
#include "debug.h" |
128 |
|
|
129 |
|
|
130 |
+ |
#ifdef USE_SDL |
131 |
+ |
#include <SDL.h> |
132 |
+ |
#endif |
133 |
+ |
|
134 |
+ |
#ifndef USE_SDL_VIDEO |
135 |
|
#include <X11/Xlib.h> |
136 |
+ |
#endif |
137 |
|
|
138 |
|
#ifdef ENABLE_GTK |
139 |
|
#include <gtk/gtk.h> |
278 |
|
|
279 |
|
|
280 |
|
// Global variables |
281 |
+ |
#ifndef USE_SDL_VIDEO |
282 |
|
char *x_display_name = NULL; // X11 display name |
283 |
|
Display *x_display = NULL; // X11 display handle |
284 |
|
#ifdef X11_LOCK_TYPE |
285 |
|
X11_LOCK_TYPE x_display_lock = X11_LOCK_INIT; // X11 display lock |
286 |
|
#endif |
287 |
+ |
#endif |
288 |
|
|
289 |
|
static int zero_fd = 0; // FD of /dev/zero |
290 |
|
static bool lm_area_mapped = false; // Flag: Low Memory area mmap()ped |
460 |
|
for (int i=1; i<argc; i++) { |
461 |
|
if (strcmp(argv[i], "--help") == 0) { |
462 |
|
usage(argv[0]); |
463 |
+ |
#ifndef USE_SDL_VIDEO |
464 |
|
} else if (strcmp(argv[i], "--display") == 0) { |
465 |
|
i++; |
466 |
|
if (i < argc) |
467 |
|
x_display_name = strdup(argv[i]); |
468 |
+ |
#endif |
469 |
|
} else if (argv[i][0] == '-') { |
470 |
|
fprintf(stderr, "Unrecognized option '%s'\n", argv[i]); |
471 |
|
usage(argv[0]); |
472 |
|
} |
473 |
|
} |
474 |
|
|
475 |
+ |
#ifdef USE_SDL |
476 |
+ |
// Initialize SDL system |
477 |
+ |
int sdl_flags = 0; |
478 |
+ |
#ifdef USE_SDL_VIDEO |
479 |
+ |
sdl_flags |= SDL_INIT_VIDEO; |
480 |
+ |
#endif |
481 |
+ |
assert(sdl_flags != 0); |
482 |
+ |
if (SDL_Init(sdl_flags) == -1) { |
483 |
+ |
char str[256]; |
484 |
+ |
sprintf(str, "Could not initialize SDL: %s.\n", SDL_GetError()); |
485 |
+ |
ErrorAlert(str); |
486 |
+ |
goto quit; |
487 |
+ |
} |
488 |
+ |
atexit(SDL_Quit); |
489 |
+ |
#endif |
490 |
+ |
|
491 |
+ |
#ifndef USE_SDL_VIDEO |
492 |
|
// Open display |
493 |
|
x_display = XOpenDisplay(x_display_name); |
494 |
|
if (x_display == NULL) { |
502 |
|
// Fork out, so we can return from fullscreen mode when things get ugly |
503 |
|
XF86DGAForkApp(DefaultScreen(x_display)); |
504 |
|
#endif |
505 |
+ |
#endif |
506 |
|
|
507 |
|
#ifdef ENABLE_MON |
508 |
|
// Initialize mon |
1149 |
|
#endif |
1150 |
|
|
1151 |
|
// Close X11 server connection |
1152 |
+ |
#ifndef USE_SDL_VIDEO |
1153 |
|
if (x_display) |
1154 |
|
XCloseDisplay(x_display); |
1155 |
+ |
#endif |
1156 |
|
|
1157 |
|
exit(0); |
1158 |
|
} |
1597 |
|
{ |
1598 |
|
machine_regs *r = MACHINE_REGISTERS(scp); |
1599 |
|
|
1600 |
+ |
#ifdef USE_SDL_VIDEO |
1601 |
+ |
// We must fill in the events queue in the same thread that did call SDL_SetVideoMode() |
1602 |
+ |
SDL_PumpEvents(); |
1603 |
+ |
#endif |
1604 |
+ |
|
1605 |
|
// Do nothing if interrupts are disabled |
1606 |
|
if (*(int32 *)XLM_IRQ_NEST > 0) |
1607 |
|
return; |
2201 |
|
|
2202 |
|
void ErrorAlert(const char *text) |
2203 |
|
{ |
2204 |
< |
#ifdef ENABLE_GTK |
2204 |
> |
#if defined(ENABLE_GTK) && !defined(USE_SDL_VIDEO) |
2205 |
|
if (PrefsFindBool("nogui") || x_display == NULL) { |
2206 |
|
printf(GetString(STR_SHELL_ERROR_PREFIX), text); |
2207 |
|
return; |
2220 |
|
|
2221 |
|
void WarningAlert(const char *text) |
2222 |
|
{ |
2223 |
< |
#ifdef ENABLE_GTK |
2223 |
> |
#if defined(ENABLE_GTK) && !defined(USE_SDL_VIDEO) |
2224 |
|
if (PrefsFindBool("nogui") || x_display == NULL) { |
2225 |
|
printf(GetString(STR_SHELL_WARNING_PREFIX), text); |
2226 |
|
return; |