Try to fix building on SDL 1.2

This commit is contained in:
robxnano 2022-09-03 14:31:30 +01:00
parent befe6d2db0
commit 481b675e1a
7 changed files with 65 additions and 34 deletions

View File

@ -362,6 +362,7 @@ void audio_set_speaker_volume(uint32 vol)
}
static int play_startup(void *arg) {
#if SDL_VERSION_ATLEAST(2,0,0)
SDL_AudioSpec wav_spec;
Uint8 *wav_buffer;
Uint32 wav_length;
@ -378,9 +379,12 @@ static int play_startup(void *arg) {
else printf("play_startup: Audio driver failed to initialize\n");
SDL_FreeWAV(wav_buffer);
}
#endif
return 0;
}
void PlayStartupSound() {
#if SDL_VERSION_ATLEAST(2,0,0)
SDL_CreateThread(play_startup, "", NULL);
#endif
}

View File

@ -520,12 +520,28 @@ static void set_mac_frame_buffer(SDL_monitor_desc &monitor, int depth)
}
// Set window name and class
static void set_window_name(int name)
static void set_window_name(bool mouse_grabbed)
{
int grabbed = 0;
if (mouse_grabbed)
{
int hotkey = PrefsFindInt32("hotkey");
if (hotkey & 2)
grabbed = STR_WINDOW_TITLE_GRABBED2;
else if (hotkey & 4)
grabbed = STR_WINDOW_TITLE_GRABBED3;
else
grabbed = STR_WINDOW_TITLE_GRABBED1;
}
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
if (vi && vi->wm_available) {
const char *str = GetString(name);
SDL_WM_SetCaption(str, str);
if (vi && vi->wm_available)
{
const char *title = PrefsFindString("title");
char *str = (char *)(title ? title : GetString(STR_WINDOW_TITLE));
if(grabbed)
strcat(str, GetString(grabbed));
//The icon name should stay the same
SDL_WM_SetCaption(str, GetString(STR_WINDOW_TITLE));
}
}
@ -736,7 +752,7 @@ void driver_base::adapt_to_video_mode() {
SDL_ShowCursor(hardware_cursor);
// Set window name/class
set_window_name(STR_WINDOW_TITLE);
set_window_name(false);
// Everything went well
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
// some platforms - e.g. macOS Sierra.
if (mouse_grabbed_window_name_status != mouse_grabbed) {
set_window_name(mouse_grabbed ? STR_WINDOW_TITLE_GRABBED : STR_WINDOW_TITLE);
mouse_grabbed_window_name_status = mouse_grabbed;
set_window_name(mouse_grabbed);
mouse_grabbed_window_name_status = mouse_grabbed;
}
// 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
// some platforms - e.g. macOS Sierra.
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;
}
@ -2337,4 +2353,11 @@ void video_set_dirty_area(int x, int y, int w, int h)
}
#endif
#ifdef SHEEPSHAVER
void video_set_gamma(int n_colors)
{
// Not supported in SDL 1.2
}
#endif
#endif // ends: SDL version check

View File

@ -555,14 +555,12 @@ static void set_window_name() {
if (!sdl_window) return;
const char *title = PrefsFindString("title");
std::string s = title ? title : GetString(STR_WINDOW_TITLE);
if (mouse_grabbed) {
s += GetString(STR_WINDOW_TITLE_GRABBED0);
if (mouse_grabbed)
{
int hotkey = PrefsFindInt32("hotkey");
if (!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_GRABBED3);
s += GetString(STR_WINDOW_TITLE_GRABBED4);
if (hotkey & 2) s += GetString(STR_WINDOW_TITLE_GRABBED2);
else if (hotkey & 4) s += GetString(STR_WINDOW_TITLE_GRABBED3);
else s += GetString(STR_WINDOW_TITLE_GRABBED1);
}
SDL_SetWindowTitle(sdl_window, s.c_str());
}

View File

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

View File

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

View File

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

View File

@ -102,7 +102,7 @@ user_string_def common_strings[] = {
{STR_NOCDROM_CTRL, "Disable CD-ROM Driver"},
{STR_ADD_VOLUME_TITLE, "Add Volume"},
{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_FRAMESKIP_CTRL, "Window Refresh Rate"},
@ -171,22 +171,27 @@ user_string_def common_strings[] = {
{STR_IGNORESEGV_CTRL, "Ignore Illegal Memory Accesses"},
{STR_IDLEWAIT_CTRL, "Don't Use CPU When Idle"},
{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_CTRL, "Enable JIT Compiler"},
{STR_JIT_68K_CTRL, "Enable built-in 68k DR Emulator (EXPERIMENTAL)"},
{STR_WINDOW_TITLE, "SheepShaver"},
{STR_WINDOW_TITLE_GRABBED0, " (mouse grabbed, press "},
{STR_WINDOW_TITLE_GRABBED1, "Ctrl-"},
{STR_WINDOW_TITLE_GRABBED1, " (mouse grabbed, press Ctrl+F5 to release)"},
#ifdef __APPLE__
{STR_WINDOW_TITLE_GRABBED2, "Opt-"},
{STR_WINDOW_TITLE_GRABBED3, "Cmd-"},
{STR_WINDOW_TITLE_GRABBED2, " (mouse grabbed, press Opt+F5 to release)"},
{STR_WINDOW_TITLE_GRABBED3, " (mouse grabbed, press Cmd+F5 to release)"},
#else
{STR_WINDOW_TITLE_GRABBED2, "Alt-"},
{STR_WINDOW_TITLE_GRABBED3, "Win-"},
{STR_WINDOW_TITLE_GRABBED2, " (mouse grabbed, press Alt+F5 to release)"},
#endif
#ifdef __WIN32__
{STR_WINDOW_TITLE_GRABBED3, " (mouse grabbed, press Win+F5 to release)"},
#elif !defined(__APPLE__)
{STR_WINDOW_TITLE_GRABBED3, " (mouse grabbed, press Super+F5 to release)"},
#endif
{STR_WINDOW_TITLE_GRABBED4, "F5 to release)"},
{STR_WINDOW_MENU, "SheepShaver"},
{STR_WINDOW_ITEM_ABOUT, "About SheepShaver" ELLIPSIS},
{STR_WINDOW_ITEM_REFRESH, "Refresh Rate"},