Commit 0294a141 authored by deuce's avatar deuce
Browse files

More SDL2 fixes...

Remove CIOLIB_MODE_SDL_YUV* macros, these modes have no point anymore
Fix SDL prototypes

Use _beginthread() instead of SDL_CreateThread().  For some reason, using
CreateThread() sometimes caused an application crash (ie: when using -?)
Everyhing else uses _beginthread() so there's no reason for this to be
special, especially when it breaks stuff.
parent 15c7bb60
......@@ -425,8 +425,6 @@ CIOLIBEXPORT int CIOLIBCALL initciolib(int mode)
#if defined(WITH_SDL) || defined(WITH_SDL_AUDIO)
case CIOLIB_MODE_SDL:
case CIOLIB_MODE_SDL_FULLSCREEN:
case CIOLIB_MODE_SDL_YUV:
case CIOLIB_MODE_SDL_YUV_FULLSCREEN:
try_sdl_init(mode);
break;
#endif
......
......@@ -79,8 +79,6 @@ enum {
,CIOLIB_MODE_CONIO_FULLSCREEN
,CIOLIB_MODE_SDL
,CIOLIB_MODE_SDL_FULLSCREEN
,CIOLIB_MODE_SDL_YUV
,CIOLIB_MODE_SDL_YUV_FULLSCREEN
};
#if defined(_WIN32) /* presumably, Win32 */
......
......@@ -56,7 +56,6 @@ int copy_needs_events;
SDL_sem *sdl_pastebuf_set;
SDL_sem *sdl_pastebuf_copied;
SDL_mutex *sdl_copybuf_mutex;
static SDL_Thread *mouse_thread;
char *sdl_copybuf=NULL;
char *sdl_pastebuf=NULL;
......@@ -227,7 +226,7 @@ struct x11 {
struct x11 sdl_x11;
#endif
static int sdl_video_event_thread(void *data);
static void sdl_video_event_thread(void *data);
static void sdl_user_func(int func, ...)
{
......@@ -274,7 +273,7 @@ static void sdl_user_func(int func, ...)
return;
}
va_end(argptr);
while((rv = sdl.PeepEvents(&ev, 1, SDL_ADDEVENT, 0xffffffff))!=1)
while((rv = sdl.PeepEvents(&ev, 1, SDL_ADDEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT))!=1)
YIELD();
if (func != SDL_USEREVENT_FLUSH) {
if(sdl_x11available && sdl_using_x11)
......@@ -307,7 +306,7 @@ static int sdl_user_func_ret(int func, ...)
case SDL_USEREVENT_SETVIDMODE:
case SDL_USEREVENT_INIT:
case SDL_USEREVENT_QUIT:
while(sdl.PeepEvents(&ev, 1, SDL_ADDEVENT, 0xffffffff)!=1)
while(sdl.PeepEvents(&ev, 1, SDL_ADDEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)!=1)
YIELD();
break;
default:
......@@ -502,7 +501,7 @@ int sdl_init(int mode)
if(mode==CIOLIB_MODE_SDL_FULLSCREEN)
fullscreen=1;
// Needs to be *after* bitmap_drv_init()
sdl.CreateThread(sdl_video_event_thread, NULL);
_beginthread(sdl_video_event_thread, 0, NULL);
sdl_user_func_ret(SDL_USEREVENT_INIT);
sdl_init_mode(3);
......@@ -701,7 +700,7 @@ static void setup_surfaces(void)
else if(sdl_init_good) {
ev.type=SDL_QUIT;
sdl_exitcode=1;
sdl.PeepEvents(&ev, 1, SDL_ADDEVENT, 0xffffffff);
sdl.PeepEvents(&ev, 1, SDL_ADDEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
}
sdl.mutexV(win_mutex);
}
......@@ -1173,14 +1172,13 @@ static unsigned int sdl_get_char_code(unsigned int keysym, unsigned int mod)
}
/* Mouse event/keyboard thread */
static int sdl_mouse_thread(void *data)
static void sdl_mouse_thread(void *data)
{
SetThreadName("SDL Mouse");
while(1) {
if(mouse_wait())
sdl_add_key(CIO_KEY_MOUSE);
}
return 0;
}
static int win_to_text_xpos(int winpos)
......@@ -1199,7 +1197,7 @@ static int win_to_text_ypos(int winpos)
return ret;
}
static int sdl_video_event_thread(void *data)
static void sdl_video_event_thread(void *data)
{
SDL_Event ev;
int new_scaling = -1;
......@@ -1329,7 +1327,7 @@ static int sdl_video_event_thread(void *data)
case SDL_USEREVENT_QUIT:
sdl_ufunc_retval=0;
sdl.SemPost(sdl_ufunc_ret);
return(0);
return;
case SDL_USEREVENT_FLUSH:
sdl.mutexP(win_mutex);
if (win != NULL) {
......@@ -1396,7 +1394,7 @@ static int sdl_video_event_thread(void *data)
if(!sdl_init_good) {
if(sdl.WasInit(SDL_INIT_VIDEO)==SDL_INIT_VIDEO) {
sdl.mutexP(win_mutex);
mouse_thread=sdl.CreateThread(sdl_mouse_thread, NULL);
_beginthread(sdl_mouse_thread, 0, NULL);
sdl_init_good=1;
sdl.mutexV(win_mutex);
}
......@@ -1563,7 +1561,7 @@ static int sdl_video_event_thread(void *data)
}
}
}
return(0);
return;
}
int sdl_initciolib(int mode)
......
......@@ -35,7 +35,6 @@ char *sdl_getcliptext(void);
int sdl_setfont(int font, int force);
int sdl_getfont(void);
int sdl_loadfont(char *filename);
int sdl_video_event_thread(void *data);
int sdl_get_window_info(int *width, int *height, int *xpos, int *ypos);
int sdl_setpalette(uint32_t index, uint16_t r, uint16_t g, uint16_t b);
#ifdef __cplusplus
......
......@@ -72,22 +72,10 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->CreateRGBSurface=xp_dlsym(sdl_dll, SDL_CreateRGBSurface))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->CreateRGBSurfaceFrom=xp_dlsym(sdl_dll, SDL_CreateRGBSurfaceFrom))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->FillRect=xp_dlsym(sdl_dll, SDL_FillRect))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->BlitSurface=xp_dlsym(sdl_dll, SDL_UpperBlit))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->RenderPresent=xp_dlsym(sdl_dll, SDL_RenderPresent))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
......@@ -104,34 +92,14 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->CreateThread=xp_dlsym(sdl_dll, SDL_CreateThread))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->WaitThread=xp_dlsym(sdl_dll, SDL_WaitThread))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->WaitEventTimeout=xp_dlsym(sdl_dll, SDL_WaitEventTimeout))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->PollEvent=xp_dlsym(sdl_dll, SDL_PollEvent))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->CreateWindow=xp_dlsym(sdl_dll, SDL_CreateWindow))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->CreateWindowAndRenderer=xp_dlsym(sdl_dll, SDL_CreateWindowAndRenderer))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->CreateRenderer=xp_dlsym(sdl_dll, SDL_CreateRenderer))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->FreeSurface=xp_dlsym(sdl_dll, SDL_FreeSurface))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
......@@ -144,10 +112,6 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->GetWindowSurface=xp_dlsym(sdl_dll, SDL_GetWindowSurface))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->SetWindowIcon=xp_dlsym(sdl_dll, SDL_SetWindowIcon))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
......@@ -200,22 +164,6 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->MapRGB=xp_dlsym(sdl_dll, SDL_MapRGB))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->LockSurface=xp_dlsym(sdl_dll, SDL_LockSurface))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->UnlockSurface=xp_dlsym(sdl_dll, SDL_UnlockSurface))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->ConvertSurface=xp_dlsym(sdl_dll, SDL_ConvertSurface))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
}
if((sdlf->CreateTexture=xp_dlsym(sdl_dll, SDL_CreateTexture))==NULL) {
xp_dlclose(sdl_dll);
return(-1);
......@@ -339,11 +287,6 @@ int init_sdl_audio(void)
return(-1);
}
void run_sdl_drawing_thread(int (*drawing_thread)(void *data))
{
sdl.CreateThread(drawing_thread, NULL);
}
static void QuitWrap(void)
{
if (sdl_initialized) {
......
......@@ -17,39 +17,28 @@ struct sdlfuncs {
int (HACK_HACK_HACK *mutexP) (SDL_mutex *mutex);
int (HACK_HACK_HACK *mutexV) (SDL_mutex *mutex);
int (HACK_HACK_HACK *PeepEvents) (SDL_Event *events, int numevents,
SDL_eventaction action, Uint32 mask);
SDL_eventaction action, Uint32 minType, Uint32 maxType);
char *(HACK_HACK_HACK *GetCurrentVideoDriver) (void);
int (HACK_HACK_HACK *SemWait) (SDL_sem *sem);
int (HACK_HACK_HACK *SemWaitTimeout)(SDL_sem *sem, Uint32 timeout);
int (HACK_HACK_HACK *SemPost) (SDL_sem *sem);
Uint8 (HACK_HACK_HACK *EventState) (Uint32 type, int state);
SDL_Surface *(HACK_HACK_HACK *CreateRGBSurface) (Uint32 flags, int width, int height, int depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
SDL_Surface *(HACK_HACK_HACK *CreateRGBSurfaceFrom)(void *pixels, int width, int height, int depth, int pitch,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
int (HACK_HACK_HACK *FillRect) (SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
int (HACK_HACK_HACK *BlitSurface) (SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect);
void (HACK_HACK_HACK *RenderPresent) (SDL_Renderer *renderer);
SDL_sem *(HACK_HACK_HACK *SDL_CreateSemaphore) (Uint32 initial_value);
void (HACK_HACK_HACK *SDL_DestroySemaphore) (SDL_sem *semaphore);
SDL_mutex *(HACK_HACK_HACK *SDL_CreateMutex) (void);
struct SDL_Thread *(HACK_HACK_HACK *CreateThread) (int (*fn)(void *), void *data);
void (HACK_HACK_HACK *WaitThread) (SDL_Thread *thread, int *status);
int (HACK_HACK_HACK *WaitEventTimeout) (SDL_Event *event, int timeout);
int (HACK_HACK_HACK *PollEvent) (SDL_Event *event);
SDL_Window *(HACK_HACK_HACK *CreateWindow) (const char *title, int x, int y, int w, int h, Uint32 flags);
int (HACK_HACK_HACK *CreateWindowAndRenderer) (int w, int h, Uint32 flags, SDL_Window **win, SDL_Renderer **ren);
SDL_Renderer *(HACK_HACK_HACK *CreateRenderer) (SDL_Window* window, int index, Uint32 flags);
void (HACK_HACK_HACK *FreeSurface) (SDL_Surface *surface);
void (HACK_HACK_HACK *SetWindowTitle) (SDL_Window *window, const char *title);
void (HACK_HACK_HACK *GetWindowSize) (SDL_Window *window, int *w, int *h);
SDL_Surface *(HACK_HACK_HACK *GetWindowSurface) (SDL_Window *window);
void (HACK_HACK_HACK *SetWindowIcon) (SDL_Window *win, SDL_Surface *icon);
int (HACK_HACK_HACK *ShowCursor) (int toggle);
Uint32 (HACK_HACK_HACK *WasInit) (Uint32 flags);
int (HACK_HACK_HACK *GetWindowWMInfo) (SDL_Window *window, SDL_SysWMinfo *info);
char *(HACK_HACK_HACK *GetError) (void);
SDL_bool (HACK_HACK_HACK *GetWindowWMInfo) (SDL_Window *window, SDL_SysWMinfo *info);
const char *(HACK_HACK_HACK *GetError) (void);
int (HACK_HACK_HACK *InitSubSystem)(Uint32 flags);
void (HACK_HACK_HACK *QuitSubSystem)(Uint32 flags);
int (HACK_HACK_HACK *OpenAudio)(SDL_AudioSpec *desired, SDL_AudioSpec *obtained);
......@@ -58,10 +47,6 @@ struct sdlfuncs {
void (HACK_HACK_HACK *UnlockAudio)(void);
void (HACK_HACK_HACK *PauseAudio)(int pause_on);
SDL_AudioStatus (HACK_HACK_HACK *GetAudioStatus)(void);
Uint32 (HACK_HACK_HACK *MapRGB) (SDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b);
int (HACK_HACK_HACK *LockSurface) (SDL_Surface *surface);
void (HACK_HACK_HACK *UnlockSurface) (SDL_Surface *surface);
SDL_Surface *(HACK_HACK_HACK *ConvertSurface)(SDL_Surface *surf, const SDL_PixelFormat *fmt, Uint32 flags);
SDL_Texture* (HACK_HACK_HACK *CreateTexture) (SDL_Renderer *renderer, Uint32 format, int access, int w, int h);
int (HACK_HACK_HACK *UpdateTexture) (SDL_Texture *texture, const SDL_Rect * rect, const void *pixels, int pitch);
int (HACK_HACK_HACK *RenderClear) (SDL_Renderer *renderer);
......@@ -80,7 +65,6 @@ extern "C" {
int load_sdl_funcs(struct sdlfuncs *sdlf);
int init_sdl_audio(void);
int init_sdl_video(void);
void run_sdl_drawing_thread(int (*drawing_thread)(void *data));
#ifdef __cplusplus
}
#endif
......
......@@ -334,10 +334,6 @@ js_conio_init(JSContext *cx, uintN argc, jsval *arglist)
ciolib_mode=CIOLIB_MODE_SDL;
else if(!stricmp(mode,"SDL_FULLSCREEN"))
ciolib_mode=CIOLIB_MODE_SDL_FULLSCREEN;
else if(!stricmp(mode,"SDL_YUV"))
ciolib_mode=CIOLIB_MODE_SDL_YUV;
else if(!stricmp(mode,"SDL_YUV_FULLSCREEN"))
ciolib_mode=CIOLIB_MODE_SDL_YUV_FULLSCREEN;
else {
JS_ReportError(cx, "Unhandled ciolib mode \"%s\"", mode);
return JS_FALSE;
......@@ -1043,8 +1039,7 @@ static jsSyncMethodSpec js_functions[] = {
"<tr><td>\"CURSES_IBM\"</td><td>Use the curses terminal library and write extended ASCII characters directly as-is, assuming the terminal is using CP437. (*nix only)</td></tr><tr><td>"
"<tr><td>\"SDL\"</td><td>Use the SDL library for output.</td></tr><tr><td>"
"<tr><td>\"SDL_FULLSCREEN\"</td><td>Use the SDL library for output (fullscreen).</td></tr><tr><td>"
"<tr><td>\"SDL_YUV\"</td><td>Use the SDL library for output using an overlay which allows hardware-based arbitrary scaling.</td></tr><tr><td>"
"<tr><td>\"SDL_YUV_FULLSCREEN\"</td><td>Use the SDL library for output using an overlay which allows hardware-based arbitrary scaling (fullscreen).</td></tr><tr><td></table>"
"</table>"
),315
},
{"suspend", js_conio_suspend, 0
......
......@@ -744,8 +744,6 @@ int output_map[]={
#if defined(WITH_SDL) || defined(WITH_SDL_AUDIO)
,CIOLIB_MODE_SDL
,CIOLIB_MODE_SDL_FULLSCREEN
,CIOLIB_MODE_SDL_YUV
,CIOLIB_MODE_SDL_YUV_FULLSCREEN
#endif
,0};
char *output_descrs[]={
......@@ -1442,17 +1440,6 @@ int main(int argc, char **argv)
break;
}
break;
case 'O':
switch(toupper(argv[i][3])) {
case 0:
case 'W':
ciolib_mode=CIOLIB_MODE_SDL_YUV;
break;
case 'F':
ciolib_mode=CIOLIB_MODE_SDL_YUV_FULLSCREEN;
break;
}
break;
default:
goto USAGE;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment