SDL support in SheepShaver too, though it doesn't work in native mode

on Linux/ppc as libSDL is pulling in libpthread which conflicts with
our sheepthreads.
This commit is contained in:
gbeauche 2004-06-24 15:37:26 +00:00
parent 20014c1c7c
commit 0dcb2b4516
6 changed files with 101 additions and 12 deletions

View File

@ -35,8 +35,8 @@ INSTALL_DATA = @INSTALL_DATA@
SRCS = main_unix.cpp ../prefs.cpp ../prefs_items.cpp prefs_unix.cpp sys_unix.cpp \
../rom_patches.cpp ../rsrc_patches.cpp ../emul_op.cpp ../name_registry.cpp \
../macos_util.cpp ../timer.cpp timer_unix.cpp ../xpram.cpp xpram_unix.cpp \
../adb.cpp clip_unix.cpp ../sony.cpp ../disk.cpp ../cdrom.cpp ../scsi.cpp \
../video.cpp video_blit.cpp video_x.cpp ../audio.cpp ../ether.cpp ../thunks.cpp \
../adb.cpp ../sony.cpp ../disk.cpp ../cdrom.cpp ../scsi.cpp \
../video.cpp video_blit.cpp ../audio.cpp ../ether.cpp ../thunks.cpp \
../serial.cpp ../extfs.cpp extfs_unix.cpp \
about_window_unix.cpp ../user_strings.cpp user_strings_unix.cpp \
vm_alloc.cpp sigsegv.cpp \

View File

@ -15,6 +15,7 @@ AC_ARG_ENABLE(ppc-emulator, [ --enable-ppc-emulator use the selected PowerPC
AC_ARG_ENABLE(xf86-dga, [ --enable-xf86-dga use the XFree86 DGA extension [default=yes]], [WANT_XF86_DGA=$enableval], [WANT_XF86_DGA=yes])
AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode extension [default=no]], [WANT_XF86_VIDMODE=$enableval], [WANT_XF86_VIDMODE=no])
AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes])
AC_ARG_ENABLE(sdl-video, [ --enable-sdl-video use SDL for video graphics [default=no]], [WANT_SDL_VIDEO=$enableval], [WANT_SDL_VIDEO=no])
AC_ARG_WITH(esd, [ --with-esd support ESD for sound under Linux/FreeBSD [default=yes]], [WANT_ESD=$withval], [WANT_ESD=yes])
AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]], [WANT_GTK=$withval], [WANT_GTK=yes])
AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes])
@ -86,14 +87,39 @@ fi
dnl Checks for libraries.
AC_CHECK_LIB(posix4, sem_init)
dnl We need X11.
AC_PATH_XTRA
if [[ "x$no_x" = "xyes" ]]; then
AC_MSG_ERROR([You need X11 to run SheepShaver.])
dnl Do we need SDL?
WANT_SDL=no
SDL_SUPPORT="none"
if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
WANT_SDL=yes
WANT_XF86_DGA=no
WANT_XF86_VIDMODE=no
WANT_FBDEV_DGA=no
SDL_SUPPORT="video"
fi
if [[ "x$WANT_SDL" = "xyes" ]]; then
AC_PATH_PROG(sdl_config, "sdl-config")
if [[ -n "$sdl_config" ]]; then
sdl_cflags=`$sdl_config --cflags`
sdl_libs=`$sdl_config --libs`
CFLAGS="$CFLAGS $sdl_cflags"
CXXFLAGS="$CXXFLAGS $sdl_cflags"
LIBS="$LIBS $sdl_libs"
else
WANT_SDL=no
fi
fi
dnl We need X11, if not using SDL.
if [[ "x$WANT_SDL" = "xno" ]]; then
AC_PATH_XTRA
if [[ "x$no_x" = "xyes" ]]; then
AC_MSG_ERROR([You need X11 to run SheepShaver.])
fi
CFLAGS="$CFLAGS $X_CFLAGS"
CXXFLAGS="$CXXFLAGS $X_CFLAGS"
LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS"
fi
CFLAGS="$CFLAGS $X_CFLAGS"
CXXFLAGS="$CXXFLAGS $X_CFLAGS"
LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS"
dnl We need pthreads on non-PowerPC systems. Try libpthread first, then libc_r (FreeBSD), then PTL.
HAVE_PTHREADS=yes
@ -261,7 +287,19 @@ darwin*)
fi
;;
esac
SYSSRCS="$SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS"
dnl SDL overrides
if [[ "x$WANT_SDL" = "xyes" ]]; then
AC_DEFINE(USE_SDL, 1, [Define to enble SDL support])
fi
if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
VIDEOSRCS="../SDL/video_sdl.cpp ../dummy/clip_dummy.cpp"
AC_DEFINE(USE_SDL_VIDEO, 1, [Define to enable SDL video graphics support])
else
VIDEOSRCS="video_x.cpp clip_unix.cpp"
fi
SYSSRCS="$VIDEOSRCS $SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS"
dnl Define a macro that translates a yesno-variable into a C macro definition
dnl to be put into the config.h file
@ -837,6 +875,7 @@ dnl Print summary.
echo
echo SheepShaver configuration summary:
echo
echo SDL support ...................... : $SDL_SUPPORT
echo XFree86 DGA support .............. : $WANT_XF86_DGA
echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
echo Using PowerPC emulator ........... : $EMULATED_PPC

