Merge pull request #140 from robxnano/sdl1-fix

Fix building on SDL 1.2
This commit is contained in:
kanjitalk755 2022-09-07 20:21:26 +09:00 committed by GitHub
commit 75cdbd1d7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 87 additions and 40 deletions

View File

@ -361,6 +361,7 @@ void audio_set_speaker_volume(uint32 vol)
{ {
} }
#if SDL_VERSION_ATLEAST(2,0,0)
static int play_startup(void *arg) { static int play_startup(void *arg) {
SDL_AudioSpec wav_spec; SDL_AudioSpec wav_spec;
Uint8 *wav_buffer; Uint8 *wav_buffer;
@ -384,3 +385,8 @@ static int play_startup(void *arg) {
void PlayStartupSound() { void PlayStartupSound() {
SDL_CreateThread(play_startup, "", NULL); SDL_CreateThread(play_startup, "", NULL);
} }
#else
void PlayStartupSound() {
// Not implemented
}
#endif

View File

@ -49,6 +49,7 @@
#include <SDL_thread.h> #include <SDL_thread.h>
#include <errno.h> #include <errno.h>
#include <vector> #include <vector>
#include <string>
#ifdef WIN32 #ifdef WIN32
#include <malloc.h> /* alloca() */ #include <malloc.h> /* alloca() */
@ -365,6 +366,7 @@ public:
virtual void switch_to_current_mode(void); virtual void switch_to_current_mode(void);
virtual void set_palette(uint8 *pal, int num); virtual void set_palette(uint8 *pal, int num);
virtual void set_gamma(uint8 *gamma, int num);
bool video_open(void); bool video_open(void);
void video_close(void); void video_close(void);
@ -520,12 +522,26 @@ static void set_mac_frame_buffer(SDL_monitor_desc &monitor, int depth)
} }
// Set window name and class // Set window name and class
static void set_window_name(int name) static void set_window_name(bool mouse_grabbed)
{ {
const char *title = PrefsFindString("title");
std::string s = title ? title : GetString(STR_WINDOW_TITLE);
int grabbed = 0;
if (mouse_grabbed)
{
s += GetString(STR_WINDOW_TITLE_GRABBED_PRE);
int hotkey = PrefsFindInt32("hotkey");
hotkey = hotkey ? hotkey : 1;
if (hotkey & 1) s += GetString(STR_WINDOW_TITLE_GRABBED1);
if (hotkey & 2) s += GetString(STR_WINDOW_TITLE_GRABBED2);
if (hotkey & 4) s += GetString(STR_WINDOW_TITLE_GRABBED4);
s += GetString(STR_WINDOW_TITLE_GRABBED_POST);
}
const SDL_VideoInfo *vi = SDL_GetVideoInfo(); const SDL_VideoInfo *vi = SDL_GetVideoInfo();
if (vi && vi->wm_available) { if (vi && vi->wm_available)
const char *str = GetString(name); {
SDL_WM_SetCaption(str, str); //The icon name should stay the same
SDL_WM_SetCaption(s.c_str(), GetString(STR_WINDOW_TITLE));
} }
} }
@ -736,7 +752,7 @@ void driver_base::adapt_to_video_mode() {
SDL_ShowCursor(hardware_cursor); SDL_ShowCursor(hardware_cursor);
// Set window name/class // Set window name/class
set_window_name(STR_WINDOW_TITLE); set_window_name(false);
// Everything went well // Everything went well
init_ok = true; init_ok = true;
@ -1304,8 +1320,8 @@ void VideoVBL(void)
// Setting the window name must happen on the main thread, else it doesn't work on // Setting the window name must happen on the main thread, else it doesn't work on
// some platforms - e.g. macOS Sierra. // some platforms - e.g. macOS Sierra.
if (mouse_grabbed_window_name_status != mouse_grabbed) { if (mouse_grabbed_window_name_status != mouse_grabbed) {
set_window_name(mouse_grabbed ? STR_WINDOW_TITLE_GRABBED : STR_WINDOW_TITLE); set_window_name(mouse_grabbed);
mouse_grabbed_window_name_status = mouse_grabbed; mouse_grabbed_window_name_status = mouse_grabbed;
} }
// Temporarily give up frame buffer lock (this is the point where // Temporarily give up frame buffer lock (this is the point where
@ -1333,7 +1349,7 @@ void VideoInterrupt(void)
// Setting the window name must happen on the main thread, else it doesn't work on // Setting the window name must happen on the main thread, else it doesn't work on
// some platforms - e.g. macOS Sierra. // some platforms - e.g. macOS Sierra.
if (mouse_grabbed_window_name_status != mouse_grabbed) { if (mouse_grabbed_window_name_status != mouse_grabbed) {
set_window_name(mouse_grabbed ? STR_WINDOW_TITLE_GRABBED : STR_WINDOW_TITLE); set_window_name(mouse_grabbed);
mouse_grabbed_window_name_status = mouse_grabbed; mouse_grabbed_window_name_status = mouse_grabbed;
} }
@ -1452,6 +1468,10 @@ void SDL_monitor_desc::set_palette(uint8 *pal, int num_in)
UNLOCK_PALETTE; UNLOCK_PALETTE;
} }
void SDL_monitor_desc::set_gamma(uint8 *gamma, int num_in)
{
// Not implemented
}
/* /*
* Switch video mode * Switch video mode
@ -2337,4 +2357,11 @@ void video_set_dirty_area(int x, int y, int w, int h)
} }
#endif #endif
#ifdef SHEEPSHAVER
void video_set_gamma(int n_colors)
{
// Not supported in SDL 1.2
}
#endif
#endif // ends: SDL version check #endif // ends: SDL version check

View File

@ -555,14 +555,15 @@ static void set_window_name() {
if (!sdl_window) return; if (!sdl_window) return;
const char *title = PrefsFindString("title"); const char *title = PrefsFindString("title");
std::string s = title ? title : GetString(STR_WINDOW_TITLE); std::string s = title ? title : GetString(STR_WINDOW_TITLE);
if (mouse_grabbed) { if (mouse_grabbed)
s += GetString(STR_WINDOW_TITLE_GRABBED0); {
s += GetString(STR_WINDOW_TITLE_GRABBED_PRE);
int hotkey = PrefsFindInt32("hotkey"); int hotkey = PrefsFindInt32("hotkey");
if (!hotkey) hotkey = 1; hotkey = hotkey ? hotkey : 1;
if (hotkey & 1) s += GetString(STR_WINDOW_TITLE_GRABBED1); if (hotkey & 1) s += GetString(STR_WINDOW_TITLE_GRABBED1);
if (hotkey & 2) s += GetString(STR_WINDOW_TITLE_GRABBED2); if (hotkey & 2) s += GetString(STR_WINDOW_TITLE_GRABBED2);
if (hotkey & 4) s += GetString(STR_WINDOW_TITLE_GRABBED3); if (hotkey & 4) s += GetString(STR_WINDOW_TITLE_GRABBED4);
s += GetString(STR_WINDOW_TITLE_GRABBED4); s += GetString(STR_WINDOW_TITLE_GRABBED_POST);
} }
SDL_SetWindowTitle(sdl_window, s.c_str()); SDL_SetWindowTitle(sdl_window, s.c_str());
} }
@ -1673,11 +1674,7 @@ static void do_toggle_fullscreen(void)
SDL_SetWindowGrab(sdl_window, SDL_FALSE); SDL_SetWindowGrab(sdl_window, SDL_FALSE);
} else { } else {
display_type = DISPLAY_SCREEN; display_type = DISPLAY_SCREEN;
#ifdef __MACOSX__
SDL_SetWindowFullscreen(sdl_window, SDL_WINDOW_FULLSCREEN_DESKTOP); SDL_SetWindowFullscreen(sdl_window, SDL_WINDOW_FULLSCREEN_DESKTOP);
#else
SDL_SetWindowFullscreen(sdl_window, SDL_WINDOW_FULLSCREEN);
#endif
SDL_SetWindowGrab(sdl_window, SDL_TRUE); SDL_SetWindowGrab(sdl_window, SDL_TRUE);
} }
} }

View File

@ -36,7 +36,7 @@ AC_ARG_ENABLE(sdl-video, [ --enable-sdl-video use SDL for video graphi
AC_ARG_ENABLE(sdl-audio, [ --enable-sdl-audio use SDL for audio [default=no]], [WANT_SDL_AUDIO=$enableval], [WANT_SDL_AUDIO=yes]) AC_ARG_ENABLE(sdl-audio, [ --enable-sdl-audio use SDL for audio [default=no]], [WANT_SDL_AUDIO=$enableval], [WANT_SDL_AUDIO=yes])
AC_ARG_ENABLE(sdl-framework, [ --enable-sdl-framework use SDL framework [default=no]], [WANT_SDL_FRAMEWORK=$enableval], [WANT_SDL_FRAMEWORK=no]) AC_ARG_ENABLE(sdl-framework, [ --enable-sdl-framework use SDL framework [default=no]], [WANT_SDL_FRAMEWORK=$enableval], [WANT_SDL_FRAMEWORK=no])
AC_ARG_ENABLE(sdl-framework-prefix, [ --enable-sdl-framework-prefix=PFX default=/Library/Frameworks], [SDL_FRAMEWORK="$enableval"], [SDL_FRAMEWORK=/Library/Frameworks]) AC_ARG_ENABLE(sdl-framework-prefix, [ --enable-sdl-framework-prefix=PFX default=/Library/Frameworks], [SDL_FRAMEWORK="$enableval"], [SDL_FRAMEWORK=/Library/Frameworks])
#AC_ARG_WITH(sdl1, [ --with-sdl1 use SDL 1.x, rather than SDL 2.x [default=no]], [WANT_SDL_VERSION_MAJOR=1], []) AC_ARG_WITH(sdl1, [ --with-sdl1 use SDL 1.x, rather than SDL 2.x [default=no]], [WANT_SDL_VERSION_MAJOR=1], [])
dnl JIT compiler options. dnl JIT compiler options.
AC_ARG_ENABLE(jit-compiler, [ --enable-jit-compiler enable JIT compiler [default=yes]], [WANT_JIT=$enableval], [WANT_JIT=yes]) AC_ARG_ENABLE(jit-compiler, [ --enable-jit-compiler enable JIT compiler [default=yes]], [WANT_JIT=$enableval], [WANT_JIT=yes])

View File

@ -93,8 +93,11 @@ void EmulOp(uint16 opcode, M68kRegisters *r)
TimerReset(); TimerReset();
EtherReset(); EtherReset();
AudioReset(); AudioReset();
#ifdef ENABLE_SDL
#if SDL_VERSION_ATLEAST(2,0,0)
PlayStartupSound(); PlayStartupSound();
#endif
#endif
// Create BootGlobs at top of memory // Create BootGlobs at top of memory
Mac_memset(RAMBaseMac + RAMSize - 4096, 0, 4096); Mac_memset(RAMBaseMac + RAMSize - 4096, 0, 4096);
uint32 boot_globs = RAMBaseMac + RAMSize - 0x1c; uint32 boot_globs = RAMBaseMac + RAMSize - 0x1c;

View File

@ -218,11 +218,11 @@ enum {
// Mac window // Mac window
STR_WINDOW_TITLE = 4000, STR_WINDOW_TITLE = 4000,
STR_WINDOW_TITLE_GRABBED0, STR_WINDOW_TITLE_GRABBED_PRE,
STR_WINDOW_TITLE_GRABBED1, STR_WINDOW_TITLE_GRABBED1,
STR_WINDOW_TITLE_GRABBED2, STR_WINDOW_TITLE_GRABBED2,
STR_WINDOW_TITLE_GRABBED3,
STR_WINDOW_TITLE_GRABBED4, STR_WINDOW_TITLE_GRABBED4,
STR_WINDOW_TITLE_GRABBED_POST,
STR_WINDOW_MENU = 4050, STR_WINDOW_MENU = 4050,
STR_WINDOW_ITEM_ABOUT, STR_WINDOW_ITEM_ABOUT,
STR_WINDOW_ITEM_REFRESH, STR_WINDOW_ITEM_REFRESH,

View File

@ -231,16 +231,20 @@ user_string_def common_strings[] = {
{STR_JIT_FOLLOW_CONST_JUMPS, "Translate through constant jumps (inline blocks)"}, {STR_JIT_FOLLOW_CONST_JUMPS, "Translate through constant jumps (inline blocks)"},
{STR_WINDOW_TITLE, "Basilisk II"}, {STR_WINDOW_TITLE, "Basilisk II"},
{STR_WINDOW_TITLE_GRABBED0, " (mouse grabbed, press "}, {STR_WINDOW_TITLE_GRABBED_PRE, " (mouse grabbed, press "},
{STR_WINDOW_TITLE_GRABBED1, "Ctrl-"}, {STR_WINDOW_TITLE_GRABBED1, "Ctrl+"},
#ifdef __APPLE__ #ifdef __APPLE__
{STR_WINDOW_TITLE_GRABBED2, "Opt-"}, {STR_WINDOW_TITLE_GRABBED2, "Opt+"},
{STR_WINDOW_TITLE_GRABBED3, "Cmd-"}, {STR_WINDOW_TITLE_GRABBED4, "Cmd+F5"},
#else #else
{STR_WINDOW_TITLE_GRABBED2, "Alt-"}, {STR_WINDOW_TITLE_GRABBED2, "Alt+"},
{STR_WINDOW_TITLE_GRABBED3, "Win-"},
#endif #endif
{STR_WINDOW_TITLE_GRABBED4, "F5 to release)"}, #ifdef __WIN32__
{STR_WINDOW_TITLE_GRABBED4, "Win+"},
#elif !defined(__APPLE__)
{STR_WINDOW_TITLE_GRABBED4, "Super+"},
#endif
{STR_WINDOW_TITLE_GRABBED_POST, "F5 to release)"},
{STR_WINDOW_MENU, "Basilisk II"}, {STR_WINDOW_MENU, "Basilisk II"},
{STR_WINDOW_ITEM_ABOUT, "About Basilisk II" ELLIPSIS}, {STR_WINDOW_ITEM_ABOUT, "About Basilisk II" ELLIPSIS},
{STR_WINDOW_ITEM_REFRESH, "Refresh Rate"}, {STR_WINDOW_ITEM_REFRESH, "Refresh Rate"},

View File

@ -72,7 +72,7 @@ AC_ARG_ENABLE(sdl-video, [ --enable-sdl-video use SDL for video graphic
AC_ARG_ENABLE(sdl-audio, [ --enable-sdl-audio use SDL for audio [default=no]], [WANT_SDL_AUDIO=$enableval], [WANT_SDL_AUDIO=yes]) AC_ARG_ENABLE(sdl-audio, [ --enable-sdl-audio use SDL for audio [default=no]], [WANT_SDL_AUDIO=$enableval], [WANT_SDL_AUDIO=yes])
AC_ARG_ENABLE(sdl-framework, [ --enable-sdl-framework use SDL framework [default=no]], [WANT_SDL_FRAMEWORK=$enableval], [WANT_SDL_FRAMEWORK=no]) AC_ARG_ENABLE(sdl-framework, [ --enable-sdl-framework use SDL framework [default=no]], [WANT_SDL_FRAMEWORK=$enableval], [WANT_SDL_FRAMEWORK=no])
AC_ARG_ENABLE(sdl-framework-prefix, [ --enable-sdl-framework-prefix=PFX default=/Library/Frameworks], [SDL_FRAMEWORK="$enableval"], [SDL_FRAMEWORK=/Library/Frameworks]) AC_ARG_ENABLE(sdl-framework-prefix, [ --enable-sdl-framework-prefix=PFX default=/Library/Frameworks], [SDL_FRAMEWORK="$enableval"], [SDL_FRAMEWORK=/Library/Frameworks])
#AC_ARG_WITH(sdl1, [ --with-sdl1 use SDL 1.x, rather than SDL 2.x [default=no]], [WANT_SDL_VERSION_MAJOR=1], []) AC_ARG_WITH(sdl1, [ --with-sdl1 use SDL 1.x, rather than SDL 2.x [default=no]], [WANT_SDL_VERSION_MAJOR=1], [])
dnl Checks for programs. dnl Checks for programs.
AC_PROG_CC AC_PROG_CC

View File

@ -163,6 +163,9 @@ enum {
STR_IGNORESEGV_CTRL, STR_IGNORESEGV_CTRL,
STR_IDLEWAIT_CTRL, STR_IDLEWAIT_CTRL,
STR_ROM_FILE_CTRL, STR_ROM_FILE_CTRL,
STR_NOGUI_CTRL,
STR_NOGUI_TIP,
STR_NOGUI_TIP2,
// JIT Compiler pane // JIT Compiler pane
STR_JIT_PANE_TITLE = 3700, STR_JIT_PANE_TITLE = 3700,
@ -171,11 +174,11 @@ enum {
// Mac window // Mac window
STR_WINDOW_TITLE = 4000, STR_WINDOW_TITLE = 4000,
STR_WINDOW_TITLE_GRABBED0, STR_WINDOW_TITLE_GRABBED_PRE,
STR_WINDOW_TITLE_GRABBED1, STR_WINDOW_TITLE_GRABBED1,
STR_WINDOW_TITLE_GRABBED2, STR_WINDOW_TITLE_GRABBED2,
STR_WINDOW_TITLE_GRABBED3,
STR_WINDOW_TITLE_GRABBED4, STR_WINDOW_TITLE_GRABBED4,
STR_WINDOW_TITLE_GRABBED_POST,
STR_WINDOW_MENU = 4050, STR_WINDOW_MENU = 4050,
STR_WINDOW_ITEM_ABOUT, STR_WINDOW_ITEM_ABOUT,
STR_WINDOW_ITEM_REFRESH, STR_WINDOW_ITEM_REFRESH,

View File

@ -102,7 +102,7 @@ user_string_def common_strings[] = {
{STR_NOCDROM_CTRL, "Disable CD-ROM Driver"}, {STR_NOCDROM_CTRL, "Disable CD-ROM Driver"},
{STR_ADD_VOLUME_TITLE, "Add Volume"}, {STR_ADD_VOLUME_TITLE, "Add Volume"},
{STR_CREATE_VOLUME_TITLE, "Create Hardfile"}, {STR_CREATE_VOLUME_TITLE, "Create Hardfile"},
{STR_HARDFILE_SIZE_CTRL, "Size (MB)"}, {STR_HARDFILE_SIZE_CTRL, "Size (MiB)"},
{STR_GRAPHICS_SOUND_PANE_TITLE, "Graphics/Sound"}, {STR_GRAPHICS_SOUND_PANE_TITLE, "Graphics/Sound"},
{STR_FRAMESKIP_CTRL, "Window Refresh Rate"}, {STR_FRAMESKIP_CTRL, "Window Refresh Rate"},
@ -171,22 +171,29 @@ user_string_def common_strings[] = {
{STR_IGNORESEGV_CTRL, "Ignore Illegal Memory Accesses"}, {STR_IGNORESEGV_CTRL, "Ignore Illegal Memory Accesses"},
{STR_IDLEWAIT_CTRL, "Don't Use CPU When Idle"}, {STR_IDLEWAIT_CTRL, "Don't Use CPU When Idle"},
{STR_ROM_FILE_CTRL, "ROM File"}, {STR_ROM_FILE_CTRL, "ROM File"},
{STR_NOGUI_CTRL, "Don't show settings window on launch"},
{STR_NOGUI_TIP, "Tip: You can access the settings by right-clicking on the launcher icon." },
{STR_NOGUI_TIP2, "Tip: You can access the settings with the command: SheepShaver --nogui false" },
{STR_JIT_PANE_TITLE, "JIT Compiler"}, {STR_JIT_PANE_TITLE, "JIT Compiler"},
{STR_JIT_CTRL, "Enable JIT Compiler"}, {STR_JIT_CTRL, "Enable JIT Compiler"},
{STR_JIT_68K_CTRL, "Enable built-in 68k DR Emulator (EXPERIMENTAL)"}, {STR_JIT_68K_CTRL, "Enable built-in 68k DR Emulator (EXPERIMENTAL)"},
{STR_WINDOW_TITLE, "SheepShaver"}, {STR_WINDOW_TITLE, "SheepShaver"},
{STR_WINDOW_TITLE_GRABBED0, " (mouse grabbed, press "}, {STR_WINDOW_TITLE_GRABBED_PRE, " (mouse grabbed, press "},
{STR_WINDOW_TITLE_GRABBED1, "Ctrl-"}, {STR_WINDOW_TITLE_GRABBED1, "Ctrl+"},
#ifdef __APPLE__ #ifdef __APPLE__
{STR_WINDOW_TITLE_GRABBED2, "Opt-"}, {STR_WINDOW_TITLE_GRABBED2, "Opt+"},
{STR_WINDOW_TITLE_GRABBED3, "Cmd-"}, {STR_WINDOW_TITLE_GRABBED4, "Cmd+F5"},
#else #else
{STR_WINDOW_TITLE_GRABBED2, "Alt-"}, {STR_WINDOW_TITLE_GRABBED2, "Alt+"},
{STR_WINDOW_TITLE_GRABBED3, "Win-"},
#endif #endif
{STR_WINDOW_TITLE_GRABBED4, "F5 to release)"}, #ifdef __WIN32__
{STR_WINDOW_TITLE_GRABBED4, "Win+"},
#elif !defined(__APPLE__)
{STR_WINDOW_TITLE_GRABBED4, "Super+"},
#endif
{STR_WINDOW_TITLE_GRABBED_POST, "F5 to release)"},
{STR_WINDOW_MENU, "SheepShaver"}, {STR_WINDOW_MENU, "SheepShaver"},
{STR_WINDOW_ITEM_ABOUT, "About SheepShaver" ELLIPSIS}, {STR_WINDOW_ITEM_ABOUT, "About SheepShaver" ELLIPSIS},
{STR_WINDOW_ITEM_REFRESH, "Refresh Rate"}, {STR_WINDOW_ITEM_REFRESH, "Refresh Rate"},