--- sbbs/src/xpdev/sdlfuncs.c 2018/04/24 16:41:24 1.1.1.1 +++ sbbs/src/xpdev/sdlfuncs.c 2018/04/24 16:45:33 1.1.1.2 @@ -1,8 +1,5 @@ #include /* getenv()/exit()/atexit() */ #include /* NULL */ -#ifdef __unix__ -#include -#endif #include #ifndef main @@ -18,6 +15,12 @@ struct sdlfuncs sdl; #endif +/* Make xp_dl do static linking */ +#ifdef STATIC_SDL +#define STATIC_LINK +#endif +#include + static int sdl_funcs_loaded=0; static int sdl_initialized=0; static int sdl_audio_initialized=0; @@ -30,402 +33,238 @@ SDL_sem *sdl_exit_sem; int XPDEV_main(int argc, char **argv, char **enviro); -#ifdef STATIC_SDL int load_sdl_funcs(struct sdlfuncs *sdlf) { - sdlf->gotfuncs=0; - sdlf->Init=SDL_Init; - sdlf->Quit=SDL_Quit; -#ifdef _WIN32 - sdlf->SetModuleHandle=SDL_SetModuleHandle; -#endif - sdlf->mutexP=SDL_mutexP; - sdlf->mutexV=SDL_mutexV; - sdlf->PeepEvents=SDL_PeepEvents; - sdlf->VideoDriverName=SDL_VideoDriverName; - sdlf->SemWait=SDL_SemWait; - sdlf->SemPost=SDL_SemPost; - sdlf->EventState=SDL_EventState; - sdlf->CreateRGBSurface=SDL_CreateRGBSurface; - sdlf->FillRect=SDL_FillRect; - sdlf->SetColors=SDL_SetColors; - sdlf->BlitSurface=SDL_UpperBlit; - sdlf->UpdateRects=SDL_UpdateRects; - sdlf->SDL_CreateSemaphore=SDL_CreateSemaphore; - sdlf->SDL_DestroySemaphore=SDL_DestroySemaphore; - sdlf->SDL_CreateMutex=SDL_CreateMutex; - sdlf->CreateThread=SDL_CreateThread; - sdlf->KillThread=SDL_KillThread; - sdlf->WaitThread=SDL_WaitThread; - sdlf->WaitEvent=SDL_WaitEvent; - sdlf->SetVideoMode=SDL_SetVideoMode; - sdlf->FreeSurface=SDL_FreeSurface; - sdlf->WM_SetCaption=SDL_WM_SetCaption; - sdlf->ShowCursor=SDL_ShowCursor; - sdlf->WasInit=SDL_WasInit; - sdlf->EnableUNICODE=SDL_EnableUNICODE; - sdlf->EnableKeyRepeat=SDL_EnableKeyRepeat; - sdlf->GetWMInfo=SDL_GetWMInfo; - sdlf->GetError=SDL_GetError; - sdlf->InitSubSystem=SDL_InitSubSystem; - sdlf->QuitSubSystem=SDL_QuitSubSystem; - sdlf->OpenAudio=SDL_OpenAudio; - sdlf->CloseAudio=SDL_CloseAudio; - sdlf->PauseAudio=SDL_PauseAudio; - sdlf->LockAudio=SDL_LockAudio; - sdlf->UnlockAudio=SDL_UnlockAudio; - sdlf->GetAudioStatus=SDL_GetAudioStatus; - sdlf->gotfuncs=1; - sdl_funcs_loaded=1; - return(0); -} -#else - -#if defined(_WIN32) -#include - -int load_sdl_funcs(struct sdlfuncs *sdlf) -{ - HMODULE sdl_dll; + dll_handle sdl_dll; + const char *libnames[]={"SDL", "SDL-1.2", "SDL-1.1", NULL}; + putenv("SDL_VIDEO_ALLOW_SCREENSAVER=1"); sdlf->gotfuncs=0; - if((sdl_dll=LoadLibrary("SDL.dll"))==NULL) - if((sdl_dll=LoadLibrary("SDL-1.2.dll"))==NULL) - if((sdl_dll=LoadLibrary("SDL-1.1.dll"))==NULL) - return(-1); - - if((sdlf->Init=GetProcAddress(sdl_dll, "SDL_Init"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->Quit=GetProcAddress(sdl_dll, "SDL_Quit"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->SetModuleHandle=GetProcAddress(sdl_dll, "SDL_SetModuleHandle"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->mutexP=GetProcAddress(sdl_dll, "SDL_mutexP"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->mutexV=GetProcAddress(sdl_dll, "SDL_mutexV"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->PeepEvents=GetProcAddress(sdl_dll, "SDL_PeepEvents"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->VideoDriverName=GetProcAddress(sdl_dll, "SDL_VideoDriverName"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->SemWait=GetProcAddress(sdl_dll, "SDL_SemWait"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->SemPost=GetProcAddress(sdl_dll, "SDL_SemPost"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->EventState=GetProcAddress(sdl_dll, "SDL_EventState"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->CreateRGBSurface=GetProcAddress(sdl_dll, "SDL_CreateRGBSurface"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->FillRect=GetProcAddress(sdl_dll, "SDL_FillRect"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->SetColors=GetProcAddress(sdl_dll, "SDL_SetColors"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->BlitSurface=GetProcAddress(sdl_dll, "SDL_UpperBlit"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->UpdateRects=GetProcAddress(sdl_dll, "SDL_UpdateRects"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->SDL_CreateSemaphore=GetProcAddress(sdl_dll, "SDL_CreateSemaphore"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->SDL_DestroySemaphore=GetProcAddress(sdl_dll, "SDL_DestroySemaphore"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->SDL_CreateMutex=GetProcAddress(sdl_dll, "SDL_CreateMutex"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->CreateThread=GetProcAddress(sdl_dll, "SDL_CreateThread"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->KillThread=GetProcAddress(sdl_dll, "SDL_KillThread"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->WaitThread=GetProcAddress(sdl_dll, "SDL_WaitThread"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->WaitEvent=GetProcAddress(sdl_dll, "SDL_WaitEvent"))==NULL) { - FreeLibrary(sdl_dll); - return(-1); - } - if((sdlf->SetVideoMode=GetProcAddress(sdl_dll, "SDL_SetVideoMode"))==NULL) { - FreeLibrary(sdl_dll); + if((sdl_dll=xp_dlopen(libnames,RTLD_LAZY|RTLD_GLOBAL,SDL_PATCHLEVEL))==NULL) return(-1); - } - if((sdlf->FreeSurface=GetProcAddress(sdl_dll, "SDL_FreeSurface"))==NULL) { - FreeLibrary(sdl_dll); + +#ifdef _WIN32 + if((sdlf->SetModuleHandle=xp_dlsym(sdl_dll, SDL_SetModuleHandle))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->WM_SetCaption=GetProcAddress(sdl_dll, "SDL_WM_SetCaption"))==NULL) { - FreeLibrary(sdl_dll); +#endif + if((sdlf->Init=xp_dlsym(sdl_dll, SDL_Init))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->ShowCursor=GetProcAddress(sdl_dll, "SDL_ShowCursor"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->Quit=xp_dlsym(sdl_dll, SDL_Quit))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->WasInit=GetProcAddress(sdl_dll, "SDL_WasInit"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->mutexP=xp_dlsym(sdl_dll, SDL_mutexP))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->EnableUNICODE=GetProcAddress(sdl_dll, "SDL_EnableUNICODE"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->mutexV=xp_dlsym(sdl_dll, SDL_mutexV))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->EnableKeyRepeat=GetProcAddress(sdl_dll, "SDL_EnableKeyRepeat"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->PeepEvents=xp_dlsym(sdl_dll, SDL_PeepEvents))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->GetWMInfo=GetProcAddress(sdl_dll, "SDL_GetWMInfo"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->VideoDriverName=xp_dlsym(sdl_dll, SDL_VideoDriverName))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->GetError=GetProcAddress(sdl_dll, "SDL_GetError"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->SemWait=xp_dlsym(sdl_dll, SDL_SemWait))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->InitSubSystem=GetProcAddress(sdl_dll, "SDL_InitSubSystem"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->SemPost=xp_dlsym(sdl_dll, SDL_SemPost))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->QuitSubSystem=GetProcAddress(sdl_dll, "SDL_QuitSubSystem"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->EventState=xp_dlsym(sdl_dll, SDL_EventState))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->OpenAudio=GetProcAddress(sdl_dll, "SDL_OpenAudio"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->CreateRGBSurface=xp_dlsym(sdl_dll, SDL_CreateRGBSurface))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->CloseAudio=GetProcAddress(sdl_dll, "SDL_CloseAudio"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->CreateRGBSurfaceFrom=xp_dlsym(sdl_dll, SDL_CreateRGBSurfaceFrom))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->PauseAudio=GetProcAddress(sdl_dll, "SDL_PauseAudio"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->FillRect=xp_dlsym(sdl_dll, SDL_FillRect))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->LockAudio=GetProcAddress(sdl_dll, "SDL_LockAudio"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->SetColors=xp_dlsym(sdl_dll, SDL_SetColors))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->UnlockAudio=GetProcAddress(sdl_dll, "SDL_UnlockAudio"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->BlitSurface=xp_dlsym(sdl_dll, SDL_UpperBlit))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->GetAudioStatus=GetProcAddress(sdl_dll, "SDL_GetAudioStatus"))==NULL) { - FreeLibrary(sdl_dll); + if((sdlf->UpdateRects=xp_dlsym(sdl_dll, SDL_UpdateRects))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - sdlf->gotfuncs=1; - sdl_funcs_loaded=1; - return(0); -} -#elif defined(__unix__) -#include - -int load_sdl_funcs(struct sdlfuncs *sdlf) -{ - void *sdl_dll; - - sdlf->gotfuncs=0; - if((sdl_dll=dlopen("libSDL.so",RTLD_LAZY|RTLD_GLOBAL))==NULL) - if((sdl_dll=dlopen("libSDL-1.2.so",RTLD_LAZY|RTLD_GLOBAL))==NULL) - if((sdl_dll=dlopen("libSDL-1.1.so",RTLD_LAZY|RTLD_GLOBAL))==NULL) - return(-1); - - if((sdlf->Init=dlsym(sdl_dll, "SDL_Init"))==NULL) { - dlclose(sdl_dll); + if((sdlf->UpdateRect=xp_dlsym(sdl_dll, SDL_UpdateRect))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->Quit=dlsym(sdl_dll, "SDL_Quit"))==NULL) { - dlclose(sdl_dll); + if((sdlf->SDL_CreateSemaphore=xp_dlsym(sdl_dll, SDL_CreateSemaphore))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->mutexP=dlsym(sdl_dll, "SDL_mutexP"))==NULL) { - dlclose(sdl_dll); + if((sdlf->SDL_DestroySemaphore=xp_dlsym(sdl_dll, SDL_DestroySemaphore))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->mutexV=dlsym(sdl_dll, "SDL_mutexV"))==NULL) { - dlclose(sdl_dll); + if((sdlf->SDL_CreateMutex=xp_dlsym(sdl_dll, SDL_CreateMutex))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->PeepEvents=dlsym(sdl_dll, "SDL_PeepEvents"))==NULL) { - dlclose(sdl_dll); + if((sdlf->CreateThread=xp_dlsym(sdl_dll, SDL_CreateThread))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->VideoDriverName=dlsym(sdl_dll, "SDL_VideoDriverName"))==NULL) { - dlclose(sdl_dll); + if((sdlf->KillThread=xp_dlsym(sdl_dll, SDL_KillThread))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->SemWait=dlsym(sdl_dll, "SDL_SemWait"))==NULL) { - dlclose(sdl_dll); + if((sdlf->WaitThread=xp_dlsym(sdl_dll, SDL_WaitThread))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->SemPost=dlsym(sdl_dll, "SDL_SemPost"))==NULL) { - dlclose(sdl_dll); + if((sdlf->WaitEvent=xp_dlsym(sdl_dll, SDL_WaitEvent))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->EventState=dlsym(sdl_dll, "SDL_EventState"))==NULL) { - dlclose(sdl_dll); + if((sdlf->SetVideoMode=xp_dlsym(sdl_dll, SDL_SetVideoMode))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->CreateRGBSurface=dlsym(sdl_dll, "SDL_CreateRGBSurface"))==NULL) { - dlclose(sdl_dll); + if((sdlf->FreeSurface=xp_dlsym(sdl_dll, SDL_FreeSurface))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->FillRect=dlsym(sdl_dll, "SDL_FillRect"))==NULL) { - dlclose(sdl_dll); + if((sdlf->WM_SetCaption=xp_dlsym(sdl_dll, SDL_WM_SetCaption))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->SetColors=dlsym(sdl_dll, "SDL_SetColors"))==NULL) { - dlclose(sdl_dll); + if((sdlf->WM_SetIcon=xp_dlsym(sdl_dll, SDL_WM_SetIcon))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->BlitSurface=dlsym(sdl_dll, "SDL_UpperBlit"))==NULL) { - dlclose(sdl_dll); + if((sdlf->ShowCursor=xp_dlsym(sdl_dll, SDL_ShowCursor))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->UpdateRects=dlsym(sdl_dll, "SDL_UpdateRects"))==NULL) { - dlclose(sdl_dll); + if((sdlf->WasInit=xp_dlsym(sdl_dll, SDL_WasInit))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->SDL_CreateSemaphore=dlsym(sdl_dll, "SDL_CreateSemaphore"))==NULL) { - dlclose(sdl_dll); + if((sdlf->EnableUNICODE=xp_dlsym(sdl_dll, SDL_EnableUNICODE))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->SDL_DestroySemaphore=dlsym(sdl_dll, "SDL_DestroySemaphore"))==NULL) { - dlclose(sdl_dll); + if((sdlf->EnableKeyRepeat=xp_dlsym(sdl_dll, SDL_EnableKeyRepeat))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->SDL_CreateMutex=dlsym(sdl_dll, "SDL_CreateMutex"))==NULL) { - dlclose(sdl_dll); + if((sdlf->GetWMInfo=xp_dlsym(sdl_dll, SDL_GetWMInfo))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->CreateThread=dlsym(sdl_dll, "SDL_CreateThread"))==NULL) { - dlclose(sdl_dll); + if((sdlf->GetError=xp_dlsym(sdl_dll, SDL_GetError))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->KillThread=dlsym(sdl_dll, "SDL_KillThread"))==NULL) { - dlclose(sdl_dll); + if((sdlf->InitSubSystem=xp_dlsym(sdl_dll, SDL_InitSubSystem))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->WaitThread=dlsym(sdl_dll, "SDL_WaitThread"))==NULL) { - dlclose(sdl_dll); + if((sdlf->QuitSubSystem=xp_dlsym(sdl_dll, SDL_QuitSubSystem))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->WaitEvent=dlsym(sdl_dll, "SDL_WaitEvent"))==NULL) { - dlclose(sdl_dll); + if((sdlf->OpenAudio=xp_dlsym(sdl_dll, SDL_OpenAudio))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->SetVideoMode=dlsym(sdl_dll, "SDL_SetVideoMode"))==NULL) { - dlclose(sdl_dll); + if((sdlf->CloseAudio=xp_dlsym(sdl_dll, SDL_CloseAudio))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->FreeSurface=dlsym(sdl_dll, "SDL_FreeSurface"))==NULL) { - dlclose(sdl_dll); + if((sdlf->PauseAudio=xp_dlsym(sdl_dll, SDL_PauseAudio))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->WM_SetCaption=dlsym(sdl_dll, "SDL_WM_SetCaption"))==NULL) { - dlclose(sdl_dll); + if((sdlf->LockAudio=xp_dlsym(sdl_dll, SDL_LockAudio))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->ShowCursor=dlsym(sdl_dll, "SDL_ShowCursor"))==NULL) { - dlclose(sdl_dll); + if((sdlf->UnlockAudio=xp_dlsym(sdl_dll, SDL_UnlockAudio))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->WasInit=dlsym(sdl_dll, "SDL_WasInit"))==NULL) { - dlclose(sdl_dll); + if((sdlf->GetAudioStatus=xp_dlsym(sdl_dll, SDL_GetAudioStatus))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->EnableUNICODE=dlsym(sdl_dll, "SDL_EnableUNICODE"))==NULL) { - dlclose(sdl_dll); + if((sdlf->MapRGB=xp_dlsym(sdl_dll, SDL_MapRGB))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->EnableKeyRepeat=dlsym(sdl_dll, "SDL_EnableKeyRepeat"))==NULL) { - dlclose(sdl_dll); + if((sdlf->LockSurface=xp_dlsym(sdl_dll, SDL_LockSurface))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->GetWMInfo=dlsym(sdl_dll, "SDL_GetWMInfo"))==NULL) { - dlclose(sdl_dll); + if((sdlf->UnlockSurface=xp_dlsym(sdl_dll, SDL_UnlockSurface))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->GetError=dlsym(sdl_dll, "SDL_GetError"))==NULL) { - dlclose(sdl_dll); + if((sdlf->DisplayFormat=xp_dlsym(sdl_dll, SDL_DisplayFormat))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->InitSubSystem=dlsym(sdl_dll, "SDL_InitSubSystem"))==NULL) { - dlclose(sdl_dll); + if((sdlf->Flip=xp_dlsym(sdl_dll, SDL_Flip))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->QuitSubSystem=dlsym(sdl_dll, "SDL_QuitSubSystem"))==NULL) { - dlclose(sdl_dll); + if((sdlf->CreateYUVOverlay=xp_dlsym(sdl_dll, SDL_CreateYUVOverlay))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->OpenAudio=dlsym(sdl_dll, "SDL_OpenAudio"))==NULL) { - dlclose(sdl_dll); + if((sdlf->DisplayYUVOverlay=xp_dlsym(sdl_dll, SDL_DisplayYUVOverlay))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->CloseAudio=dlsym(sdl_dll, "SDL_CloseAudio"))==NULL) { - dlclose(sdl_dll); + if((sdlf->FreeYUVOverlay=xp_dlsym(sdl_dll, SDL_FreeYUVOverlay))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->PauseAudio=dlsym(sdl_dll, "SDL_PauseAudio"))==NULL) { - dlclose(sdl_dll); + if((sdlf->LockYUVOverlay=xp_dlsym(sdl_dll, SDL_LockYUVOverlay))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->LockAudio=dlsym(sdl_dll, "SDL_LockAudio"))==NULL) { - dlclose(sdl_dll); + if((sdlf->UnlockYUVOverlay=xp_dlsym(sdl_dll, SDL_UnlockYUVOverlay))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->UnlockAudio=dlsym(sdl_dll, "SDL_UnlockAudio"))==NULL) { - dlclose(sdl_dll); + if((sdlf->GetVideoInfo=xp_dlsym(sdl_dll, SDL_GetVideoInfo))==NULL) { + xp_dlclose(sdl_dll); return(-1); } - if((sdlf->GetAudioStatus=dlsym(sdl_dll, "SDL_GetAudioStatus"))==NULL) { - dlclose(sdl_dll); + if((sdlf->Linked_Version=xp_dlsym(sdl_dll, SDL_Linked_Version))==NULL) { + xp_dlclose(sdl_dll); return(-1); } sdlf->gotfuncs=1; sdl_funcs_loaded=1; return(0); } -#endif - -#endif int init_sdl_video(void) { @@ -483,13 +322,14 @@ int main(int argc, char **argv, char **e int SDL_main_env(int argc, char **argv, char **env) #endif { - unsigned int i; - SDL_Event ev; char drivername[64]; struct main_args ma; SDL_Thread *main_thread; int main_ret; int use_sdl_video=FALSE; +#ifdef _WIN32 + char *driver_env=NULL; +#endif ma.argc=argc; ma.argv=argv; @@ -504,7 +344,8 @@ int SDL_main_env(int argc, char **argv, #ifdef _WIN32 /* Fail to windib (ie: No mouse attached) */ if(sdl.Init(SDL_INIT_VIDEO)) { - if(getenv("SDL_VIDEODRIVER")==NULL) { + driver_env=getenv("SDL_VIDEODRIVER"); + if(driver_env==NULL || strcmp(driver_env,"windib")) { putenv("SDL_VIDEODRIVER=windib"); WinExec(GetCommandLine(), SW_SHOWDEFAULT); return(0); @@ -525,7 +366,7 @@ int SDL_main_env(int argc, char **argv, * This ugly hack attempts to prevent this... of course, remote X11 * connections must still be allowed. */ - if((!use_sdl_video) || getenv("REMOTEHOST")!=NULL && getenv("DISPLAY")==NULL) { + if((!use_sdl_video) || ((getenv("REMOTEHOST")!=NULL || getenv("SSH_CLIENT")!=NULL) && getenv("DISPLAY")==NULL)) { /* Sure ,we can't use video, but audio is still valid! */ if(sdl.Init(0)==0) sdl_initialized=TRUE; @@ -549,6 +390,13 @@ int SDL_main_env(int argc, char **argv, sdl_video_initialized=FALSE; } else { + const SDL_VideoInfo *initial=sdl.GetVideoInfo(); + + /* Save initial video mode */ + if(initial) + sdl.initial_videoinfo=*initial; + else + memset(&sdl.initial_videoinfo, 0, sizeof(sdl.initial_videoinfo)); sdl_video_initialized=TRUE; } }