View File

@ -127,7 +127,13 @@
#include "debug.h"
#ifdef USE_SDL
#include <SDL.h>
#endif
#ifndef USE_SDL_VIDEO
#include <X11/Xlib.h>
#endif
#ifdef ENABLE_GTK
#include <gtk/gtk.h>
@ -272,11 +278,13 @@ int64 BusClockSpeed; // Bus clock speed (Hz)
// Global variables
#ifndef USE_SDL_VIDEO
char *x_display_name = NULL; // X11 display name
Display *x_display = NULL; // X11 display handle
#ifdef X11_LOCK_TYPE
X11_LOCK_TYPE x_display_lock = X11_LOCK_INIT; // X11 display lock
#endif
#endif
static int zero_fd = 0; // FD of /dev/zero
static bool lm_area_mapped = false; // Flag: Low Memory area mmap()ped
@ -452,16 +460,35 @@ int main(int argc, char **argv)
for (int i=1; i<argc; i++) {
if (strcmp(argv[i], "--help") == 0) {
usage(argv[0]);
#ifndef USE_SDL_VIDEO
} else if (strcmp(argv[i], "--display") == 0) {
i++;
if (i < argc)
x_display_name = strdup(argv[i]);
#endif
} else if (argv[i][0] == '-') {
fprintf(stderr, "Unrecognized option '%s'\n", argv[i]);
usage(argv[0]);
}
}
#ifdef USE_SDL
// Initialize SDL system
int sdl_flags = 0;
#ifdef USE_SDL_VIDEO
sdl_flags |= SDL_INIT_VIDEO;
#endif
assert(sdl_flags != 0);
if (SDL_Init(sdl_flags) == -1) {
char str[256];
sprintf(str, "Could not initialize SDL: %s.\n", SDL_GetError());
ErrorAlert(str);
goto quit;
}
atexit(SDL_Quit);
#endif
#ifndef USE_SDL_VIDEO
// Open display
x_display = XOpenDisplay(x_display_name);
if (x_display == NULL) {
@ -475,6 +502,7 @@ int main(int argc, char **argv)
// Fork out, so we can return from fullscreen mode when things get ugly
XF86DGAForkApp(DefaultScreen(x_display));
#endif
#endif
#ifdef ENABLE_MON
// Initialize mon
@ -1121,8 +1149,10 @@ static void Quit(void)
#endif
// Close X11 server connection
#ifndef USE_SDL_VIDEO
if (x_display)
XCloseDisplay(x_display);
#endif
exit(0);
}
@ -1567,6 +1597,11 @@ static void sigusr2_handler(int sig, siginfo_t *sip, void *scp)
{
machine_regs *r = MACHINE_REGISTERS(scp);
#ifdef USE_SDL_VIDEO
// We must fill in the events queue in the same thread that did call SDL_SetVideoMode()
SDL_PumpEvents();
#endif
// Do nothing if interrupts are disabled
if (*(int32 *)XLM_IRQ_NEST > 0)
return;
@ -2166,7 +2201,7 @@ void display_alert(int title_id, int prefix_id, int button_id, const char *text)
void ErrorAlert(const char *text)
{
#ifdef ENABLE_GTK
#if defined(ENABLE_GTK) && !defined(USE_SDL_VIDEO)
if (PrefsFindBool("nogui") || x_display == NULL) {
printf(GetString(STR_SHELL_ERROR_PREFIX), text);
return;
@ -2185,7 +2220,7 @@ void ErrorAlert(const char *text)
void WarningAlert(const char *text)
{
#ifdef ENABLE_GTK
#if defined(ENABLE_GTK) && !defined(USE_SDL_VIDEO)
if (PrefsFindBool("nogui") || x_display == NULL) {
printf(GetString(STR_SHELL_WARNING_PREFIX), text);
return;

View File

@ -79,6 +79,9 @@ user_string_def platform_strings[] = {
{STR_SUSPEND_WINDOW_TITLE, "SheepShaver suspended. Press Space to reactivate."},
{STR_VOSF_INIT_ERR, "Cannot initialize Video on SEGV signals."},
{STR_OPEN_WINDOW_ERR, "Cannot open Mac window."},
{STR_WINDOW_TITLE_GRABBED, "SheepShaver (mouse grabbed, press Ctrl-F5 to release)"},
{-1, NULL} // End marker
};

View File

@ -72,6 +72,9 @@ enum {
STR_MOUSEWHEELMODE_PAGE_LAB,
STR_MOUSEWHEELMODE_CURSOR_LAB,
STR_MOUSEWHEELLINES_CTRL,
STR_OPEN_WINDOW_ERR,
STR_WINDOW_TITLE_GRABBED
};
#endif

View File

@ -43,6 +43,10 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef USE_SDL_VIDEO
#include <SDL_events.h>
#endif
#if ENABLE_MON
#include "mon.h"
#include "mon_disass.h"
@ -1059,6 +1063,11 @@ void TriggerInterrupt(void)
void sheepshaver_cpu::handle_interrupt(void)
{
#ifdef USE_SDL_VIDEO
// We must fill in the events queue in the same thread that did call SDL_SetVideoMode()
SDL_PumpEvents();
#endif
// Do nothing if interrupts are disabled
if (int32(ReadMacInt32(XLM_IRQ_NEST)) > 0)
return;