Previous 15994 Revisions Next

r2989 Monday 28th July, 2008 at 20:31:29 UTC by R. Belmont
[SDLMESS] Sync with SDLMAME 0.126u2, including that version's new features.
[src/osd/sdl]debugosx.c debugwin.c debugwin.h drawogl.c drawsdl.c input.c input.h os2work.c osdsdl.h osxutils.h sdl.mak sdlmain.c sdlsync.c sdlsync.h sdlwork.c strconv.h testkeys.c video.c video.h window.c window.h

src/osd/sdl/drawogl.c
r2988r2989
160160struct _sdl_info
161161{
162162   INT32          blittimer;
163   UINT32         extra_flags;
163164
164165#if (SDL_VERSION_ATLEAST(1,3,0))
165166   SDL_GLContext   gl_context_id;
r2988r2989
197198
198199   int            totalColors;      // total colors from machine/sdl_window_config/sdl_window_info
199200
201   float         last_hofs;
202   float         last_vofs;
203   
200204   // Static vars from draogl_window_dra
201   INT32          old_blitwidth;
202   INT32          old_blitheight;
203205   INT32          surf_w;
204206   INT32          surf_h;
205207    GLfloat       texVerticex[8];
r2988r2989
292294// core functions
293295
294296static void drawogl_exit(void);
297static void drawogl_attach(sdl_draw_info *info, sdl_window_info *window);
295298static int drawogl_window_create(sdl_window_info *window, int width, int height);
296299static void drawogl_window_resize(sdl_window_info *window, int width, int height);
297300static void drawogl_window_destroy(sdl_window_info *window);
r2988r2989
299302static const render_primitive_list *drawogl_window_get_primitives(sdl_window_info *window);
300303static void drawogl_destroy_all_textures(sdl_window_info *window);
301304static void drawogl_window_clear(sdl_window_info *window);
305static int drawogl_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt);
302306
303307
304308
r2988r2989
389393//  drawogl_init
390394//============================================================
391395
392int drawogl_init(sdl_draw_callbacks *callbacks)
396int drawogl_init(sdl_draw_info *callbacks)
393397{
394398   // fill in the callbacks
395399   callbacks->exit = drawogl_exit;
396   callbacks->window_create = drawogl_window_create;
397   callbacks->window_resize = drawogl_window_resize;
398   callbacks->window_get_primitives = drawogl_window_get_primitives;
399   callbacks->window_draw = drawogl_window_draw;
400   callbacks->window_destroy = drawogl_window_destroy;
401   callbacks->window_destroy_all_textures = drawogl_destroy_all_textures;
402   callbacks->window_clear = drawogl_window_clear;
400   callbacks->attach = drawogl_attach;
403401
404402   dll_loaded = 0;
405403
406   #if SDL_VERSION_ATLEAST(1,3,0)
407   mame_printf_verbose("Using SDL multi-window OpenGL driver (SDL 1.3+)\n");
408   #else
409   mame_printf_verbose("Using SDL single-window OpenGL driver (SDL 1.2)\n");
410   #endif
404   if (SDL_VERSION_ATLEAST(1,3,0))
405      mame_printf_verbose("Using SDL multi-window OpenGL driver (SDL 1.3+)\n");
406   else
407      mame_printf_verbose("Using SDL single-window OpenGL driver (SDL 1.2)\n");
411408   return 0;
412409}
413410
411
414412//============================================================
413//  drawogl_attach
414//============================================================
415
416static void drawogl_attach(sdl_draw_info *info, sdl_window_info *window)
417{
418   // fill in the callbacks
419   window->create = drawogl_window_create;
420   window->resize = drawogl_window_resize;
421   window->get_primitives = drawogl_window_get_primitives;
422   window->draw = drawogl_window_draw;
423   window->destroy = drawogl_window_destroy;
424   window->destroy_all_textures = drawogl_destroy_all_textures;
425   window->clear = drawogl_window_clear;
426   window->xy_to_render_target = drawogl_xy_to_render_target;
427}
428
429
430//============================================================
415431// Load the OGL function addresses
416432//============================================================
417433
r2988r2989
454470       *  directfb and and x11 use this env var
455471       *   SDL_VIDEO_GL_DRIVER
456472       */
457      const char *e;
473      const char *stemp;
458474
459      e=getenv(SDLENV_GL_LIB);
460     
461#ifdef SDLMAME_MACOSX
462      /* Vas Crabb: Default GL-lib for MACOSX */
463      if (!e)
464         e = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib";
465#endif
466      if (SDL_GL_LoadLibrary(e) != 0) // Load library (default for e==NULL
475      stemp = options_get_string(mame_options(), SDLOPTION_GL_LIB);
476      if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) == 0)
477         stemp = NULL;
478
479      if (SDL_GL_LoadLibrary(stemp) != 0) // Load library (default for e==NULL
467480      {
468         fatalerror("Unable to load default library: %s\n", e);
481         fatalerror("Unable to load opengl library: %s\n", stemp ? stemp : "<default>");
469482      }
470          mame_printf_verbose("Loaded opengl shared library: %s\n", e ? e : "<default>");
483          mame_printf_verbose("Loaded opengl shared library: %s\n", stemp ? stemp : "<default>");
471484       gl_dispatch = auto_malloc(sizeof(osd_gl_dispatch));
472485        dll_loaded=1;
473486   }
r2988r2989
492505   window->dxdata = sdl;
493506
494507#if (SDL_VERSION_ATLEAST(1,3,0))
495   window->extra_flags = (window->fullscreen ?
508   sdl->extra_flags = (window->fullscreen ?
496509         SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS : SDL_WINDOW_RESIZABLE);
497   window->extra_flags |= SDL_WINDOW_OPENGL;
510   sdl->extra_flags |= SDL_WINDOW_OPENGL;
498511
499512   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
500513   load_gl_lib();
501514
502515   // create the SDL window
503516   SDL_SelectVideoDisplay(window->monitor->handle);
504   SDL_SetFullscreenDisplayMode(NULL);   // Use desktop
517
518   if (window->fullscreen && video_config.switchres)
519   {
520      SDL_DisplayMode mode;
521      SDL_GetCurrentDisplayMode(&mode);
522      mode.w = width;
523      mode.h = height;
524      SDL_SetFullscreenDisplayMode(&mode);   // Try to set mode
525   }
526   else
527      SDL_SetFullscreenDisplayMode(NULL);   // Use desktop
528   
505529   window->window_id = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
506         width, height, window->extra_flags);
507#if 0
508   if ( (video_config.mode  == VIDEO_MODE_OPENGL) && !(sdl->sdlsurf->flags & SDL_OPENGL) )
530         width, height, sdl->extra_flags);
531
532   if  (!(SDL_GetWindowFlags(window->window_id) & SDL_WINDOW_OPENGL) )
509533   {
510      fprintf(stderr, "OpenGL not supported on this driver!\n");
534      mame_printf_error("OpenGL not supported on this driver!\n");
511535      return 1;
512536   }
513#endif
537
514538   SDL_ShowWindow(window->window_id);
515539   SDL_SetWindowFullscreen(window->window_id, window->fullscreen);
516540   SDL_RaiseWindow(window->window_id);
r2988r2989
519543   sdl->gl_context_id = SDL_GL_CreateContext(window->window_id);
520544
521545#else
522   window->extra_flags = (window->fullscreen ?  SDL_FULLSCREEN : SDL_RESIZABLE);
523   window->extra_flags |= SDL_OPENGL | SDL_DOUBLEBUF;
546   sdl->extra_flags = (window->fullscreen ?  SDL_FULLSCREEN : SDL_RESIZABLE);
547   sdl->extra_flags |= SDL_OPENGL | SDL_DOUBLEBUF;
524548
525549   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
526550   #if (SDL_VERSION_ATLEAST(1,2,10))
r2988r2989
532556
533557   // create the SDL surface (which creates the window in windowed mode)
534558   sdl->sdlsurf = SDL_SetVideoMode(width, height,
535                     0, SDL_SWSURFACE  | SDL_ANYFORMAT | window->extra_flags);
559                     0, SDL_SWSURFACE  | SDL_ANYFORMAT | sdl->extra_flags);
536560
537561   if (!sdl->sdlsurf)
538562      return 1;
r2988r2989
542566   
543567   if ( (video_config.mode  == VIDEO_MODE_OPENGL) && !(sdl->sdlsurf->flags & SDL_OPENGL) )
544568   {
545      fprintf(stderr, "OpenGL not supported on this driver!\n");
569      mame_printf_error("OpenGL not supported on this driver!\n");
546570      return 1;
547571   }
548572
r2988r2989
551575
552576#endif   
553577   sdl->totalColors = window->totalColors;
554   sdl->old_blitwidth = 0;
555   sdl->old_blitheight = 0;
556578   sdl->blittimer = 0;
557579   sdl->surf_w = 0;
558580   sdl->surf_h = 0;
r2988r2989
737759   SDL_FreeSurface(sdl->sdlsurf);
738760
739761   sdl->sdlsurf = SDL_SetVideoMode(width, height, 0,
740         SDL_SWSURFACE | SDL_ANYFORMAT | window->extra_flags);
762         SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags);
741763   window->width = sdl->sdlsurf->w;
742764   window->height = sdl->sdlsurf->h;
743765
744766#endif
745   sdl->init_context = 0;
767   sdl->init_context = 1;
746768   
747769}
748770
749771//============================================================
772//  drawsdl_xy_to_render_target
773//============================================================
774
775static int drawogl_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt)
776{
777   sdl_info *sdl = window->dxdata;
778
779   *xt = x - sdl->last_hofs;
780   *yt = y - sdl->last_vofs;
781   if (*xt<0 || *xt >= window->blitwidth)
782      return 0;
783   if (*yt<0 || *xt >= window->blitheight)
784      return 0;
785   return 1;
786}
787
788//============================================================
750789//  drawogl_window_get_primitives
751790//============================================================
752791
r2988r2989
768807//  loadGLExtensions
769808//============================================================
770809
771static void loadGLExtensions(sdl_info *sdl)
810static void loadGLExtensions(sdl_window_info *window)
772811{
812   sdl_info *sdl = window->dxdata;
773813   static int _once = 1;
774814
775815   // sdl->usevbo=FALSE; // You may want to switch VBO and PBO off, by uncommenting this statement
r2988r2989
9781018
9791019   if ( sdl->useglsl )
9801020   {
981      if ( video_config.prescale != 1 )
1021      if ( window->prescale != 1 )
9821022      {
9831023         sdl->useglsl = 0;
9841024         if (_once)
r2988r2989
9861026            mame_printf_warning("OpenGL: GLSL supported, but disabled due to: prescale !=1 \n");
9871027         }
9881028      }
989      if ( video_config.prescale_effect != 0 )
1029      if ( window->prescale_effect != 0 )
9901030      {
9911031         sdl->useglsl = 0;
9921032         if (_once)
r2988r2989
11071147   }
11081148
11091149#if (SDL_VERSION_ATLEAST(1,3,0))
1110   //SDL_SelectRenderer(window->window_id);
11111150   SDL_GL_MakeCurrent(window->window_id, sdl->gl_context_id);
11121151#endif
11131152   if (sdl->init_context)
r2988r2989
11271166      sdl->blittimer--;
11281167   }
11291168
1130   if (sdl->init_context || (sdl->old_blitwidth != window->blitwidth) || (sdl->old_blitheight != window->blitheight))
1131   {
1132      glClear(GL_COLOR_BUFFER_BIT);
1133
1134      sdl->old_blitwidth  = window->blitwidth;
1135      sdl->old_blitheight = window->blitheight;
1136
1137      sdl->blittimer = 2;
1138   }
1139
11401169   if ( !sdl->initialized ||
11411170         window->width!= sdl->surf_w || window->height!= sdl->surf_h )
11421171   {
11431172      if ( !sdl->initialized )
11441173      {
1145         loadGLExtensions(sdl);
1174         loadGLExtensions(window);
11461175      }
11471176     
11481177      sdl->surf_w=window->width;
r2988r2989
12311260      }
12321261   }
12331262
1263   sdl->last_hofs = hofs;
1264   sdl->last_vofs = vofs;
1265   
12341266   osd_lock_acquire(window->primlist->lock);
12351267
12361268   // now draw
r2988r2989
12531285                curPrimitive=GL_LINES;
12541286            }
12551287
1256                                if(pendingPrimitive!=GL_NO_PRIMITIVE && pendingPrimitive!=curPrimitive)
1288            if(pendingPrimitive!=GL_NO_PRIMITIVE && pendingPrimitive!=curPrimitive)
12571289            {
12581290                glEnd();
12591291                pendingPrimitive=GL_NO_PRIMITIVE;
r2988r2989
16641696   return (needPow2)?gl_round_to_pow2(v):v;
16651697}
16661698
1667static void texture_compute_size_subroutine(sdl_info *sdl, texture_info *texture, UINT32 flags,
1699static void texture_compute_size_subroutine(sdl_window_info *window, texture_info *texture, UINT32 flags,
16681700                                            UINT32 width, UINT32 height,
16691701                                            int* p_width, int* p_height, int* p_width_create, int* p_height_create)
16701702{
1671        int width_create;
1672        int height_create;
1703   sdl_info *sdl = window->dxdata;
1704    int width_create;
1705    int height_create;
16731706
16741707   if ( texture->texpow2 )
16751708        {
r2988r2989
16921725      texture->xprescale--;
16931726   while (texture->yprescale > 1 && height_create * texture->yprescale > sdl->texture_max_height)
16941727      texture->yprescale--;
1695   if (PRIMFLAG_GET_SCREENTEX(flags) && (texture->xprescale != video_config.prescale || texture->yprescale != video_config.prescale))
1696      mame_printf_warning("SDL: adjusting prescale from %dx%d to %dx%d\n", video_config.prescale, video_config.prescale, texture->xprescale, texture->yprescale);
1728   if (PRIMFLAG_GET_SCREENTEX(flags) && (texture->xprescale != window->prescale || texture->yprescale != window->prescale))
1729      mame_printf_warning("SDL: adjusting prescale from %dx%d to %dx%d\n", window->prescale, window->prescale, texture->xprescale, texture->yprescale);
16971730
16981731   width  *= texture->xprescale;
16991732   height *= texture->yprescale;
r2988r2989
17151748        *p_height_create=height_create;
17161749}
17171750
1718static void texture_compute_size_type(sdl_info *sdl, const render_texinfo *texsource, texture_info *texture, UINT32 flags)
1751static void texture_compute_size_type(sdl_window_info *window, const render_texinfo *texsource, texture_info *texture, UINT32 flags)
17191752{
1753   sdl_info *sdl = window->dxdata;
17201754   int finalheight, finalwidth;
17211755   int finalheight_create, finalwidth_create;
17221756
r2988r2989
17291763
17301764        texture_compute_type_subroutine(sdl, texsource, texture, flags);
17311765         
1732        texture_compute_size_subroutine(sdl, texture, flags, texsource->width, texsource->height,
1766        texture_compute_size_subroutine(window, texture, flags, texsource->width, texsource->height,
17331767                                        &finalwidth, &finalheight, &finalwidth_create, &finalheight_create);
17341768
17351769   // if we added pixels for the border, and that just barely pushed us over, take it back
r2988r2989
17411775
17421776                texture_compute_type_subroutine(sdl, texsource, texture, flags);
17431777                 
1744                texture_compute_size_subroutine(sdl, texture, flags, texsource->width, texsource->height,
1778                texture_compute_size_subroutine(window, texture, flags, texsource->width, texsource->height,
17451779                                                &finalwidth, &finalheight, &finalwidth_create, &finalheight_create);
17461780   }
17471781
r2988r2989
22442278   texture->texinfo.seqid = -1; // force set data
22452279   if (PRIMFLAG_GET_SCREENTEX(flags))
22462280   {
2247      texture->xprescale = video_config.prescale;
2248      texture->yprescale = video_config.prescale;
2249      texture->prescale_effect = video_config.prescale_effect;
2281      texture->xprescale = window->prescale;
2282      texture->yprescale = window->prescale;
2283      texture->prescale_effect = window->prescale_effect;
22502284   }
22512285   else
22522286   {
r2988r2989
23052339   }
23062340
23072341   // compute the size
2308   texture_compute_size_type(sdl, texsource, texture, flags);
2342   texture_compute_size_type(window, texsource, texture, flags);
23092343
2310        texture->pbo=0;
2344    texture->pbo=0;
23112345
23122346   if ( texture->type != TEXTURE_TYPE_SHADER && sdl->useglsl)
23132347   {
r2988r2989
27082742      if (container!=NULL)
27092743      {
27102744         render_container_user_settings settings;
2711
27122745         render_container_get_user_settings(container, &settings);
2713
2746         //FIXME: Intended behaviour
2747#if 1
27142748         vid_attributes[0] = options_get_float(mame_options(), OPTION_GAMMA);
27152749         vid_attributes[1] = options_get_float(mame_options(), OPTION_CONTRAST);
27162750         vid_attributes[2] = options_get_float(mame_options(), OPTION_BRIGHTNESS);
2751#else
2752         vid_attributes[0] = settings.gamma;
2753         vid_attributes[1] = settings.contrast;
2754         vid_attributes[2] = settings.brightness;
2755#endif
27172756         vid_attributes[3] = 0.0f;
27182757         uniform_location = pfn_glGetUniformLocationARB(sdl->glsl_program[shaderIdx], "vid_attributes");
27192758         pfn_glUniform4fvARB(uniform_location, 1, &(vid_attributes[shaderIdx]));
src/osd/sdl/osxutils.h
r2988r2989
99//
1010//============================================================
1111
12#ifndef __SDL_OSXUTILS__
13#define __SDL_OSXUTILS__
12#ifndef __SDLOSXUTILS__
13#define __SDLOSXUTILS__
1414
1515//============================================================
1616//  PROTOTYPES
src/osd/sdl/strconv.h
r2988r2989
77//
88//============================================================
99
10#ifndef __SDL_STRCONV__
11#define __SDL_STRCONV__
10#ifndef __SDLSTRCONV__
11#define __SDLSTRCONV__
1212
1313#include "mamecore.h"
1414
r2988r2989
3232
3333
3434
35#endif // __SDL_STRCONV__
35#endif // __SDLSTRCONV__
3636
src/osd/sdl/sdl.mak
r2988r2989
4444# There is no need to play with this option unless you are doing
4545# active development on sdlmame or SDL.
4646
47#SDL_INSTALL_ROOT = /usr/local/sdl13
47# SDL_INSTALL_ROOT = /usr/local/sdl13
4848
4949###########################################################################
5050##################   END USER-CONFIGURABLE OPTIONS   ######################
src/osd/sdl/input.c
r2988r2989
135135
136136#if SDLMAME_EVENTS_IN_WORKER_THREAD
137137// input buffer
138#define MAX_BUF_EVENTS       (100)
138#define MAX_BUF_EVENTS       (500)      /* 100 not enough for SDL 1.3 */
139139static SDL_Event         event_buf[MAX_BUF_EVENTS];
140140static int               event_buf_count;
141141#endif
r2988r2989
203203#if (SDL_VERSION_ATLEAST(1,3,0))
204204
205205#define OSD_SDL_INDEX(x) (x)
206#define OSD_SDL_INDEX_KEYSYM(keysym) ((keysym)->scancode)
207#define GET_WINDOW(ev) window_from_id((ev)->windowID)
206208
207209#define KTT_ENTRY0(MAME, SDL, VK, AS, UI) { ITEM_ID_ ## MAME, SDL_SCANCODE_ ## SDL, "ITEM_ID_" #MAME, (char *) UI }
208210#define KTT_ENTRY1(MAME, SDL) KTT_ENTRY0(MAME, SDL, MAME, MAME, #MAME)
r2988r2989
325327#else
326328
327329#define OSD_SDL_INDEX(x) (SDLK_INDEX(x)-SDLK_FIRST)
330#define OSD_SDL_INDEX_KEYSYM(keysym) (OSD_SDL_INDEX((keysym)->sym))
331#define GET_WINDOW(ev) sdl_window_list
328332
329333#define KTT_ENTRY0(MAME, SDL, VK, AS, UI) { ITEM_ID_ ## MAME, SDLK_ ## SDL, "ITEM_ID_" #MAME, (char *) UI }
330334#define KTT_ENTRY1(MAME, SDL) KTT_ENTRY0(MAME, SDL, MAME, MAME, #MAME)
r2988r2989
578582//============================================================
579583//  INLINE FUNCTIONS
580584//============================================================
581#if 0
582INLINE INT32 normalize_absolute_axis(INT32 raw, INT32 rawmin, INT32 rawmax)
583{
584   INT32 center = (rawmax + rawmin) / 2;
585585
586   // make sure we have valid data
587   if (rawmin >= rawmax)
588      return raw;
589   
590   // above center
591   if (raw >= center)
592   {
593      INT32 result = (INT64)(raw - center) * (INT64)INPUT_ABSOLUTE_MAX / (INT64)(rawmax - center);
594      return MIN(result, INPUT_ABSOLUTE_MAX);
595   }
596   
597   // below center
598   else
599   {
600      INT32 result = -((INT64)(center - raw) * (INT64)-INPUT_ABSOLUTE_MIN / (INT64)(center - rawmin));
601      return MAX(result, INPUT_ABSOLUTE_MIN);
602   }
603}
604#endif
605586static int joy_map_leastfree(void)
606587{
607588   int i;
r2988r2989
888869#endif
889870
890871//============================================================
872//  sdlinput_read_keymap
873//============================================================
874
875static kt_table * sdlinput_read_keymap(char *keymap_filename)
876{
877   kt_table *key_trans_table;
878   FILE *keymap_file;
879   int line = 1;
880   int index,i, sk, vk, ak;
881   char buf[256];
882   char mks[21];
883   char sks[21];
884   char kns[21];
885
886   mame_printf_verbose("Keymap: Start reading keymap_file %s\n", keymap_filename);
887
888   keymap_file = fopen(keymap_filename, "r");
889   if (keymap_file == NULL)
890   {
891      mame_printf_warning( "Keymap: Unable to open keymap %s, using default\n", keymap_filename);
892      return sdl_key_trans_table;
893   }
894
895   key_trans_table = auto_malloc(sizeof(sdl_key_trans_table));
896   memcpy((void *) key_trans_table, sdl_key_trans_table, sizeof(sdl_key_trans_table));
897   
898   while (!feof(keymap_file))
899   {
900      fgets(buf, 255, keymap_file);
901      if (*buf && buf[0] && buf[0] != '#')
902      {
903         buf[255]=0;
904         i=strlen(buf);
905         if (i && buf[i-1] == '\n')
906            buf[i-1] = 0;
907         mks[0]=0;
908         sks[0]=0;
909         memset(kns, 0, 21);
910         sscanf(buf, "%20s %20s %x %x %20c\n",
911               mks, sks, &vk, &ak, kns);
912         
913         index=lookup_mame_index(mks);
914         sk = lookup_sdl_code(sks);
915
916         if ( sk >= 0 && index >=0)
917         {
918            key_trans_table[index].sdl_key = sk;
919            // vk and ak are not really needed
920            //key_trans_table[index][VIRTUAL_KEY] = vk;
921            //key_trans_table[index][ASCII_KEY] = ak;
922            key_trans_table[index].ui_name = auto_malloc(strlen(kns)+1);
923            strcpy(key_trans_table[index].ui_name, kns);
924            mame_printf_verbose("Keymap: Mapped <%s> to <%s> with ui-text <%s>\n", sks, mks, kns);
925         }
926         else
927            mame_printf_warning("Keymap: Error on line %d - %s key not found: %s\n", line, (sk<0) ? "sdl" : "mame", buf);
928      }
929      line++;
930   }
931   fclose(keymap_file);
932   mame_printf_verbose("Keymap: Processed %d lines\n", line);
933   
934   return key_trans_table;
935}
936
937//============================================================
891938//  sdlinput_init
892939//============================================================
893940
r2988r2989
897944   int keynum, button;
898945   char defname[20];
899946   kt_table *key_trans_table;
900   kt_table *ktt_alloc = NULL;
901947
902   // we want unicode keyboard characters
903   SDL_EnableUNICODE(1);
904
905948   keyboard_list = NULL;
906949   joystick_list = NULL;
907950   mouse_list = NULL;
r2988r2989
917960   if (options_get_bool(mame_options(), SDLOPTION_KEYMAP))
918961   {
919962      char *keymap_filename;
920      FILE *keymap_file;
921      int line = 1;
922963
923964      keymap_filename = (char *)options_get_string(mame_options(), SDLOPTION_KEYMAP_FILE);
924      mame_printf_verbose("Keymap: Start reading keymap_file %s\n", keymap_filename);
925965
926      keymap_file = fopen(keymap_filename, "r");
927
928      if (keymap_file == NULL)
929      {
930         mame_printf_warning( "Keymap: Unable to open keymap %s, using default\n", keymap_filename);
931         key_trans_table = sdl_key_trans_table;
932      }
933      else
934      {
935         int index,i, sk, vk, ak;
936         char buf[256];
937         char mks[21];
938         char sks[21];
939         char kns[21];
940         
941         ktt_alloc = malloc_or_die(sizeof(sdl_key_trans_table));
942         key_trans_table = ktt_alloc;
943         memcpy((void *) key_trans_table, sdl_key_trans_table, sizeof(sdl_key_trans_table));
944         while (!feof(keymap_file))
945         {
946            fgets(buf, 255, keymap_file);
947            if (*buf && buf[0] && buf[0] != '#')
948            {
949               buf[255]=0;
950               i=strlen(buf);
951               if (i && buf[i-1] == '\n')
952                  buf[i-1] = 0;
953               mks[0]=0;
954               sks[0]=0;
955               memset(kns, 0, 21);
956               sscanf(buf, "%20s %20s %x %x %20c\n",
957                     mks, sks, &vk, &ak, kns);
958               
959               index=lookup_mame_index(mks);
960               sk = lookup_sdl_code(sks);
961
962               if ( sk >= 0 && index >=0)
963               {
964                  key_trans_table[index].sdl_key = sk;
965                  // vk and ak are not really needed
966                  //key_trans_table[index][VIRTUAL_KEY] = vk;
967                  //key_trans_table[index][ASCII_KEY] = ak;
968                  key_trans_table[index].ui_name = auto_malloc(strlen(kns)+1);
969                  strcpy(key_trans_table[index].ui_name, kns);
970                  mame_printf_verbose("Keymap: Mapped <%s> to <%s> with ui-text <%s>\n", sks, mks, kns);
971               }
972               else
973                  mame_printf_warning("Keymap: Error on line %d - %s key not found: %s\n", line, (sk<0) ? "sdl" : "mame", buf);
974            }
975            line++;
976         }
977         fclose(keymap_file);
978         mame_printf_verbose("Keymap: Processed %d lines\n", line);
979      }
966      key_trans_table = sdlinput_read_keymap(keymap_filename);
980967   }
981968   else
982969   {
r2988r2989
10301017   device_list_reset_devices(mouse_list);
10311018   device_list_reset_devices(joystick_list);
10321019   
1033   // clean up
1034   if (ktt_alloc)
1035      free(ktt_alloc);
10361020}
10371021
10381022
r2988r2989
10911075         return w;
10921076      }
10931077   }
1094   // deliberately crash
1095   printf("Window %d not found\n", windowID);
10961078   return NULL;
10971079}
10981080#endif
r2988r2989
11701152         }
11711153         #endif
11721154
1173         #if (SDL_VERSION_ATLEAST(1,3,0))
1174         ui_input_push_char_event(machine, window_from_id(event.window.windowID)->target, (unicode_char)event.key.keysym.unicode);
1175         #else
1176         ui_input_push_char_event(machine, sdl_window_list->target, (unicode_char)event.key.keysym.unicode);
1177         #endif
1178
11791155         devinfo = keyboard_list;
1180#if (SDL_VERSION_ATLEAST(1,3,0))
1181         devinfo->keyboard.state[OSD_SDL_INDEX(event.key.keysym.scancode)] = 0x80;
1182#else
1183         devinfo->keyboard.state[OSD_SDL_INDEX(event.key.keysym.sym)] = 0x80;
1156         devinfo->keyboard.state[OSD_SDL_INDEX_KEYSYM(&event.key.keysym)] = 0x80;
1157#if (!SDL_VERSION_ATLEAST(1,3,0))
1158         ui_input_push_char_event(machine, sdl_window_list->target, (unicode_char) event.key.keysym.unicode);
11841159#endif
11851160         break;
11861161      case SDL_KEYUP:
11871162         devinfo = keyboard_list;
1188#if (SDL_VERSION_ATLEAST(1,3,0))
1189         devinfo->keyboard.state[OSD_SDL_INDEX(event.key.keysym.scancode)] = 0x0;
1190#else
1191         devinfo->keyboard.state[OSD_SDL_INDEX(event.key.keysym.sym)] = 0x0;
1192#endif
1163         devinfo->keyboard.state[OSD_SDL_INDEX_KEYSYM(&event.key.keysym)] = 0x00;
11931164         break;
11941165      case SDL_JOYAXISMOTION:
11951166         devinfo = generic_device_find_index(joystick_list, joy_logical[event.jaxis.which]);
r2988r2989
12631234      case SDL_MOUSEBUTTONDOWN:
12641235         devinfo = mouse_list;
12651236         devinfo->mouse.buttons[event.button.button-1] = 0x80;
1266
1267         #if (SDL_VERSION_ATLEAST(1,3,0))
1268         ui_input_push_mouse_click_event(machine, window_from_id(event.window.windowID)->target, event.button.x, event.button.y);
1269         #else
1270         ui_input_push_mouse_click_event(machine, sdl_window_list->target, event.button.x, event.button.y);
1271         #endif
1272
1237         if (event.button.button == 1)
1238         {
1239            // FIXME Move static declaration
1240            static osd_ticks_t last_click = 0;
1241            static int last_x = 0;
1242            static int last_y = 0;
1243            int cx, cy;
1244            osd_ticks_t click = osd_ticks() * 1000 / osd_ticks_per_second();
1245            sdl_window_info *window = GET_WINDOW(&event.button);
1246           
1247            if (window != NULL && window->xy_to_render_target(window, event.button.x,event.button.y, &cx, &cy) )
1248            {
1249               ui_input_push_mouse_click_event(machine, window->target, cx, cy);
1250               // FIXME Parameter ?
1251               if ((click-last_click < 250)
1252                     && (cx >= last_x - 4 && cx <= last_x  + 4)
1253                     && (cy >= last_y - 4 && cy <= last_y  + 4) )
1254               {
1255                  last_click = 0;
1256                  ui_input_push_mouse_double_click_event(machine, window->target, cx, cy);
1257               }
1258               else
1259               {
1260                  last_click = click;
1261                  last_x = cx;
1262                  last_y = cy;
1263               }
1264            }
1265         }
12731266         break;
12741267      case SDL_MOUSEBUTTONUP:
12751268         devinfo = mouse_list;
r2988r2989
12791272         devinfo = mouse_list;
12801273         devinfo->mouse.lX = event.motion.xrel * INPUT_RELATIVE_PER_PIXEL;
12811274         devinfo->mouse.lY = event.motion.yrel * INPUT_RELATIVE_PER_PIXEL;
1282
1283         #if (SDL_VERSION_ATLEAST(1,3,0))
1284         ui_input_push_mouse_move_event(machine, window_from_id(event.window.windowID)->target, event.motion.xrel * INPUT_RELATIVE_PER_PIXEL, event.motion.yrel * INPUT_RELATIVE_PER_PIXEL);
1285         #else
1286         ui_input_push_mouse_move_event(machine, sdl_window_list->target, event.motion.xrel * INPUT_RELATIVE_PER_PIXEL, event.motion.yrel * INPUT_RELATIVE_PER_PIXEL);
1287         #endif
1275         {
1276            int cx=-1, cy=-1;
1277            sdl_window_info *window = GET_WINDOW(&event.motion);
1278           
1279            if (window != NULL && window->xy_to_render_target(window, event.motion.x, event.motion.y, &cx, &cy) )
1280               ui_input_push_mouse_move_event(machine, window->target, cx, cy);
1281         }
12881282         break;
12891283#if (!SDL_VERSION_ATLEAST(1,3,0))
12901284      case SDL_QUIT:
r2988r2989
12941288         sdlwindow_resize(sdl_window_list, event.resize.w, event.resize.h);
12951289         break;
12961290#else
1291      case SDL_TEXTINPUT:
1292         if (*event.text.text)
1293         {
1294            sdl_window_info *w = GET_WINDOW(&event.text);
1295            unicode_char result;
1296            osd_uchar_from_osdchar(&result, event.text.text, 1);
1297            ui_input_push_char_event(machine, w->target, result);
1298         }
1299         break;
12971300      case SDL_WINDOWEVENT:
1301      {
1302         sdl_window_info *window = GET_WINDOW(&event.window);
1303         
1304         if (window == NULL)
1305            break;
1306         
12981307         switch (event.window.event)
12991308         {
13001309         case SDL_WINDOWEVENT_CLOSE:
13011310            mame_schedule_exit(machine);
13021311            break;
1312         case  SDL_WINDOWEVENT_LEAVE:
1313         {
1314            ui_input_push_mouse_leave_event(machine, window->target);
1315            break;
1316           
1317         }
13031318         case SDL_WINDOWEVENT_RESIZED:
1304            sdlwindow_resize(window_from_id(event.window.windowID), event.window.data1, event.window.data2);
1319            sdlwindow_resize(window, event.window.data1, event.window.data2);
13051320            /* fall through break; */
13061321         case SDL_WINDOWEVENT_FOCUS_GAINED:
13071322         case SDL_WINDOWEVENT_ENTER:
13081323         case SDL_WINDOWEVENT_EXPOSED:
13091324         case SDL_WINDOWEVENT_MAXIMIZED: 
13101325         case SDL_WINDOWEVENT_RESTORED:
1311            focus_window = window_from_id(event.window.windowID);
1326            focus_window = window;
13121327            break;
13131328         }
13141329         break;
1330      }
13151331#endif
13161332      }
13171333   }
src/osd/sdl/drawsdl.c
r2988r2989
4848struct _sdl_info
4949{
5050   INT32             blittimer;
51   UINT32            extra_flags;
5152
5253#if (SDL_VERSION_ATLEAST(1,3,0))
5354   SDL_TextureID      texture_id;
r2988r2989
6061   // YUV overlay
6162   UINT32             *yuv_lookup;
6263   UINT16            *yuv_bitmap;
63   int               yuv_ovl_width;
64   int               yuv_ovl_height;
64   
65   // if we leave scaling to SDL and the underlying driver, this
66   // is the render_target_width/height to use
67   
68   int               hw_scale_width;
69   int               hw_scale_height;
70   int               last_hofs;
71   int               last_vofs;
6572};
6673
6774//============================================================
r2988r2989
7481
7582// core functions
7683static void drawsdl_exit(void);
84static void drawsdl_attach(sdl_draw_info *info, sdl_window_info *window);
7785static int drawsdl_window_create(sdl_window_info *window, int width, int height);
7886static void drawsdl_window_resize(sdl_window_info *window, int width, int height);
7987static void drawsdl_window_destroy(sdl_window_info *window);
r2988r2989
8189static int drawsdl_window_draw(sdl_window_info *window, UINT32 dc, int update);
8290static void drawsdl_destroy_all_textures(sdl_window_info *window);
8391static void drawsdl_window_clear(sdl_window_info *window);
92static int drawsdl_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt);
93
8494#if (SDL_VERSION_ATLEAST(1,3,0))
8595static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight);
8696#endif
r2988r2989
103113
104114#if (!SDL_VERSION_ATLEAST(1,3,0))
105115static int shown_video_info = 0;
106static const char *yuv_mode_names[] = { "none", "yv12", "yv12x2", "yuy2", "yuy2x2" };
116static const char *scale_mode_names[] = { "none", "hwblit", "yv12", "yv12x2", "yuy2", "yuy2x2" };
107117#endif
108118
109119//============================================================
110120//  drawsdl_init
111121//============================================================
112122
113int drawsdl_init(sdl_draw_callbacks *callbacks)
123int drawsdl_init(sdl_draw_info *callbacks)
114124{
115125   // fill in the callbacks
116126   callbacks->exit = drawsdl_exit;
117   callbacks->window_create = drawsdl_window_create;
118   callbacks->window_resize = drawsdl_window_resize;
119   callbacks->window_get_primitives = drawsdl_window_get_primitives;
120   callbacks->window_draw = drawsdl_window_draw;
121   callbacks->window_destroy = drawsdl_window_destroy;
122   callbacks->window_destroy_all_textures = drawsdl_destroy_all_textures;
123   callbacks->window_clear = drawsdl_window_clear;
127   callbacks->attach = drawsdl_attach;
124128
125   #if SDL_VERSION_ATLEAST(1,3,0)
126   mame_printf_verbose("Using SDL multi-window soft driver (SDL 1.3+)\n");
127   #else
128   mame_printf_verbose("Using SDL single-window soft driver (SDL 1.2)\n");
129   #endif
129   if (SDL_VERSION_ATLEAST(1,3,0))
130      mame_printf_verbose("Using SDL multi-window soft driver (SDL 1.3+)\n");
131   else
132      mame_printf_verbose("Using SDL single-window soft driver (SDL 1.2)\n");
133
130134   return 0;
131135}
132136
r2988r2989
139143}
140144
141145//============================================================
146//  drawsdl_attach
147//============================================================
148
149static void drawsdl_attach(sdl_draw_info *info, sdl_window_info *window)
150{
151   // fill in the callbacks
152   window->create = drawsdl_window_create;
153   window->resize = drawsdl_window_resize;
154   window->get_primitives = drawsdl_window_get_primitives;
155   window->draw = drawsdl_window_draw;
156   window->destroy = drawsdl_window_destroy;
157   window->destroy_all_textures = drawsdl_destroy_all_textures;
158   window->clear = drawsdl_window_clear;
159   window->xy_to_render_target = drawsdl_xy_to_render_target;
160}
161
162//============================================================
142163//  drawsdl_destroy_all_textures
143164//============================================================
144165
r2988r2989
155176static void setup_texture(sdl_window_info *window, int tempwidth, int tempheight)
156177{
157178   sdl_info *   sdl = window->dxdata;
179   SDL_DisplayMode mode;
180   
158181   // Determine preferred pixelformat and set up yuv if necessary
182   SDL_GetCurrentDisplayMode(&mode);
159183   
160184   if (sdl->yuv_bitmap)
161185   {
r2988r2989
163187      sdl->yuv_bitmap = NULL;   
164188   }
165189   
166   switch (video_config.yuv_mode)
190   switch (window->scale_mode)
167191   {
168      case VIDEO_YUV_MODE_NONE:
169         sdl->texture_id = SDL_CreateTexture(SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING,
192      case VIDEO_SCALE_MODE_NONE:
193         sdl->texture_id = SDL_CreateTexture(mode.format, SDL_TEXTUREACCESS_STREAMING,
170194               tempwidth, tempheight);
171195         SDL_SetTextureScaleMode(sdl->texture_id, SDL_TEXTURESCALEMODE_NONE);
172196         break;
173      case VIDEO_YUV_MODE_YV12:
174         render_target_get_minimum_size(window->target, &sdl->yuv_ovl_width, &sdl->yuv_ovl_height);
175         sdl->yuv_bitmap = malloc_or_die(sdl->yuv_ovl_width * sdl->yuv_ovl_height * sizeof(UINT16));
197      case VIDEO_SCALE_MODE_HWBLIT:
198         render_target_get_minimum_size(window->target, &sdl->hw_scale_width, &sdl->hw_scale_height);
199         sdl->texture_id = SDL_CreateTexture(mode.format, SDL_TEXTUREACCESS_STREAMING,
200               sdl->hw_scale_width, sdl->hw_scale_height);
201         break;
202      case VIDEO_SCALE_MODE_YV12:
203         render_target_get_minimum_size(window->target, &sdl->hw_scale_width, &sdl->hw_scale_height);
204         sdl->yuv_bitmap = malloc_or_die(sdl->hw_scale_width * sdl->hw_scale_height * sizeof(UINT16));
176205         sdl->texture_id = SDL_CreateTexture(SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING,
177               sdl->yuv_ovl_width, sdl->yuv_ovl_height);
178         //SDL_SetTextureScaleMode(sdl->sdltex, SDL_TEXTURESCALEMODE_FAST);
206               sdl->hw_scale_width, sdl->hw_scale_height);
179207         break;
180      case VIDEO_YUV_MODE_YV12X2:
181         render_target_get_minimum_size(window->target, &sdl->yuv_ovl_width, &sdl->yuv_ovl_height);
182         sdl->yuv_bitmap = malloc_or_die(sdl->yuv_ovl_width * sdl->yuv_ovl_height * sizeof(UINT16));
208      case VIDEO_SCALE_MODE_YV12X2:
209         render_target_get_minimum_size(window->target, &sdl->hw_scale_width, &sdl->hw_scale_height);
210         sdl->yuv_bitmap = malloc_or_die(sdl->hw_scale_width * sdl->hw_scale_height * sizeof(UINT16));
183211         sdl->texture_id = SDL_CreateTexture(SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING,
184               sdl->yuv_ovl_width * 2, sdl->yuv_ovl_height * 2);
212               sdl->hw_scale_width * 2, sdl->hw_scale_height * 2);
185213         break;
186      case VIDEO_YUV_MODE_YUY2:
187         render_target_get_minimum_size(window->target, &sdl->yuv_ovl_width, &sdl->yuv_ovl_height);
188         sdl->yuv_bitmap = malloc_or_die(sdl->yuv_ovl_width * sdl->yuv_ovl_height * sizeof(UINT16));
214      case VIDEO_SCALE_MODE_YUY2:
215         render_target_get_minimum_size(window->target, &sdl->hw_scale_width, &sdl->hw_scale_height);
216         sdl->yuv_bitmap = malloc_or_die(sdl->hw_scale_width * sdl->hw_scale_height * sizeof(UINT16));
189217         sdl->texture_id = SDL_CreateTexture(SDL_PIXELFORMAT_YUY2, SDL_TEXTUREACCESS_STREAMING,
190               sdl->yuv_ovl_width, sdl->yuv_ovl_height);
218               sdl->hw_scale_width, sdl->hw_scale_height);
191219         break;
192      case VIDEO_YUV_MODE_YUY2X2:
193         render_target_get_minimum_size(window->target, &sdl->yuv_ovl_width, &sdl->yuv_ovl_height);
194         sdl->yuv_bitmap = malloc_or_die(sdl->yuv_ovl_width * sdl->yuv_ovl_height * sizeof(UINT16));
220      case VIDEO_SCALE_MODE_YUY2X2:
221         render_target_get_minimum_size(window->target, &sdl->hw_scale_width, &sdl->hw_scale_height);
222         sdl->yuv_bitmap = malloc_or_die(sdl->hw_scale_width * sdl->hw_scale_height * sizeof(UINT16));
195223         sdl->texture_id = SDL_CreateTexture(SDL_PIXELFORMAT_YUY2, SDL_TEXTUREACCESS_STREAMING,
196               sdl->yuv_ovl_width * 2, sdl->yuv_ovl_height);
224               sdl->hw_scale_width * 2, sdl->hw_scale_height);
197225         break;
198226   }
199227}
r2988r2989
211239
212240   render_target_get_minimum_size(window->target, &minimum_width, &minimum_height);
213241   if (sdl->yuvsurf != NULL)
242   {
214243      SDL_FreeYUVOverlay(sdl->yuvsurf);
244      sdl->yuvsurf = NULL;
245   }
246   
215247   if (sdl->yuv_bitmap != NULL)
216248   {
217249      free(sdl->yuv_bitmap);   
218250   }
219251   sdl->yuv_bitmap = malloc_or_die(minimum_width*minimum_height*sizeof(UINT16));
220252
221   mame_printf_verbose("SDL: Creating YUV-Overlay ...\n");
222   switch (video_config.yuv_mode)
253   mame_printf_verbose("SDL: Creating %d x %d YUV-Overlay ...\n", minimum_width, minimum_height);
254   switch (window->scale_mode)
223255   {
224      case VIDEO_YUV_MODE_YV12:
256      case VIDEO_SCALE_MODE_YV12:
225257         sdl->yuvsurf = SDL_CreateYUVOverlay(minimum_width, minimum_height,
226258                 SDL_YV12_OVERLAY, sdl->sdlsurf);
227259         break;
228      case VIDEO_YUV_MODE_YV12X2:
260      case VIDEO_SCALE_MODE_YV12X2:
229261         sdl->yuvsurf = SDL_CreateYUVOverlay(minimum_width*2, minimum_height*2,
230262                  SDL_YV12_OVERLAY, sdl->sdlsurf);
231263         break;
232      case VIDEO_YUV_MODE_YUY2:
264      case VIDEO_SCALE_MODE_YUY2:
233265         sdl->yuvsurf = SDL_CreateYUVOverlay(minimum_width, minimum_height,
234266                  SDL_YUY2_OVERLAY, sdl->sdlsurf);
235267         break;
236      case VIDEO_YUV_MODE_YUY2X2:
268      case VIDEO_SCALE_MODE_YUY2X2:
237269         sdl->yuvsurf = SDL_CreateYUVOverlay(minimum_width*2, minimum_height,
238270                  SDL_YUY2_OVERLAY, sdl->sdlsurf);
239271         break;
r2988r2989
242274      mame_printf_error("SDL: Couldn't create SDL_yuv_overlay: %s\n", SDL_GetError());
243275      //return 1;
244276   }
245   sdl->yuv_ovl_width = minimum_width;
246   sdl->yuv_ovl_height = minimum_height;
277   sdl->hw_scale_width = minimum_width;
278   sdl->hw_scale_height = minimum_height;
247279
248280   if (!shown_video_info)
249281   {
250      mame_printf_verbose("YUV Mode         : %s\n", yuv_mode_names[video_config.yuv_mode]);
282      mame_printf_verbose("YUV Mode         : %s\n", scale_mode_names[window->scale_mode]);
251283      mame_printf_verbose("YUV Overlay Size : %d x %d\n", minimum_width, minimum_height);
252284      mame_printf_verbose("YUV Acceleration : %s\n", sdl->yuvsurf->hw_overlay ? "Hardware" : "Software");
253285      shown_video_info = 1;
r2988r2989
270302   window->dxdata = sdl;
271303   
272304#if (SDL_VERSION_ATLEAST(1,3,0))
273   window->extra_flags = (window->fullscreen ? 
305   sdl->extra_flags = (window->fullscreen ? 
274306         SDL_WINDOW_BORDERLESS | SDL_WINDOW_INPUT_FOCUS : SDL_WINDOW_RESIZABLE);
275   //FIXME: OpenGL in Software
276   /* the following is a workaround for a bug in SDL 1.3
277    * where creating a renderer will loose keyboard focus
278    * This happens only if one window is present.
279    */
280   window->extra_flags |= SDL_WINDOW_OPENGL;
281307
282308   SDL_SelectVideoDisplay(window->monitor->handle);
283   SDL_SetFullscreenDisplayMode(NULL);   // Use desktop
309
310   if (window->fullscreen && video_config.switchres)
311   {
312      SDL_DisplayMode mode;
313      SDL_GetCurrentDisplayMode(&mode);
314      mode.w = width;
315      mode.h = height;
316      SDL_SetFullscreenDisplayMode(&mode);   // Try to set mode
317   }
318   else
319      SDL_SetFullscreenDisplayMode(NULL);   // Use desktop
320   
284321   window->window_id = SDL_CreateWindow(window->title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
285         width, height, window->extra_flags);
322         width, height, sdl->extra_flags);
286323   SDL_ShowWindow(window->window_id);
287   SDL_SetWindowFullscreen(window->window_id, window->fullscreen);
288324   SDL_RaiseWindow(window->window_id);
289   SDL_GetWindowSize(window->window_id, &window->width, &window->height);
290325   
291326   // create a texture
292327   SDL_CreateRenderer(window->window_id, -1, SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD);
293328    SDL_SelectRenderer(window->window_id);
329   SDL_SetWindowFullscreen(window->window_id, window->fullscreen);
330   SDL_GetWindowSize(window->window_id, &window->width, &window->height);
294331   setup_texture(window, width, height);
295332#else
296   window->extra_flags = (window->fullscreen ?  SDL_FULLSCREEN : SDL_RESIZABLE);
333   sdl->extra_flags = (window->fullscreen ?  SDL_FULLSCREEN : SDL_RESIZABLE);
297334   // create the SDL surface (which creates the window in windowed mode)
298   if (video_config.yuv_mode == VIDEO_YUV_MODE_NONE)
299      window->extra_flags |= SDL_DOUBLEBUF;
335   if (!IS_YUV_MODE(window->scale_mode))
336      sdl->extra_flags |= SDL_DOUBLEBUF;
300337
301338   sdl->sdlsurf = SDL_SetVideoMode(width, height,
302               0, SDL_SWSURFACE | SDL_ANYFORMAT | window->extra_flags);
339               0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags);
303340
304341   if (!sdl->sdlsurf)
305342      return 1;
r2988r2989
307344   window->width = sdl->sdlsurf->w;
308345   window->height = sdl->sdlsurf->h;
309346   
310   if (video_config.yuv_mode != VIDEO_YUV_MODE_NONE)
347   if (IS_YUV_MODE(window->scale_mode))
311348   {
312349      yuv_overlay_init(window);
313350   }
r2988r2989
340377
341378   setup_texture(window, window->width, window->height);
342379#else
380   if (sdl->yuvsurf != NULL)
381   {
382      SDL_FreeYUVOverlay(sdl->yuvsurf);
383      sdl->yuvsurf = NULL;
384   }
343385   SDL_FreeSurface(sdl->sdlsurf);
344386   //printf("SetVideoMode %d %d\n", wp->resize_new_width, wp->resize_new_height);
345387
346388   sdl->sdlsurf = SDL_SetVideoMode(width, height, 0,
347         SDL_SWSURFACE | SDL_ANYFORMAT | window->extra_flags);
389         SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags);
348390   window->width = sdl->sdlsurf->w;
349391   window->height = sdl->sdlsurf->h;
350392
351   if (video_config.yuv_mode != VIDEO_YUV_MODE_NONE)
393   if (IS_YUV_MODE(window->scale_mode))
352394   {
353395      yuv_overlay_init(window);
354396   }
r2988r2989
375417   //SDL_DestroyRenderer(window->window_id);
376418   SDL_DestroyWindow(window->window_id);
377419#else
420   if (sdl->yuvsurf != NULL)
421   {
422      SDL_FreeYUVOverlay(sdl->yuvsurf);
423      sdl->yuvsurf = NULL;
424   }
425
378426   if (sdl->sdlsurf)
379427   {
380428      SDL_FreeSurface(sdl->sdlsurf);
r2988r2989
409457}
410458
411459//============================================================
460//  drawsdl_xy_to_render_target
461//============================================================
462
463static int drawsdl_xy_to_render_target(sdl_window_info *window, int x, int y, int *xt, int *yt)
464{
465   sdl_info *sdl = window->dxdata;
466
467   *xt = x - sdl->last_hofs;
468   *yt = y - sdl->last_vofs;
469   if (*xt<0 || *xt >= window->blitwidth)
470      return 0;
471   if (*yt<0 || *xt >= window->blitheight)
472      return 0;
473   if (window->scale_mode == VIDEO_SCALE_MODE_NONE || (!SDL_VERSION_ATLEAST(1,3,0) && !IS_YUV_MODE(window->scale_mode)))
474   {
475      return 1;
476   }
477   /* Rescale */
478   *xt = (*xt * sdl->hw_scale_width) / window->blitwidth;
479   *yt = (*yt * sdl->hw_scale_height) / window->blitheight;
480   return 1;
481}
482
483//============================================================
412484//  drawsdl_window_get_primitives
413485//============================================================
414486
r2988r2989
423495   {
424496      sdlwindow_blit_surface_size(window, window->monitor->center_width, window->monitor->center_height);
425497   }
426   if (video_config.yuv_mode == VIDEO_YUV_MODE_NONE)
498   if (window->scale_mode == VIDEO_SCALE_MODE_NONE || (!SDL_VERSION_ATLEAST(1,3,0) && !IS_YUV_MODE(window->scale_mode)))
427499      render_target_set_bounds(window->target, window->blitwidth, window->blitheight, sdlvideo_monitor_get_aspect(window->monitor));
428500   else
429      render_target_set_bounds(window->target, sdl->yuv_ovl_width, sdl->yuv_ovl_height, 0);
501      render_target_set_bounds(window->target, sdl->hw_scale_width, sdl->hw_scale_height, 0);
430502   return render_target_get_primitives(window->target);
431503}
432504
r2988r2989
472544   }
473545
474546   
475   if (video_config.yuv_mode != VIDEO_YUV_MODE_NONE)
547   if (IS_YUV_MODE(window->scale_mode))
476548   {
477549      SDL_LockYUVOverlay(sdl->yuvsurf);
478550      surfptr = sdl->yuvsurf->pixels[0]; // (UINT8 *) sdl->yuv_bitmap;
r2988r2989
493565
494566   SDL_LockTexture(sdl->texture_id, NULL, 1, (void **) &surfptr, &pitch);
495567   // Clear if necessary
496   if (video_config.yuv_mode == VIDEO_YUV_MODE_NONE)
568   if (window->scale_mode == VIDEO_SCALE_MODE_NONE)
497569      if (sdl->blittimer > 0)
498570      {   
499571         memset(surfptr, 0, window->height * pitch);
r2988r2989
539611      hofs = (cw - window->blitwidth) / 2;
540612   }
541613
614   sdl->last_hofs = hofs;
615   sdl->last_vofs = vofs;
616   
542617   osd_lock_acquire(window->primlist->lock);
543618
544619   // render to it
545   if (video_config.yuv_mode == VIDEO_YUV_MODE_NONE)
620   if (!IS_YUV_MODE(window->scale_mode))
546621   {
547      surfptr += ((vofs * pitch) + (hofs * bpp));
622      int mamewidth, mameheight;
623     
624      if (window->scale_mode == VIDEO_SCALE_MODE_NONE || !SDL_VERSION_ATLEAST(1,3,0))
625      {
626         mamewidth = blitwidth;
627         mameheight = blitheight;
628         surfptr += ((vofs * pitch) + (hofs * bpp));
629      }
630      else
631      {
632         mamewidth = sdl->hw_scale_width;
633         mameheight = sdl->hw_scale_height;
634      }
548635      switch (rmask)
549636      {
550637         case 0x00ff0000:
551            drawsdl_rgb888_draw_primitives(window->primlist->head, surfptr, blitwidth, blitheight, pitch / 4);
638            drawsdl_rgb888_draw_primitives(window->primlist->head, surfptr, mamewidth, mameheight, pitch / 4);
552639            break;
553640
554641         case 0x000000ff:
555            drawsdl_bgr888_draw_primitives(window->primlist->head, surfptr, blitwidth, blitheight, pitch / 4);
642            drawsdl_bgr888_draw_primitives(window->primlist->head, surfptr, mamewidth, mameheight, pitch / 4);
556643            break;
557644
558645         case 0xf800:
559            drawsdl_rgb565_draw_primitives(window->primlist->head, surfptr, blitwidth, blitheight, pitch / 2);
646            drawsdl_rgb565_draw_primitives(window->primlist->head, surfptr, mamewidth, mameheight, pitch / 2);
560647            break;
561648
562649         case 0x7c00:
563            drawsdl_rgb555_draw_primitives(window->primlist->head, surfptr, blitwidth, blitheight, pitch / 2);
650            drawsdl_rgb555_draw_primitives(window->primlist->head, surfptr, mamewidth, mameheight, pitch / 2);
564651            break;
565652
566653         default:
r2988r2989
572659   {
573660      assert (sdl->yuv_bitmap != NULL);
574661      assert (surfptr != NULL);
575      drawsdl_rgb555_draw_primitives(window->primlist->head, sdl->yuv_bitmap, sdl->yuv_ovl_width, sdl->yuv_ovl_height, sdl->yuv_ovl_width);
576      switch (video_config.yuv_mode)
662      drawsdl_rgb555_draw_primitives(window->primlist->head, sdl->yuv_bitmap, sdl->hw_scale_width, sdl->hw_scale_height, sdl->hw_scale_width);
663      switch (window->scale_mode)
577664      {
578         case VIDEO_YUV_MODE_YV12:
665         case VIDEO_SCALE_MODE_YV12:
579666            yuv_RGB_to_YV12((UINT16 *)sdl->yuv_bitmap, sdl, surfptr, pitch);
580667            break;
581         case VIDEO_YUV_MODE_YV12X2:
668         case VIDEO_SCALE_MODE_YV12X2:
582669            yuv_RGB_to_YV12X2((UINT16 *)sdl->yuv_bitmap, sdl, surfptr, pitch);
583670            break;
584         case VIDEO_YUV_MODE_YUY2:
671         case VIDEO_SCALE_MODE_YUY2:
585672            yuv_RGB_to_YUY2((UINT16 *)sdl->yuv_bitmap, sdl, surfptr, pitch);
586673            break;
587         case VIDEO_YUV_MODE_YUY2X2:
674         case VIDEO_SCALE_MODE_YUY2X2:
588675            yuv_RGB_to_YUY2X2((UINT16 *)sdl->yuv_bitmap, sdl, surfptr, pitch);
589676            break;
590677      }
r2988r2989
595682   // unlock and flip
596683#if (!SDL_VERSION_ATLEAST(1,3,0))
597684   if (SDL_MUSTLOCK(sdl->sdlsurf)) SDL_UnlockSurface(sdl->sdlsurf);
598   if (video_config.yuv_mode == VIDEO_YUV_MODE_NONE)
685   if (!IS_YUV_MODE(window->scale_mode))
599686   {
600687      SDL_Flip(sdl->sdlsurf);
601688   }
r2988r2989
612699   }
613700#else
614701   SDL_UnlockTexture(sdl->texture_id);
615   if (video_config.yuv_mode == VIDEO_YUV_MODE_NONE)
702   if (window->scale_mode == VIDEO_SCALE_MODE_NONE)
616703   {
617704      //SDL_UpdateTexture(sdl->sdltex, NULL, sdl->sdlsurf->pixels, pitch);
618705      SDL_RenderCopy(sdl->texture_id, NULL, NULL);
r2988r2989
764851   int u1,v1,y1,u2,v2,y2,u3,v3,y3,u4,v4,y4;     /* 12 */
765852   
766853   pixels[0] = ptr;
767   pixels[1] = ptr + pitch * sdl->yuv_ovl_height;
768   pixels[2] = pixels[1] + pitch * sdl->yuv_ovl_height / 4;
854   pixels[1] = ptr + pitch * sdl->hw_scale_height;
855   pixels[2] = pixels[1] + pitch * sdl->hw_scale_height / 4;
769856     
770   for(y=0;y<sdl->yuv_ovl_height;y+=2)
857   for(y=0;y<sdl->hw_scale_height;y+=2)
771858   {
772      src=bitmap + (y * sdl->yuv_ovl_width) ;
773      src2=src + sdl->yuv_ovl_width;
859      src=bitmap + (y * sdl->hw_scale_width) ;
860      src2=src + sdl->hw_scale_width;
774861
775862      dest_y = pixels[0] + y * pitch;
776863      dest_v = pixels[1] + (y>>1) * pitch / 2;
777864      dest_u = pixels[2] + (y>>1) * pitch / 2;
778865
779      for(x=0;x<sdl->yuv_ovl_width;x+=2)
866      for(x=0;x<sdl->hw_scale_width;x+=2)
780867      {
781868         v1 = lookup[src[x]];
782869         y1 = (v1>>Y1SHIFT) & 0xff;
r2988r2989
822909   UINT8 *pixels[3];
823910
824911   pixels[0] = ptr;
825   pixels[1] = ptr + pitch * sdl->yuv_ovl_height * 2;
826   pixels[2] = pixels[1] + pitch * sdl->yuv_ovl_height / 2;
912   pixels[1] = ptr + pitch * sdl->hw_scale_height * 2;
913   pixels[2] = pixels[1] + pitch * sdl->hw_scale_height / 2;
827914
828   for(y=0;y<sdl->yuv_ovl_height;y++)
915   for(y=0;y<sdl->hw_scale_height;y++)
829916   {
830      src = bitmap + (y * sdl->yuv_ovl_width) ;
917      src = bitmap + (y * sdl->hw_scale_width) ;
831918
832919      dest_y = (UINT16 *)(pixels[0] + 2 * y * pitch);
833920      dest_v = pixels[1] + y * pitch / 2;
834921      dest_u = pixels[2] + y * pitch / 2;
835      for(x=0;x<sdl->yuv_ovl_width;x++)
922      for(x=0;x<sdl->hw_scale_width;x++)
836923      {
837924         v1 = sdl->yuv_lookup[src[x]];
838925         y1 = (v1 >> Y1SHIFT) & 0xff;
r2988r2989
858945   UINT32 *lookup = sdl->yuv_lookup;
859946   int yuv_pitch = pitch/4;
860947
861   for(y=0;y<sdl->yuv_ovl_height;y++)
948   for(y=0;y<sdl->hw_scale_height;y++)
862949   {
863      src=bitmap + (y * sdl->yuv_ovl_width) ;
864      end=src+sdl->yuv_ovl_width;
950      src=bitmap + (y * sdl->hw_scale_width) ;
951      end=src+sdl->hw_scale_width;
865952
866953      dest = (UINT32 *) ptr;
867954      dest += y * yuv_pitch;
r2988r2989
886973   UINT32 *lookup = sdl->yuv_lookup;
887974   int yuv_pitch = pitch / 4;
888975
889   for(y=0;y<sdl->yuv_ovl_height;y++)
976   for(y=0;y<sdl->hw_scale_height;y++)
890977   {
891      src=bitmap + (y * sdl->yuv_ovl_width) ;
892      end=src+sdl->yuv_ovl_width;
978      src=bitmap + (y * sdl->hw_scale_width) ;
979      end=src+sdl->hw_scale_width;
893980
894981      dest = (UINT32 *) ptr;
895982      dest += (y * yuv_pitch);
src/osd/sdl/input.h
r2988r2989
99//
1010//============================================================
1111
12#ifndef __INPUT_H
13#define __INPUT_H
12#ifndef __SDLINPUT_H__
13#define __SDLINPUT_H__
1414
1515#include "window.h"
1616
r2988r2989
2626
2727void  sdlinput_process_events_buf(running_machine *machine);
2828
29#endif /* __INPUT_H */
29#endif /* __SDLINPUT_H__ */
src/osd/sdl/debugwin.c
r2988r2989
388388
389389// The entry point
390390
391void osd_wait_for_debugger(void)
391void osd_wait_for_debugger(running_machine *machine, int firststop)
392392{
393393   // create a console window
394394   if(!dmain) {
r2988r2989
398398   }
399399
400400   // update the views in the console to reflect the current CPU
401   debugmain_set_cpunum(Machine, cpu_getactivecpu());
401   debugmain_set_cpunum(machine, cpu_getactivecpu());
402402
403403   debugwin_show(1);
404404   gtk_main_iteration();
src/osd/sdl/os2work.c
r2988r2989
673673    ULONG numprocs = 0;
674674
675675    // if the OSDPROCESSORS environment variable is set, use that value if valid
676    procsoverride = getenv("OSDPROCESSORS");
676    procsoverride = getenv(SDLENV_PROCESSORS);
677677    if (procsoverride != NULL && sscanf(procsoverride, "%lu", &numprocs) == 1 && numprocs > 0)
678678        return numprocs;
679679
src/osd/sdl/video.c
r2988r2989
4949#include "video.h"
5050#include "window.h"
5151#include "input.h"
52#include "uiinput.h"
5253
5354#include "osdsdl.h"
5455
5556#include "osd_opengl.h"
5657
57#include "uiinput.h"
58
5958#ifdef MESS
6059#include "menu.h"
6160#endif
r2988r2989
6463//  CONSTANTS
6564//============================================================
6665
67// refresh rate while paused
68#define PAUSED_REFRESH_RATE         (60)
6966
70
7167//============================================================
7268//  GLOBAL VARIABLES
7369//============================================================
r2988r2989
178174}
179175
180176
177//============================================================
178//  get_modes - code take from SDL_Compat
179//============================================================
181180
181#if (SDL_VERSION_ATLEAST(1,3,0))
182static SDL_Rect **get_current_display_modes(void)
183{
184   /* Get modes for current select display */
185    int i, nmodes;
186    SDL_Rect **modes;
187
188    /* Memory leak, but this is a compatibility function, who cares? */
189    nmodes = 0;
190    modes = NULL;
191    for (i = 0; i < SDL_GetNumDisplayModes(); ++i) {
192        SDL_DisplayMode mode;
193        SDL_GetDisplayMode(i, &mode);
194        if (!mode.w || !mode.h) {
195            return (SDL_Rect **) (NULL);
196        }
197        // FIXME: refresh rates
198        if (nmodes > 0 && modes[nmodes - 1]->w == mode.w
199            && modes[nmodes - 1]->h == mode.h) {
200            continue;
201        }
202
203        modes = SDL_realloc(modes, (nmodes + 2) * sizeof(*modes));
204        if (!modes) {
205            return NULL;
206        }
207        modes[nmodes] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect));
208        if (!modes[nmodes]) {
209            return NULL;
210        }
211        modes[nmodes]->x = 0;
212        modes[nmodes]->y = 0;
213        modes[nmodes]->w = mode.w;
214        modes[nmodes]->h = mode.h;
215        mame_printf_verbose("Display mode #%d - %d x %d\n", nmodes, mode.w, mode.h);
216        ++nmodes;
217    }
218    if (modes) {
219        modes[nmodes] = NULL;
220    }
221    return modes;
222}
223#endif
224
225
226
182227//============================================================
183228//  sdlvideo_monitor_refresh
184229//============================================================
185230
186231void sdlvideo_monitor_refresh(sdl_monitor_info *monitor)
187232{
188   #if defined(SDLMAME_WIN32)   // Win32 version
189   MONITORINFOEX info;
190   info.cbSize = sizeof(info);   
191    GetMonitorInfo((HMONITOR)monitor->handle, (LPMONITORINFO)&info);
192   monitor->center_width = monitor->monitor_width = info.rcMonitor.right - info.rcMonitor.left;
193   monitor->center_height = monitor->monitor_height = info.rcMonitor.bottom - info.rcMonitor.top;
194   strcpy(monitor->monitor_device, info.szDevice);
195   #elif (SDL_VERSION_ATLEAST(1,3,0))
233   #if (SDL_VERSION_ATLEAST(1,3,0))
196234   SDL_DisplayMode dmode;
197235   
198236   SDL_SelectVideoDisplay(monitor->handle);
r2988r2989
201239   monitor->monitor_height = dmode.h;
202240   monitor->center_width = dmode.w;
203241   monitor->center_height = dmode.h;
242   #else
243   #if defined(SDLMAME_WIN32)   // Win32 version
244   MONITORINFOEX info;
245   info.cbSize = sizeof(info);   
246    GetMonitorInfo((HMONITOR)monitor->handle, (LPMONITORINFO)&info);
247   monitor->center_width = monitor->monitor_width = info.rcMonitor.right - info.rcMonitor.left;
248   monitor->center_height = monitor->monitor_height = info.rcMonitor.bottom - info.rcMonitor.top;
249   strcpy(monitor->monitor_device, info.szDevice);
204250   #elif defined(SDLMAME_MACOSX)   // Mac OS X Core Imaging version
205251   CGDirectDisplayID primary;
206252   CGRect dbounds;
r2988r2989
295341   #endif
296342
297343   {
298      //FIXME: Code not really suitable for multiple monitors
299344      static int info_shown=0;
300345      if (!info_shown)
301346      {
r2988r2989
304349         info_shown = 1;
305350      }
306351   }
352   #endif //  (SDL_VERSION_ATLEAST(1,3,0))
307353}
308354
309355
r2988r2989
340386   return NULL;
341387}
342388
389
343390//============================================================
344391//  osd_update
345392//============================================================
r2988r2989
365412      debugwin_update_during_game();
366413}
367414
415
368416//============================================================
369417//  add_primary_monitor
370418//============================================================
419
371420#if !defined(SDLMAME_WIN32) && !(SDL_VERSION_ATLEAST(1,3,0))
372421static void add_primary_monitor(void *data)
373422{
r2988r2989
395444}
396445#endif
397446
447
398448//============================================================
399449//  monitor_enum_callback
400450//============================================================
451
401452#ifdef SDLMAME_WIN32
402453static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data)
403454{
r2988r2989
437488}
438489#endif
439490
491
440492//============================================================
441493//  init_monitors
442494//============================================================
r2988r2989
451503
452504   #ifdef SDLMAME_WIN32
453505   EnumDisplayMonitors(NULL, NULL, monitor_enum_callback, (LPARAM)&tailptr);
506   monitor->modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_DOUBLEBUF);
454507   #elif (SDL_VERSION_ATLEAST(1,3,0))
455508   {
456      int i;
509      int i, temp;
457510
511      temp = SDL_GetCurrentVideoDisplay();
512
458513      for (i = 0; i < SDL_GetNumVideoDisplays(); i++)
459514      {
460515         sdl_monitor_info *monitor;
r2988r2989
466521
467522         snprintf(monitor->monitor_device, sizeof(monitor->monitor_device)-1, "%s%d", SDLOPTION_SCREEN(""),i);
468523       
524         SDL_SelectVideoDisplay(i);
469525         SDL_GetDesktopDisplayMode(&dmode);
470526         monitor->monitor_width = dmode.w;
471527         monitor->monitor_height = dmode.h;
r2988r2989
475531           // guess the aspect ratio assuming square pixels
476532           monitor->aspect = (float)(dmode.w) / (float)(dmode.h);
477533           mame_printf_verbose("Adding monitor %s (%d x %d)\n", monitor->monitor_device, dmode.w, dmode.h);
534
535           monitor->modes = get_current_display_modes();
478536           
479537           // save the primary monitor handle
480538           if (i == 0)
r2988r2989
484542         *tailptr = monitor;
485543         tailptr = &monitor->next;
486544      }
545      SDL_SelectVideoDisplay(temp);
487546   }
488547   #else
489548   add_primary_monitor((void *)&tailptr);
549   sdl_monitor_list->modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_DOUBLEBUF);
490550   #endif
491551}
492552
553
493554//============================================================
494555//  pick_monitor
495556//============================================================
r2988r2989
558619}
559620#endif
560621
622
561623//============================================================
562624//  check_osd_inputs
563625//============================================================
r2988r2989
572634   
573635   if (ui_input_pressed(machine, IPT_OSD_2))
574636   {
637      //FIXME: on a per window basis
575638      video_config.fullstretch = !video_config.fullstretch;
576639      ui_popup_time(1, "Uneven stretch %s", video_config.fullstretch? "enabled":"disabled");
577640   }
578641   
579642   if (ui_input_pressed(machine, IPT_OSD_4))
580643   {
644      //FIXME: on a per window basis
581645      video_config.keepaspect = !video_config.keepaspect;
582646      ui_popup_time(1, "Keepaspect %s", video_config.keepaspect? "enabled":"disabled");
583647   }
584648   
585649   if (USE_OPENGL)
586650   {
651      //FIXME: on a per window basis
587652      if (ui_input_pressed(machine, IPT_OSD_5))
588653      {
589654         video_config.filter = !video_config.filter;
r2988r2989
608673}
609674
610675
611
612676//============================================================
613677//  extract_video_config
614678//============================================================
r2988r2989
674738   video_config.centerh       = options_get_bool(mame_options(), SDLOPTION_CENTERH);
675739   video_config.centerv       = options_get_bool(mame_options(), SDLOPTION_CENTERV);
676740
677#if USE_OPENGL
678   video_config.prescale      = options_get_int(mame_options(), SDLOPTION_PRESCALE);
679   if (video_config.prescale < 1 || video_config.prescale > 3)
741   if (USE_OPENGL)
680742   {
681      mame_printf_warning("Invalid prescale option, reverting to '1'\n");
682      video_config.prescale = 1;
683   }
684   // default to working video please
685   video_config.prefer16bpp_tex = 0;
686   video_config.filter        = options_get_bool(mame_options(), SDLOPTION_FILTER);
687   video_config.forcepow2texture = options_get_bool(mame_options(), SDLOPTION_GL_FORCEPOW2TEXTURE)==1;
688   video_config.allowtexturerect = options_get_bool(mame_options(), SDLOPTION_GL_NOTEXTURERECT)==0;
689   video_config.vbo         = options_get_bool(mame_options(), SDLOPTION_GL_VBO);
690   video_config.pbo         = options_get_bool(mame_options(), SDLOPTION_GL_PBO);
691   video_config.glsl        = options_get_bool(mame_options(), SDLOPTION_GL_GLSL);
692   if ( video_config.glsl )
693   {
694      int i;
695      static char buffer[20]; // gl_glsl_filter[0..9]?
696
697      video_config.glsl_filter = options_get_int (mame_options(), SDLOPTION_GLSL_FILTER);
698
699      video_config.glsl_shader_mamebm_num=0;
700
701      for(i=0; i<GLSL_SHADER_MAX; i++)
743      video_config.prescale      = options_get_int(mame_options(), SDLOPTION_PRESCALE);
744      if (video_config.prescale < 1 || video_config.prescale > 3)
702745      {
703         snprintf(buffer, 18, SDLOPTION_SHADER_MAME("%d"), i); buffer[17]=0;
704
705         stemp = options_get_string(mame_options(), buffer);
706         if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0)
746         mame_printf_warning("Invalid prescale option, reverting to '1'\n");
747         video_config.prescale = 1;
748      }
749      // default to working video please
750      video_config.prefer16bpp_tex = 0;
751      video_config.filter        = options_get_bool(mame_options(), SDLOPTION_FILTER);
752      video_config.forcepow2texture = options_get_bool(mame_options(), SDLOPTION_GL_FORCEPOW2TEXTURE)==1;
753      video_config.allowtexturerect = options_get_bool(mame_options(), SDLOPTION_GL_NOTEXTURERECT)==0;
754      video_config.vbo         = options_get_bool(mame_options(), SDLOPTION_GL_VBO);
755      video_config.pbo         = options_get_bool(mame_options(), SDLOPTION_GL_PBO);
756      video_config.glsl        = options_get_bool(mame_options(), SDLOPTION_GL_GLSL);
757      if ( video_config.glsl )
758      {
759         int i;
760         static char buffer[20]; // gl_glsl_filter[0..9]?
761   
762         video_config.glsl_filter = options_get_int (mame_options(), SDLOPTION_GLSL_FILTER);
763   
764         video_config.glsl_shader_mamebm_num=0;
765   
766         for(i=0; i<GLSL_SHADER_MAX; i++)
707767         {
708            video_config.glsl_shader_mamebm[i] = (char *) malloc(strlen(stemp)+1);
709            strcpy(video_config.glsl_shader_mamebm[i], stemp);
710            video_config.glsl_shader_mamebm_num++;
711         } else {
768            snprintf(buffer, 18, SDLOPTION_SHADER_MAME("%d"), i); buffer[17]=0;
769   
770            stemp = options_get_string(mame_options(), buffer);
771            if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0)
772            {
773               video_config.glsl_shader_mamebm[i] = (char *) malloc(strlen(stemp)+1);
774               strcpy(video_config.glsl_shader_mamebm[i], stemp);
775               video_config.glsl_shader_mamebm_num++;
776            } else {
777               video_config.glsl_shader_mamebm[i] = NULL;
778            }
779         }
780   
781         video_config.glsl_shader_scrn_num=0;
782   
783         for(i=0; i<GLSL_SHADER_MAX; i++)
784         {
785            snprintf(buffer, 20, SDLOPTION_SHADER_SCREEN("%d"), i); buffer[19]=0;
786   
787            stemp = options_get_string(mame_options(), buffer);
788            if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0)
789            {
790               video_config.glsl_shader_scrn[i] = (char *) malloc(strlen(stemp)+1);
791               strcpy(video_config.glsl_shader_scrn[i], stemp);
792               video_config.glsl_shader_scrn_num++;
793            } else {
794               video_config.glsl_shader_scrn[i] = NULL;
795            }
796         }
797   
798         video_config.glsl_vid_attributes = options_get_int (mame_options(), SDLOPTION_GL_GLSL_VID_ATTR);
799         {
800            // Disable feature: glsl_vid_attributes, as long we have the gamma calculation
801            // disabled within the direct shaders .. -> too slow.
802            // IMHO the gamma setting should be done global anyways, and for the whole system,
803            // not just MAME ..
804            float gamma = options_get_float(mame_options(), OPTION_GAMMA);
805            if (gamma != 1.0 && video_config.glsl_vid_attributes && video_config.glsl)
806            {
807               video_config.glsl_vid_attributes = FALSE;
808               mame_printf_warning("OpenGL: GLSL - disable handling of brightness and contrast, gamma is set to %f\n", gamma);
809            }
810         }
811      } else {
812         int i;
813         video_config.glsl_filter = 0;
814         video_config.glsl_shader_mamebm_num=0;
815         for(i=0; i<GLSL_SHADER_MAX; i++)
816         {
712817            video_config.glsl_shader_mamebm[i] = NULL;
713818         }
714      }
715
716      video_config.glsl_shader_scrn_num=0;
717
718      for(i=0; i<GLSL_SHADER_MAX; i++)
719      {
720         snprintf(buffer, 20, SDLOPTION_SHADER_SCREEN("%d"), i); buffer[19]=0;
721
722         stemp = options_get_string(mame_options(), buffer);
723         if (stemp && strcmp(stemp, SDLOPTVAL_NONE) != 0 && strlen(stemp)>0)
819         video_config.glsl_shader_scrn_num=0;
820         for(i=0; i<GLSL_SHADER_MAX; i++)
724821         {
725            video_config.glsl_shader_scrn[i] = (char *) malloc(strlen(stemp)+1);
726            strcpy(video_config.glsl_shader_scrn[i], stemp);
727            video_config.glsl_shader_scrn_num++;
728         } else {
729822            video_config.glsl_shader_scrn[i] = NULL;
730823         }
824         video_config.glsl_vid_attributes = 0;
731825      }
732
733      video_config.glsl_vid_attributes = options_get_int (mame_options(), SDLOPTION_GL_GLSL_VID_ATTR);
734      {
735         // Disable feature: glsl_vid_attributes, as long we have the gamma calculation
736         // disabled within the direct shaders .. -> too slow.
737         // IMHO the gamma setting should be done global anyways, and for the whole system,
738         // not just MAME ..
739         float gamma = options_get_float(mame_options(), OPTION_GAMMA);
740         if (gamma != 1.0 && video_config.glsl_vid_attributes && video_config.glsl)
741         {
742            video_config.glsl_vid_attributes = FALSE;
743            mame_printf_warning("OpenGL: GLSL - disable handling of brightness and contrast, gamma is set to %f\n", gamma);
744         }
745      }
746   } else {
747      int i;
748      video_config.glsl_filter = 0;
749      video_config.glsl_shader_mamebm_num=0;
750      for(i=0; i<GLSL_SHADER_MAX; i++)
751      {
752         video_config.glsl_shader_mamebm[i] = NULL;
753      }
754      video_config.glsl_shader_scrn_num=0;
755      for(i=0; i<GLSL_SHADER_MAX; i++)
756      {
757         video_config.glsl_shader_scrn[i] = NULL;
758      }
759      video_config.glsl_vid_attributes = 0;
826   
827      if (sdl_use_unsupported())
828         video_config.prescale_effect = options_get_int(mame_options(), SDLOPTION_PRESCALE_EFFECT);
829      else
830         video_config.prescale_effect = 0;
760831   }
761
762   if (sdl_use_unsupported())
763      video_config.prescale_effect = options_get_int(mame_options(), SDLOPTION_PRESCALE_EFFECT);
764   else
765      video_config.prescale_effect = 0;
766#endif
767832   // misc options: sanity check values
768833
769834   // global options: sanity check values
r2988r2989
781846   }
782847#endif
783848   // yuv settings ...
784   stemp = options_get_string(mame_options(), SDLOPTION_YUVMODE);
849   stemp = options_get_string(mame_options(), SDLOPTION_SCALEMODE);
785850   if (strcmp(stemp, SDLOPTVAL_NONE) == 0)
786      video_config.yuv_mode = VIDEO_YUV_MODE_NONE;
851      video_config.scale_mode = VIDEO_SCALE_MODE_NONE;
852   else if (strcmp(stemp, SDLOPTVAL_HWBLIT) == 0)
853      video_config.scale_mode = VIDEO_SCALE_MODE_HWBLIT;
787854   else if (strcmp(stemp, SDLOPTVAL_YV12) == 0)
788      video_config.yuv_mode = VIDEO_YUV_MODE_YV12;
855      video_config.scale_mode = VIDEO_SCALE_MODE_YV12;
789856   else if (strcmp(stemp, SDLOPTVAL_YV12x2) == 0)
790      video_config.yuv_mode = VIDEO_YUV_MODE_YV12X2;
857      video_config.scale_mode = VIDEO_SCALE_MODE_YV12X2;
791858   else if (strcmp(stemp, SDLOPTVAL_YUY2) == 0)
792      video_config.yuv_mode = VIDEO_YUV_MODE_YUY2;
859      video_config.scale_mode = VIDEO_SCALE_MODE_YUY2;
793860   else if (strcmp(stemp, SDLOPTVAL_YUY2x2) == 0)
794      video_config.yuv_mode = VIDEO_YUV_MODE_YUY2X2;
861      video_config.scale_mode = VIDEO_SCALE_MODE_YUY2X2;
795862   else
796863   {
797864      mame_printf_warning("Invalid yuvmode value %s; reverting to none\n", stemp);
798      video_config.yuv_mode = VIDEO_YUV_MODE_NONE;
865      video_config.scale_mode = VIDEO_SCALE_MODE_NONE;
799866   }
800   if ( (video_config.mode != VIDEO_MODE_SOFT) && (video_config.yuv_mode != VIDEO_YUV_MODE_NONE) )
867   if ( (video_config.mode != VIDEO_MODE_SOFT) && (video_config.scale_mode != VIDEO_SCALE_MODE_NONE) )
801868   {
802      mame_printf_warning("yuvmode is only for -video soft, overriding\n");
803      video_config.yuv_mode = VIDEO_YUV_MODE_NONE;
869      mame_printf_warning("scalemode is only for -video soft, overriding\n");
870      video_config.scale_mode = VIDEO_SCALE_MODE_NONE;
804871   }
872   if ( !SDL_VERSION_ATLEAST(1,3,0) && (video_config.mode == VIDEO_MODE_SOFT) && (video_config.scale_mode == VIDEO_SCALE_MODE_HWBLIT) )
873   {
874      mame_printf_warning("scalemode 'hwblit' treated like 'none' in SDL1.2\n");
875   }
805876}
806877
807878
r2988r2989
861932}
862933
863934
864
865935//============================================================
866936//  get_resolution
867937//============================================================
src/osd/sdl/window.c
r2988r2989
5252#define WINDOW_DECORATION_WIDTH   (8)   // should be more than plenty
5353#define WINDOW_DECORATION_HEIGHT (48)   // title bar + bottom drag region
5454
55#if 1
55#ifdef MAME_DEBUG
5656#define ASSERT_USE(x)   assert_always(SDL_ThreadID() == x, "Wrong Thread")
57//#define ASSERT_USE(x)
5857#else
59#define ASSERT_USE(x)   assert(SDL_ThreadID() == x)
58#define ASSERT_USE(x)   do {} while (0)
59//#define ASSERT_USE(x)   assert(SDL_ThreadID() == x)
6060#endif
6161
6262#define ASSERT_REDRAW_THREAD()    ASSERT_USE(window_threadid)
r2988r2989
7979#define WMSZ_RIGHT      (7)
8080#endif
8181
82
8283//============================================================
8384//  GLOBAL VARIABLES
8485//============================================================
r2988r2989
9899static int main_threadid;
99100static int window_threadid;
100101
101static const char *yuv_mode_names[] = { "none", "yv12", "yv12x2", "yuy2", "yuy2x2" };
102static const char *scale_mode_names[] = { "none", "hwblit", "yv12", "yv12x2", "yuy2", "yuy2x2" };
102103
104
103105// debugger
104106//static int in_background;
105107
106static sdl_draw_callbacks draw;
108static sdl_draw_info draw;
107109
108110typedef struct _worker_param worker_param;
109111struct _worker_param {
r2988r2989
148150   wp->resize_new_height=0;
149151}
150152
153
151154//============================================================
152155//  execute_async
153156//============================================================
154157
158
155159INLINE void execute_async(osd_work_callback callback, worker_param *wp)
156160{
157161   worker_param *wp_temp = NULL;
r2988r2989
168172      callback((void *) wp_temp, 0);
169173}
170174
175
171176//============================================================
172177//  execute_async_wait
173178//============================================================
r2988r2989
178183   sdlwindow_sync();
179184}
180185
186
181187//============================================================
182188//  sdlwindow_thread_id
183189//  (window thread)
r2988r2989
198204   return NULL;
199205}
200206
207
201208//============================================================
202209//  win_init_window
203210//  (main thread)
r2988r2989
267274   }
268275}
269276
277
270278//============================================================
271279//  sdlwindow_exit
272280//  (main thread)
r2988r2989
281289   return NULL;
282290}
283291
292
284293static void sdlwindow_exit(running_machine *machine)
285294{
286295   ASSERT_MAIN_THREAD();
r2988r2989
312321
313322}
314323
324
315325//============================================================
316326//  sdlwindow_blit_surface_size
317327//============================================================
r2988r2989
343353      desired_aspect = (float)target_width / (float)target_height;
344354   }
345355
346        // non-integer scaling - often gives more pleasing results in full screen
347        if (!video_config.fullstretch)
356    // non-integer scaling - often gives more pleasing results in full screen
357    if (!video_config.fullstretch)
348358   {
349359      // compute maximum integral scaling to fit the window
350360      xscale = (target_width + 2) / newwidth;
r2988r2989
391401   }
392402
393403   if ((render_target_get_layer_config(window->target) & LAYER_CONFIG_ZOOM_TO_SCREEN)
394      && video_config.yuv_mode == VIDEO_YUV_MODE_NONE)
404      && (window->scale_mode == VIDEO_SCALE_MODE_NONE || (!SDL_VERSION_ATLEAST(1,3,0) && !IS_YUV_MODE(window->scale_mode))))
395405      newwidth = window_width;
396406
397407   if ((window->blitwidth != newwidth) || (window->blitheight != newheight))
r2988r2989
414424
415425   ASSERT_WINDOW_THREAD();
416426   
417   draw.window_destroy_all_textures(window);
418   draw.window_resize(window, wp->resize_new_width, wp->resize_new_height);
427   window->destroy_all_textures(window);
428   window->resize(window, wp->resize_new_width, wp->resize_new_height);
419429
420430   sdlwindow_blit_surface_size(window, wp->resize_new_width, wp->resize_new_height);
421431   
r2988r2989
442452   execute_async_wait(&sdlwindow_resize_wt, &wp);
443453}
444454
455
445456//============================================================
446457//  sdlwindow_clear_surface
447458//  (window thread)
r2988r2989
454465
455466   ASSERT_WINDOW_THREAD();
456467
457   draw.window_clear(window);
468   window->clear(window);
458469   free(wp);
459470   return NULL;
460471}
r2988r2989
475486      sdlwindow_clear_surface_wt( (void *) wp, 0);
476487}
477488
489
478490//============================================================
479491//  sdlwindow_toggle_full_screen
480492//  (main thread)
r2988r2989
498510      window->windowed_height = window->height;
499511   }
500512
501   (*draw.window_destroy)(window);
513   window->destroy(window);
502514
503515   // toggle the window mode
504516   window->fullscreen = !window->fullscreen;   
r2988r2989
517529   clear_worker_param(&wp);
518530   wp.window = window;
519531   
532   //FIMXE: Reset Key state ....
520533   execute_async_wait(&sdlwindow_toggle_full_screen_wt, &wp);
521534}
522535
523static void sdlwindow_modify_yuv(running_machine *machine, int dir)
536static void sdlwindow_modify_yuv(running_machine *machine, sdl_window_info *window, int dir)
524537{
525   int new_yuv_mode = video_config.yuv_mode;
526   sdl_window_info *window = sdlinput_get_focus_window(machine);
538   int new_scale_mode = window->scale_mode;
527539
528   if (dir > 0 && video_config.yuv_mode < VIDEO_YUV_MODE_MAX)
529      new_yuv_mode = video_config.yuv_mode + 1;
530   if (dir < 0 && video_config.yuv_mode > VIDEO_YUV_MODE_MIN)
531      new_yuv_mode = video_config.yuv_mode - 1;
540   if (dir > 0 && window->scale_mode < VIDEO_SCALE_MODE_MAX)
541      new_scale_mode = window->scale_mode + 1;
542   if (dir < 0 && window->scale_mode > VIDEO_SCALE_MODE_MIN)
543      new_scale_mode = window->scale_mode - 1;
532544   
533   if (new_yuv_mode != video_config.yuv_mode)
545   // FIXME: Changing to yv12 mode from video_mode none does not work
546   if (new_scale_mode != window->scale_mode)
534547   {
535548      worker_param wp;
536549
537550      clear_worker_param(&wp);
538551      wp.window = window;
552      sdlwindow_sync();
539553      execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp);
540554         
541      video_config.yuv_mode = new_yuv_mode;
555      window->scale_mode = new_scale_mode;
542556      execute_async_wait(&complete_create_wt, &wp);
557      sdlwindow_sync();
543558
544      ui_popup_time(1, "YUV mode %s", yuv_mode_names[video_config.yuv_mode]);
559      ui_popup_time(1, "YUV mode %s", scale_mode_names[window->scale_mode]);
560      mame_printf_verbose("YUV mode %s\n", scale_mode_names[window->scale_mode]);
545561   }
546562}
547563
r2988r2989
551567
552568   sdl_window_info *window = wp->window;
553569
554   draw.window_destroy_all_textures(window);
570   window->destroy_all_textures(window);
555571
556572   free(wp);
557573   return NULL;
r2988r2989
560576void sdlwindow_modify_prescale(running_machine *machine, sdl_window_info *window, int dir)
561577{
562578   worker_param wp;
563   int new_prescale = video_config.prescale;
579   int new_prescale = window->prescale;
564580
565581   clear_worker_param(&wp);
566582
567583   wp.window = window;
568584
569   if (dir > 0 && video_config.prescale < 3)
570      new_prescale = video_config.prescale + 1;
571   if (dir < 0 && video_config.prescale > 1)
572      new_prescale = video_config.prescale - 1;
585   if (dir > 0 && window->prescale < 3)
586      new_prescale = window->prescale + 1;
587   if (dir < 0 && window->prescale > 1)
588      new_prescale = window->prescale - 1;
573589   
574   if (new_prescale != video_config.prescale)
590   if (new_prescale != window->prescale)
575591   {
576592      if (window->fullscreen && video_config.switchres)
577593      {
578594         execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp);
579595         
580         video_config.prescale = new_prescale;
596         window->prescale = new_prescale;
581597
582598         execute_async_wait(&complete_create_wt, &wp);
583599
r2988r2989
585601      else
586602      {
587603         execute_async_wait(destroy_all_textures_wt, &wp);
588         video_config.prescale = new_prescale;
604         window->prescale = new_prescale;
589605      }
590      ui_popup_time(1, "Prescale %d", video_config.prescale);
606      ui_popup_time(1, "Prescale %d", window->prescale);
591607   }
592608}
593609
r2988r2989
596612
597613   if (video_config.mode == VIDEO_MODE_SOFT)
598614   {
599      sdlwindow_modify_yuv(machine, dir);
615      sdlwindow_modify_yuv(machine, window, dir);
600616      return;
601617   }
602#if USE_OPENGL
603   else
618   else if (USE_OPENGL)
604619   {
605      int new_prescale_effect = video_config.prescale_effect;
620      int new_prescale_effect = window->prescale_effect;
606621      const char *effect_names[] = { "none", "scale2x" };
607622
608      if (dir > 0 && video_config.prescale_effect < 1)
609         new_prescale_effect = video_config.prescale_effect + 1;
610      if (dir < 0 && video_config.prescale_effect > 0)
611         new_prescale_effect = video_config.prescale_effect - 1;
623      if (dir > 0 && window->prescale_effect < 1)
624         new_prescale_effect = window->prescale_effect + 1;
625      if (dir < 0 && window->prescale_effect > 0)
626         new_prescale_effect = window->prescale_effect - 1;
612627     
613      if (new_prescale_effect != video_config.prescale_effect)
628      if (new_prescale_effect != window->prescale_effect)
614629      {
615630         worker_param wp;
616631
r2988r2989
618633         wp.window = window;
619634         execute_async_wait(destroy_all_textures_wt, &wp);
620635
621         video_config.prescale_effect = new_prescale_effect;
622         ui_popup_time(1, "Effect: %s", effect_names[video_config.prescale_effect]);
636         window->prescale_effect = new_prescale_effect;
637         ui_popup_time(1, "Effect: %s", effect_names[window->prescale_effect]);
623638      }
624639   }
625#endif
626640}
627641
628642void sdlwindow_toggle_draw(running_machine *machine, sdl_window_info *window)
r2988r2989
642656   wp.window = window;
643657   execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp);
644658
645   video_config.yuv_mode = VIDEO_YUV_MODE_NONE;
659   window->scale_mode = VIDEO_SCALE_MODE_NONE;
646660
647661   if (video_config.mode == VIDEO_MODE_OPENGL)
648662   {
r2988r2989
661675#endif
662676}
663677
678
664679//============================================================
665680//  sdlwindow_update_cursor_state
666681//  (main or window thread)
r2988r2989
669684static void sdlwindow_update_cursor_state(running_machine *machine, sdl_window_info *window)
670685{
671686#if (SDL_VERSION_ATLEAST(1,3,0))
687   // FIXME: belongs into callback
672688   // do not do mouse capture if the debugger's enabled to avoid
673689   // the possibility of losing control
674690   if (!options_get_bool(mame_options(), OPTION_DEBUG))
r2988r2989
735751   window->depth = config->depth;
736752   window->refresh = config->refresh;
737753   window->monitor = monitor;
754   
755   //FIXME: these should be per_window in config->
738756   window->fullscreen = !video_config.windowed;
757   window->prescale = video_config.prescale;
758   window->prescale_effect = video_config.prescale_effect;
759   window->scale_mode = video_config.scale_mode;
739760
740761   // set the initial maximized state
762   // FIXME: Does not belong here
741763   window->startmaximized = options_get_bool(mame_options(), SDLOPTION_MAXIMIZE);
742764
743765   if (!window->fullscreen)
r2988r2989
751773   *last_window_ptr = window;
752774   last_window_ptr = &window->next;
753775
776   draw.attach(&draw, window);
777   
754778   // create a lock that we can use to skip blitting
755779   window->render_lock = osd_lock_alloc();
756780
r2988r2989
806830   ASSERT_WINDOW_THREAD();
807831
808832   // free the textures etc
809   (*draw.window_destroy)(window);
833   window->destroy(window);
810834
811835   free(wp);
812836   return NULL;
r2988r2989
849873   free(window);
850874}
851875
876
852877//============================================================
853878//  pick_best_mode
854879//============================================================
r2988r2989
856881static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight)
857882{
858883   int minimum_width, minimum_height, target_width, target_height;
859   SDL_Rect **modes;
860884   int i;
861885   float size_score, best_score = 0.0f;
886   SDL_Rect **modes;
862887
863888   // determine the minimum width/height for the selected target
864889   render_target_get_minimum_size(window->target, &minimum_width, &minimum_height);
865890
866891   // use those as the target for now
867   target_width = minimum_width * MAX(1, video_config.prescale);
868   target_height = minimum_height * MAX(1, video_config.prescale);
892   target_width = minimum_width * MAX(1, window->prescale);
893   target_height = minimum_height * MAX(1, window->prescale);
869894
870895   // if we're not stretching, allow some slop on the minimum since we can handle it
871896   {
r2988r2989
873898      minimum_height -= 4;
874899   }
875900
876#if (SDL_VERSION_ATLEAST(1,3,0))
877   // FIXME: Mode switching not supported!
878   modes = NULL;
879#else
880   modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_DOUBLEBUF);
881#endif
901   modes = window->monitor->modes;
882902   
883903   if (modes == (SDL_Rect **)0)
884904   {
r2988r2989
961981         }
962982      }
963983     
964// this: 'osd_lock_acquire', just to 'see' if rendering was still happening
965// is invalid.
966// 'osd_lock_acquire' puts us to the waiting queue and we will miss to be in sync with real-time
967// but throttle actually means to be in real time, i.e. to not render a few frames,
968// while rendering is still in progress is all fine ..
969#if 0
970      // only block if we're throttled
971      if (video_config.throttle)
972         osd_lock_acquire(window->render_lock);
973      else
974#endif
975         got_lock = osd_lock_try(window->render_lock);
984      got_lock = osd_lock_try(window->render_lock);
976985
977986      // only render if we were able to get the lock
978987      if (got_lock)
r2988r2989
986995         osd_lock_release(window->render_lock);
987996
988997         // ensure the target bounds are up-to-date, and then get the primitives
989         primlist = draw.window_get_primitives(window);
998         primlist = window->get_primitives(window);
990999
9911000         // and redraw now
9921001
r2988r2989
10241033   window->start_viewscreen=viewindex;
10251034}
10261035
1036
10271037//============================================================
10281038//  complete_create
10291039//  (window thread)
r2988r2989
10771087   }
10781088
10791089   // initialize the drawing backend
1080   if ((*draw.window_create)(window, tempwidth, tempheight))
1090   if (window->create(window, tempwidth, tempheight))
10811091      return (void *) &result[1];
10821092
10831093   return (void *) &result[0];
10841094}
10851095
1096
10861097//============================================================
10871098//  draw_video_contents
10881099//  (window thread)
r2988r2989
11141125   
11151126   t0 = getusecs();
11161127
1117   (*draw.window_draw)(window, dc, update);
1128   window->draw(window, dc, update);
11181129
11191130   frames++;
11201131   currentTime = getusecs();
r2988r2989
11431154#else
11441155static void measure_fps(sdl_window_info *window, UINT32 dc, int update)
11451156{
1146   (*draw.window_draw)(window, dc, update);
1157   window->draw(window, dc, update);
11471158}
11481159#endif
11491160
r2988r2989
11721183      if( video_config.perftest )
11731184         measure_fps(window, dc, update);
11741185      else
1175         (*draw.window_draw)(window, dc, update);
1186         window->draw(window, dc, update);
11761187   }
11771188   osd_lock_release(window->render_lock);
11781189   free(wp);
r2988r2989
11801191   return NULL;
11811192}
11821193
1194
11831195//============================================================
11841196//  constrain_to_aspect_ratio
11851197//  (window thread)
r2988r2989
12641276   *window_height = visheight;
12651277}
12661278
1279
12671280//============================================================
12681281//  get_min_bounds
12691282//  (window thread)
r2988r2989
13131326   *window_height = minheight;
13141327}
13151328
1329
13161330//============================================================
13171331//  get_max_bounds
13181332//  (window thread)
src/osd/sdl/debugwin.h
r2988r2989
1414
1515
1616//============================================================
17//  GLOBAL VARIABLES
18//============================================================
19
20// windows
21
22
23
24//============================================================
2517//  PROTOTYPES
2618//============================================================
2719
src/osd/sdl/testkeys.c
r2988r2989
162162                  buf);
163163         }
164164         break;
165      case SDL_KEYUP:
166         memset(buf, 0, 19);
167         utf8_from_uchar(buf, sizeof(buf), event.key.keysym.unicode);
168         printf("ITEM_ID_XY %s 0x%x 0x%x %s \n",
169#if (SDL_VERSION_ATLEAST(1,3,0))
170               lookup_key_name(sdl_lookup, event.key.keysym.scancode),
171#else
172               lookup_key_name(sdl_lookup, event.key.keysym.sym),
173#endif
174               (int) event.key.keysym.scancode,
175               (int) event.key.keysym.unicode,
176               buf);
177         break;
165178      }
166179      event.type = 0;
167180
src/osd/sdl/video.h
r2988r2989
99//
1010//============================================================
1111
12#ifndef __SDL_VIDEO__
13#define __SDL_VIDEO__
12#ifndef __SDLVIDEO__
13#define __SDLVIDEO__
1414
15#include <SDL/SDL.h>
16
1517//============================================================
1618//  CONSTANTS
1719//============================================================
r2988r2989
2123#define VIDEO_MODE_SOFT            (0)
2224#define VIDEO_MODE_OPENGL         (1)
2325
24#define VIDEO_YUV_MODE_NONE         (0)
25#define VIDEO_YUV_MODE_YV12         (1)
26#define VIDEO_YUV_MODE_YV12X2      (2)
27#define VIDEO_YUV_MODE_YUY2         (3)
28#define VIDEO_YUV_MODE_YUY2X2      (4)
29#define VIDEO_YUV_MODE_MAX         VIDEO_YUV_MODE_YUY2X2
30#define VIDEO_YUV_MODE_MIN         VIDEO_YUV_MODE_NONE
26#define VIDEO_SCALE_MODE_NONE      (0)
27#define VIDEO_SCALE_MODE_HWBLIT      (1)
28#define VIDEO_SCALE_MODE_YV12      (2)
29#define VIDEO_SCALE_MODE_YV12X2      (3)
30#define VIDEO_SCALE_MODE_YUY2      (4)
31#define VIDEO_SCALE_MODE_YUY2X2      (5)
32#define VIDEO_SCALE_MODE_MAX      VIDEO_SCALE_MODE_YUY2X2
33#define VIDEO_SCALE_MODE_MIN      VIDEO_SCALE_MODE_NONE
3134
35#define IS_YUV_MODE(_m)            ((_m) >= VIDEO_SCALE_MODE_YV12 && (_m) <= VIDEO_SCALE_MODE_YUY2X2)
3236
3337// texture formats
3438// This used to be an enum, but these are now defines so we can use them as
r2988r2989
6165struct _sdl_monitor_info
6266{
6367   sdl_monitor_info  *   next;               // pointer to next monitor in list
64   UINT32         handle;               // handle to the monitor
65   int         monitor_width;
66   int         monitor_height;
67   char         monitor_device[64];
68   float         aspect;               // computed/configured aspect ratio of the physical device
69   int         reqwidth;            // requested width for this monitor
70   int         reqheight;            // requested height for this monitor
71   int         center_width;            // width of first physical screen for centering
72   int         center_height;            // height of first physical screen for centering
68   UINT32            handle;               // handle to the monitor
69   int               monitor_width;
70   int               monitor_height;
71   char            monitor_device[64];
72   float            aspect;               // computed/configured aspect ratio of the physical device
73   int               reqwidth;            // requested width for this monitor
74   int               reqheight;            // requested height for this monitor
75   int               center_width;         // width of first physical screen for centering
76   int               center_height;         // height of first physical screen for centering
77   //FIXME: This should not be a SDL-type
78   SDL_Rect **modes;                     // supported modes
7379};
7480
7581
r2988r2989
112118
113119   int               fullstretch;
114120
115#if USE_OPENGL   
121   // vector options
122   int               isvector;      // 1 if vector, 0 if raster
123   float            beamwidth;      // beam width
124
116125   // OpenGL options
117126   int               filter;         // enable filtering, disabled if glsl_filter>0
118127   int               prescale_effect;
119128   int               prefer16bpp_tex;
120129   int               glsl;
121130   int               glsl_filter;      // glsl filtering, >0 disables filter
122   char *                                  glsl_shader_mamebm[GLSL_SHADER_MAX]; // custom glsl shader set, mame bitmap
131   char *              glsl_shader_mamebm[GLSL_SHADER_MAX]; // custom glsl shader set, mame bitmap
123132   int               glsl_shader_mamebm_num; // custom glsl shader set number, mame bitmap
124   char *                                  glsl_shader_scrn[GLSL_SHADER_MAX]; // custom glsl shader set, screen bitmap
133   char *              glsl_shader_scrn[GLSL_SHADER_MAX]; // custom glsl shader set, screen bitmap
125134   int               glsl_shader_scrn_num; // custom glsl shader number, screen bitmap
126135   int               glsl_vid_attributes;   // glsl brightness, contrast and gamma for RGB bitmaps
127136   int               pbo;
128137   int               vbo;
129138   int               allowtexturerect;   // allow GL_ARB_texture_rectangle, default: no
130139   int               forcepow2texture;   // force power of two textures, default: no
131#endif
132140
141   // perftest
133142   int               perftest;      // print out real video fps
134143
135   // vector options
136   int               isvector;      // 1 if vector, 0 if raster
137   float            beamwidth;      // beam width
138
139144   // X11 options
140145   int               restrictonemonitor;   // in fullscreen, confine to Xinerama monitor 0
141146
142147   // YUV options   
143   int               yuv_mode;
148   int               scale_mode;
144149};
145150
146151//============================================================
src/osd/sdl/window.h
r2988r2989
99//
1010//============================================================
1111
12#ifndef __SDL_WINDOW__
13#define __SDL_WINDOW__
12#ifndef __SDLWINDOW__
13#define __SDLWINDOW__
1414
1515#include <SDL/SDL.h>
1616#include "video.h"
r2988r2989
1818
1919#include "osd_opengl.h"
2020
21//============================================================
22//  PARAMETERS
23//============================================================
24
25#ifndef MESS
26#define HAS_WINDOW_MENU         FALSE
27#else
28#define HAS_WINDOW_MENU         TRUE
29#endif
30
3121// I don't like this, but we're going to get spurious "cast to integer of different size" warnings on
3222// at least one architecture without doing it this way.
3323#ifdef PTR64
r2988r2989
9585typedef struct _sdl_window_info sdl_window_info;
9686struct _sdl_window_info
9787{
88   // Pointer to next window
9889   sdl_window_info *   next;
90   
91   // Draw Callbacks
92   int (*create)(sdl_window_info *window, int width, int height);
93   void (*resize)(sdl_window_info *window, int width, int height);
94   int (*draw)(sdl_window_info *window, UINT32 dc, int update);
95   const render_primitive_list *(*get_primitives)(sdl_window_info *window);
96   int (*xy_to_render_target)(sdl_window_info *window, int x, int y, int *xt, int *yt);
97   void (*destroy_all_textures)(sdl_window_info *window);
98   void (*destroy)(sdl_window_info *window);
99   void (*clear)(sdl_window_info *window);
99100
100101   // window handle and info
101102   char            title[256];
102   UINT32            extra_flags;
103103
104104   // monitor info
105105   sdl_monitor_info *   monitor;
106106   int               fullscreen;
107   
108   // diverse flags
107109   int               minwidth, minheight;
108110   int               maxwidth, maxheight;
109111   int               depth;
r2988r2989
130132
131133   int               totalColors;      // total colors from machine/sdl_window_config
132134   int               start_viewscreen;
135   
136   // per window modes ...
137   int               scale_mode;
138   
139   // GL specific
140   int               prescale;
141   int               prescale_effect;
142   
133143#if (SDL_VERSION_ATLEAST(1,3,0))
134144   // Needs to be here as well so we can identify window
135145   SDL_WindowID      window_id;
136146#endif
137147};
138148
139typedef struct _sdl_draw_callbacks sdl_draw_callbacks;
140struct _sdl_draw_callbacks
149typedef struct _sdl_draw_info sdl_draw_info;
150struct _sdl_draw_info
141151{
142152   void (*exit)(void);
143
144   int (*window_create)(sdl_window_info *window, int width, int height);
145   void (*window_resize)(sdl_window_info *window, int width, int height);
146   int (*window_draw)(sdl_window_info *window, UINT32 dc, int update);
147   const render_primitive_list *(*window_get_primitives)(sdl_window_info *window);
148   void (*window_destroy_all_textures)(sdl_window_info *window);
149   void (*window_destroy)(sdl_window_info *window);
150   void (*window_clear)(sdl_window_info *window);
153   void (*attach)(sdl_draw_info *info, sdl_window_info *window);
151154};
152155
153156//============================================================
154157//  GLOBAL VARIABLES
155158//============================================================
156159
157// windows
160// window - list
158161extern sdl_window_info *sdl_window_list;
159162
160163//============================================================
r2988r2989
166169
167170// creation/deletion of windows
168171int sdlwindow_video_window_create(running_machine *machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config);
169
170172void sdlwindow_video_window_update(running_machine *machine, sdl_window_info *window);
171
172173void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int window_height);
173
174174void sdlwindow_toggle_full_screen(running_machine *machine, sdl_window_info *window);
175175void sdlwindow_modify_prescale(running_machine *machine, sdl_window_info *window, int dir);
176176void sdlwindow_modify_effect(running_machine *machine, sdl_window_info *window, int dir);
177177void sdlwindow_toggle_draw(running_machine *machine, sdl_window_info *window);
178178void sdlwindow_resize(sdl_window_info *window, INT32 width, INT32 height);
179179
180#if HAS_WINDOW_MENU
181//int sdl_create_menu(HMENU *menus);
182#endif
183
184180//============================================================
185181// PROTOTYPES - drawsdl.c
186182//============================================================
187183
188int drawsdl_init(sdl_draw_callbacks *callbacks);
189int drawogl_init(sdl_draw_callbacks *callbacks);
184int drawsdl_init(sdl_draw_info *callbacks);
185int drawogl_init(sdl_draw_info *callbacks);
190186
191#endif /* __SDL_WINDOW__ */
187#endif /* __SDLWINDOW__ */
src/osd/sdl/sdlsync.c
r2988r2989
593593   
594594   if (pthread_setaffinity_np(lthread, sizeof(cmask), &cmask) <0)
595595   {
596      // Not available during link in all targets
596597      fprintf(stderr, "error %d setting cpu affinity to mask %08x", errno, mask);
597598      return FALSE;
598599   }
src/osd/sdl/debugosx.c
r2988r2989
281281static int disasm_handle_key(debugwin_info *info, EventRef inEvent);
282282static void disasm_update_caption(debugwin_info *info);
283283
284static void console_create_window(void);
284static void console_create_window(running_machine *machine);
285285static void console_recompute_children(debugwin_info *info);
286286static void console_process_string(debugwin_info *info, const char *string);
287static void console_set_cpunum(int cpunum);
287static void console_set_cpunum(running_machine *machine, int cpunum);
288288
289289static MenuRef create_standard_menubar(void);
290290static int global_handle_command(debugwin_info *info, EventRef inEvent);
r2988r2989
366366//  osd_wait_for_debugger
367367//============================================================
368368
369void osd_wait_for_debugger(void)
369void osd_wait_for_debugger(running_machine *machine, int firststop)
370370{
371371   EventRef      message;
372372   EventTargetRef   target = GetEventDispatcherTarget();
r2988r2989
375375
376376   // create a console window
377377   if (!main_console)
378      console_create_window();
378      console_create_window(machine);
379379
380380   // update the views in the console to reflect the current CPU
381381   if (main_console)
382      console_set_cpunum(cpu_getactivecpu());
382      console_set_cpunum(machine, cpu_getactivecpu());
383383
384384   // make sure the debug windows are visible
385385   waiting_for_debugger = TRUE;
r2988r2989
31443144//  console_create_window
31453145//============================================================
31463146
3147void console_create_window(void)
3147void console_create_window(running_machine *machine)
31483148{
31493149   debugwin_info *info;
31503150   int bestwidth, bestheight;
r2988r2989
31623162   if (!info)
31633163      return;
31643164   main_console = info;
3165   console_set_cpunum(0);
3165   console_set_cpunum(Machine, 0);
31663166
31673167   // create the views
31683168   if (!debug_view_create(info, 0, DVT_DISASSEMBLY))
r2988r2989
34253425//  console_set_cpunum
34263426//============================================================
34273427
3428static void console_set_cpunum(int cpunum)
3428static void console_set_cpunum(running_machine *machine, int cpunum)
34293429{
34303430   char title[256];
34313431   CFStringRef      cftitle;
r2988r2989
34373437      debug_view_set_property_UINT32(main_console->view[1].view, DVP_REGS_CPUNUM, cpunum);
34383438
34393439   // then update the caption
3440   snprintf(title, ARRAY_LENGTH(title), "Debug: %s - CPU %d (%s)", Machine->gamedrv->name, cpu_getactivecpu(), activecpu_name());
3440   snprintf(title, ARRAY_LENGTH(title), "Debug: %s - CPU %d (%s)", machine->gamedrv->name, cpu_getactivecpu(), activecpu_name());
34413441   
34423442   cftitle = CFStringCreateWithCString( NULL, title, CFStringGetSystemEncoding() );
34433443   
src/osd/sdl/sdlsync.h
r2988r2989
99//
1010//============================================================
1111
12#ifndef __SDL_SYNC__
13#define __SDL_SYNC__
12#ifndef __SDLSYNC__
13#define __SDLSYNC__
1414
1515#ifndef SDLMAME_WIN32
1616
1717#ifndef SDLMAME_OS2
1818
1919#if (defined SDLMAME_MACOSX) || (defined SDLMAME_FREEBSD)
20#define THREAD_COOPERATIVE              (0)
20#define THREAD_COOPERATIVE      (0)
2121#else
2222#define THREAD_COOPERATIVE      (1)
2323#endif
r2988r2989
195195
196196#endif   /* SDLMAME_WIN32 */
197197
198#endif   /* __SDL_SYNC__ */
198#endif   /* __SDLSYNC__ */
src/osd/sdl/sdlwork.c
r2988r2989
3434
3535#define KEEP_STATISTICS         (0)
3636
37
38
3937//============================================================
4038//  PARAMETERS
4139//============================================================
4240
41#define SDLENV_PROCESSORS            "OSDPROCESSORS"
42#define SDLENV_CPUMASKS               "OSDCPUMASKS"
43
4344#define INFINITE            (osd_ticks_per_second() *  (osd_ticks_t) 10000)
4445#if THREAD_COOPERATIVE
4546//FIXME: depends on <THREADS>/<PHYS PROCESSORS>
r2988r2989
709710   int numprocs = 0;
710711
711712   // if the OSDPROCESSORS environment variable is set, use that value if valid
712   procsoverride = getenv("OSDPROCESSORS");
713   procsoverride = getenv(SDLENV_PROCESSORS);
713714   if (procsoverride != NULL && sscanf(procsoverride, "%d", &numprocs) == 1 && numprocs > 0)
714715      return numprocs;
715716
r2988r2989
728729   char   buf[5];
729730   UINT32   mask = 0xFFFF;
730731
731   s = getenv("OSDCPUMASKS");
732   s = getenv(SDLENV_CPUMASKS);
732733   if (s != NULL && strcmp(s,"none"))
733734   {
734735      if (!strcmp(s,"auto"))
src/osd/sdl/sdlmain.c
r2988r2989
110110   #if (SDL_VERSION_ATLEAST(1,2,10))
111111   { SDLOPTION_WAITVSYNC,                    "0",        OPTION_BOOLEAN,    "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" },
112112   #endif
113   { SDLOPTION_YUVMODE ";ym",           SDLOPTVAL_NONE,  0,                 "YUV mode: none, yv12, yuy2, yv12x2, yuy2x2 (-video soft only)" },
114
113   { SDLOPTION_SCALEMODE ";sm",         SDLOPTVAL_NONE,  0,                 "Scale mode: none, hwblit, yv12, yuy2, yv12x2, yuy2x2 (-video soft only)" },
115114#if USE_OPENGL
116115   // OpenGL specific options
117116   { NULL,                                   NULL,   OPTION_HEADER,  "OpenGL-SPECIFIC OPTIONS" },
r2988r2989
201200   { SDLOPTION_JOYMAP,                      "0",    OPTION_BOOLEAN,    "enable physical to logical joystick mapping" },
202201   { SDLOPTION_JOYMAP_FILE,                "joymap.dat", 0,            "joymap filename" },
203202   { SDLOPTION_SIXAXIS,                 "0",    OPTION_BOOLEAN,    "Use special handling for PS3 Sixaxis controllers" },
203
204   // SDL low level driver options
205   { NULL,                                NULL,   OPTION_HEADER,     "SDL LOWLEVEL DRIVER OPTIONS" },
206   { SDLOPTION_VIDEODRIVER ";vd",       SDLOPTVAL_AUTO,   0,           "sdl video driver to use ('x11', 'directfb', ... or 'auto' for SDL default" },
207#if (SDL_VERSION_ATLEAST(1,3,0))
208   { SDLOPTION_RENDERDRIVER ";rd",      SDLOPTVAL_AUTO,   0,           "sdl render driver to use ('software', 'opengl', 'directfb' ... or 'auto' for SDL default" },
209#endif
210   { SDLOPTION_AUDIODRIVER ";ad",       SDLOPTVAL_AUTO,   0,           "sdl audio driver to use ('alsa', 'arts', ... or 'auto' for SDL default" },
211#if USE_OPENGL
212    { SDLOPTION_GL_LIB,                   SDLOPTVAL_GLLIB, 0,           "alternative libGL.so to use; 'auto' for system default" },
213#endif
214
215   // End of list
204216   { NULL }
205217};
206218
r2988r2989
308320         char buf[130];
309321         if (XMatchVisualInfo(display, DefaultScreen(display), 24, TrueColor, &vi)) {
310322            snprintf(buf, sizeof(buf), "0x%lx", vi.visualid);
311            setenv(SDLENV_IDENTIFIER, buf, 0);
323            setenv(SDLENV_VISUALID, buf, 0);
312324         }
313325      }
314326      if (display)
r2988r2989
418430//============================================================
419431void osd_init(running_machine *machine)
420432{
433   const char *stemp;
434
435   // Some driver options - must be before audio init!
436   stemp = options_get_string(mame_options(), SDLOPTION_AUDIODRIVER);
437   if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
438   {
439      mame_printf_verbose("Setting SDL audiodriver '%s' ...\n", stemp);
440      setenv(SDLENV_AUDIODRIVER, stemp, 1);
441   }
442
443   stemp = options_get_string(mame_options(), SDLOPTION_VIDEODRIVER);
444   if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
445   {
446      mame_printf_verbose("Setting SDL videodriver '%s' ...\n", stemp);
447      setenv(SDLENV_VIDEODRIVER, stemp, 1);
448   }
449
450   if (SDL_VERSION_ATLEAST(1,3,0))
451   {
452      stemp = options_get_string(mame_options(), SDLOPTION_RENDERDRIVER);
453      if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0)
454      {
455         mame_printf_verbose("Setting SDL renderdriver '%s' ...\n", stemp);
456         setenv(SDLENV_RENDERDRIVER, stemp, 1);
457      }
458   }
459
421460   if (!SDLMAME_INIT_IN_WORKER_THREAD)
422461   {
423462      if (SDL_Init(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) {
424463         /* mame_printf_* not fully initialized yet */
425         ShowError("Could not initialize SDL: %s.\n", SDL_GetError());
464         ShowError("Could not initialize SDL", SDL_GetError());
426465         exit(-1);
427466      }
428467   }
r2988r2989
431470
432471   defines_verbose();
433472
434#if defined(SDLMAME_NO_X11) || defined(SDLMAME_WIN32)
435   if (options_get_bool(mame_options(), OPTION_DEBUG))
436   {
437      osd_exit(machine);
438      ShowError("sdlmame", "-debug not supported on X11-less builds\n\n");
439      exit(-1);     
440   }
441#endif
473   if (!SDLMAME_HAS_DEBUGGER)
474      if (options_get_bool(mame_options(), OPTION_DEBUG))
475      {
476         osd_exit(machine);
477         ShowError("sdlmame", "-debug not supported on X11-less builds\n\n");
478         exit(-1);     
479      }
442480   
443481   if (sdlvideo_init(machine))
444482   {
r2988r2989
456494   #endif
457495
458496   sdlinput_init(machine);
497   
459498   sdlaudio_init(machine);
460499
461500   if (options_get_bool(mame_options(), SDLOPTION_OSLOG))
462501      add_logerror_callback(machine, output_oslog);
463502
464   #ifdef MESS
465   SDL_EnableUNICODE(1);
466   #endif
503#if (SDL_VERSION_ATLEAST(1,3,0))
504   SDL_EventState(SDL_TEXTINPUT, SDL_TRUE);
505#else
506   SDL_EnableUNICODE(SDL_TRUE);
507#endif
467508}
468509
469510#ifdef MESS
src/osd/sdl/osdsdl.h
r2988r2989
33
44/* Notes
55
6   - working ui mouse inputs for SDL1.2 and SDL1.3 incl. yuv modes
7   - added blitmode "hwblit" (SDL1.3) for rgb hardware scaling
8   - rename "-yuvmode" option to "-scalemode"
9   - rename yuv_mode and derivatives to scale_mode
10   - moved extra_flags into sdl_info
11   - moved callbacks indow sdl_window_info
12   - made a number of flags (e.g. yuvmode) window relative
13         - changing of yuvmodes and opengl scale effects is working with SDL 1.3
14   - improved fullscreen handling
15   - removed HAS_WINDOW_MENU - this has no effect nowhere
16   - removed underscores in header defines, e.g. __SDL_SYNC__ ==> __SDLSYNC__
17   - added SDLMAME_HAS_DEBUGGER define
18   - removed #if 0 inw window.c
19   - added option "-audiodriver" to specify the SDL audio driver
20   - added option "-videodriver" to specify the SDL video driver
21   - added option "-renderdriver" to specify the SDL renderer driver
22   - changed environment SDLMAME_GL_LIB into option -gl_lib
23   - added some more SDL_ENV defines
24   - move keymap reading into separate function
25   - SDL_EnableUNICODE for all builds (not only MESS)
26   - SDL1.3 : Mouse & text input for ui
27
628   - removed  osd_event_wait_multiple from sdlsync.h
729   - removed some includes not needed
830   - reorganized texcopy/scale2x
r2988r2989
109131#define SDLMAME_INIT_IN_WORKER_THREAD   (0)
110132#endif
111133
134#if defined(SDLMAME_NO_X11) || defined(SDLMAME_WIN32)
135#define SDLMAME_HAS_DEBUGGER          (0)
136#else
137#define SDLMAME_HAS_DEBUGGER          (1)
138#endif
112139
113140//============================================================
114141//   Defines
r2988r2989
126153#define SDLOPTION_NUMSCREENS         "numscreens"
127154#define SDLOPTION_UNEVENSTRETCH         "unevenstretch"
128155#define SDLOPTION_USEALLHEADS         "useallheads"
129#define SDLOPTION_MAXIMIZE         "maximize"
156#define SDLOPTION_MAXIMIZE            "maximize"
130157#define SDLOPTION_EFFECT            "effect"
131158#define SDLOPTION_VIDEO               "video"
132159#define SDLOPTION_SWITCHRES            "switchres"
r2988r2989
135162#define SDLOPTION_CENTERV            "centerv"
136163#define SDLOPTION_PRESCALE            "prescale"
137164#define SDLOPTION_PRESCALE_EFFECT      "prescale_effect"
138#define SDLOPTION_YUVMODE            "yuvmode"
165#define SDLOPTION_SCALEMODE            "scalemode"
139166#define SDLOPTION_MULTITHREADING      "multithreading"
140167#define SDLOPTION_WAITVSYNC            "waitvsync"
141168#define SDLOPTION_KEYMAP            "keymap"
r2988r2989
156183#define SDLOPTION_GL_FORCEPOW2TEXTURE   "gl_forcepow2texture"
157184#define SDLOPTION_GL_GLSL_VID_ATTR      "gl_glsl_vid_attr"
158185
186#define SDLOPTION_AUDIODRIVER         "audiodriver"
187#define SDLOPTION_VIDEODRIVER         "videodriver"
188#define SDLOPTION_RENDERDRIVER         "renderdriver"
189#define SDLOPTION_GL_LIB            "gl_lib"
190
159191#define SDLOPTVAL_NONE               "none"
160192#define SDLOPTVAL_AUTO               "auto"
161193
r2988r2989
163195#define SDLOPTVAL_OPENGL16            "opengl16"
164196#define SDLOPTVAL_SOFT               "soft"
165197
198#define SDLOPTVAL_HWBLIT            "hwblit"
166199#define SDLOPTVAL_YV12               "yv12"
167200#define SDLOPTVAL_YV12x2            "yv12x2"
168201#define SDLOPTVAL_YUY2               "yuy2"
r2988r2989
170203
171204#define SDL_LED(x)                  "led" #x
172205
173#define SDLENV_IDENTIFIER            "SDL_VIDEO_X11_VISUALID"
206// read by sdlmame
207
174208#define SDLENV_DESKTOPDIM            "SDLMAME_DESKTOPDIM"
175#define SDLENV_GL_LIB               "SDLMAME_GL_LIB"
176209#define SDLENV_VMWARE               "SDLMAME_VMWARE"
177210
178211#define sdl_use_unsupported()         (getenv("SDLMAME_UNSUPPORTED") != NULL)
179212
213// set by sdlmame
214
215#define SDLENV_VISUALID               "SDL_VIDEO_X11_VISUALID"
216#define SDLENV_VIDEODRIVER            "SDL_VIDEODRIVER"
217#define SDLENV_AUDIODRIVER            "SDL_AUDIODRIVER"
218#define SDLENV_RENDERDRIVER            "SDL_VIDEO_RENDERER"
219
180220#define SDL_SOUND_LOG               "sound.log"
181221
222#ifdef SDLMAME_MACOSX
223/* Vas Crabb: Default GL-lib for MACOSX */
224#define SDLOPTVAL_GLLIB               "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
225#else
226#define SDLOPTVAL_GLLIB               SDLOPTVAL_AUTO
227#endif
228
229
182230//============================================================
183231//   sound.c
184232//============================================================

Previous 15994 Revisions Next


© 1998-2018 The MESS Team