Previous 199869 Revisions Next

r31855 Monday 1st September, 2014 at 08:58:33 UTC by Miodrag Milanović
Added window to osd_interface (nw)
win_monitor_info to class
win_window_info to class, partial
[src/osd]osdepend.c osdepend.h
[src/osd/modules/debugger]debugwin.c
[src/osd/modules/sound]direct_sound.c
[src/osd/sdl]osdsdl.h video.c window.c window.h
[src/osd/windows]d3dhlsl.c drawd3d.c drawdd.c drawgdi.c drawnone.c input.c video.c video.h window.c window.h winmain.c winmain.h

trunk/src/osd/windows/input.c
r31854r31855
614614      POINT mousepos;
615615
616616      // get the position relative to the window
617      GetClientRect(win_window_list->hwnd, &client_rect);
617      GetClientRect(win_window_list->m_hwnd, &client_rect);
618618      mousepos.x = x;
619619      mousepos.y = y;
620      ScreenToClient(win_window_list->hwnd, &mousepos);
620      ScreenToClient(win_window_list->m_hwnd, &mousepos);
621621
622622      // convert to absolute coordinates
623623      devinfo->mouse.state.lX = normalize_absolute_axis(mousepos.x, client_rect.left, client_rect.right);
r31854r31855
10431043      RECT client_rect;
10441044
10451045      // get the position relative to the window
1046      GetClientRect(win_window_list->hwnd, &client_rect);
1047      ScreenToClient(win_window_list->hwnd, &mousepos);
1046      GetClientRect(win_window_list->m_hwnd, &client_rect);
1047      ScreenToClient(win_window_list->m_hwnd, &mousepos);
10481048
10491049      // convert to absolute coordinates
10501050      xpos = normalize_absolute_axis(mousepos.x, client_rect.left, client_rect.right);
r31854r31855
12181218   }
12191219
12201220   // set the cooperative level
1221   result = IDirectInputDevice_SetCooperativeLevel(devinfo->dinput.device, win_window_list->hwnd, cooperative_level);
1221   result = IDirectInputDevice_SetCooperativeLevel(devinfo->dinput.device, win_window_list->m_hwnd, cooperative_level);
12221222   if (result != DI_OK)
12231223      goto error;
12241224   return devinfo;
r31854r31855
17021702      reglist[regcount].usUsagePage = 0x01;
17031703      reglist[regcount].usUsage = 0x06;
17041704      reglist[regcount].dwFlags = RIDEV_INPUTSINK;
1705      reglist[regcount].hwndTarget = win_window_list->hwnd;
1705      reglist[regcount].hwndTarget = win_window_list->m_hwnd;
17061706      regcount++;
17071707   }
17081708   if (mouse_list != NULL)
r31854r31855
17101710      reglist[regcount].usUsagePage = 0x01;
17111711      reglist[regcount].usUsage = 0x02;
17121712      reglist[regcount].dwFlags = 0;
1713      reglist[regcount].hwndTarget = win_window_list->hwnd;
1713      reglist[regcount].hwndTarget = win_window_list->m_hwnd;
17141714      regcount++;
17151715   }
17161716
trunk/src/osd/windows/winmain.c
r31854r31855
494494      winwindow_toggle_full_screen();
495495
496496   vsnprintf(buffer, ARRAY_LENGTH(buffer), format, argptr);
497   win_message_box_utf8(win_window_list ? win_window_list->hwnd : NULL, buffer, emulator_info::get_appname(), MB_OK);
497   win_message_box_utf8(win_window_list ? win_window_list->m_hwnd : NULL, buffer, emulator_info::get_appname(), MB_OK);
498498}
499499
500500
r31854r31855
625625
626626   // notify listeners of screen configuration
627627   astring tempstring;
628   for (win_window_info *info = win_window_list; info != NULL; info = info->next)
628   for (win_window_info *info = win_window_list; info != NULL; info = info->m_next)
629629   {
630      char *tmp = utf8_from_tstring(info->monitor->info.szDevice);
630      char *tmp = utf8_from_tstring(info->m_monitor->info.szDevice);
631631      tempstring.printf("Orientation(%s)", tmp);
632      output_set_value(tempstring, info->targetorient);
632      output_set_value(tempstring, info->m_targetorient);
633633      osd_free(tmp);
634634   }
635635
trunk/src/osd/windows/video.c
r31854r31855
7777   init_monitors();
7878
7979   // initialize the window system so we can make windows
80   winwindow_init(machine());
80   window_init();
8181
8282   // create the windows
8383   windows_options &options = downcast<windows_options &>(machine().options());
8484   for (index = 0; index < video_config.numscreens; index++)
8585      winwindow_video_window_create(machine(), index, pick_monitor(options, index), &video_config.window[index]);
8686   if (video_config.mode != VIDEO_MODE_NONE)
87      SetForegroundWindow(win_window_list->hwnd);
87      SetForegroundWindow(win_window_list->m_hwnd);
8888
8989   return true;
9090}
r31854r31855
9696
9797void windows_osd_interface::video_exit()
9898{
99   window_exit();
100   
99101   // free all of our monitor information
100102   while (win_monitor_list != NULL)
101103   {
r31854r31855
107109
108110
109111
112win_monitor_info::win_monitor_info()
113   : next(NULL),
114     handle(NULL),
115     aspect(0.0f),
116     reqwidth(0),
117     reqheight(0)
118{
119}
120
121win_monitor_info::~win_monitor_info()
122{
123}
124
110125//============================================================
111126//  winvideo_monitor_refresh
112127//============================================================
113128
114void winvideo_monitor_refresh(win_monitor_info *monitor)
129void win_monitor_info::refresh()
115130{
116131   BOOL result;
117132
118133   // fetch the latest info about the monitor
119   monitor->info.cbSize = sizeof(monitor->info);
120   result = GetMonitorInfo(monitor->handle, (LPMONITORINFO)&monitor->info);
134   info.cbSize = sizeof(info);
135   result = GetMonitorInfo(handle, (LPMONITORINFO)&info);
121136   assert(result);
122137   (void)result; // to silence gcc 4.6
123138}
r31854r31855
128143//  winvideo_monitor_get_aspect
129144//============================================================
130145
131float winvideo_monitor_get_aspect(win_monitor_info *monitor)
146float win_monitor_info::get_aspect()
132147{
133148   // refresh the monitor information and compute the aspect
134149   if (video_config.keepaspect)
135150   {
136151      int width, height;
137      winvideo_monitor_refresh(monitor);
138      width = rect_width(&monitor->info.rcMonitor);
139      height = rect_height(&monitor->info.rcMonitor);
140      return monitor->aspect / ((float)width / (float)height);
152      refresh();
153      width = rect_width(&info.rcMonitor);
154      height = rect_height(&info.rcMonitor);
155      return aspect / ((float)width / (float)height);
141156   }
142157   return 0.0f;
143158}
r31854r31855
172187
173188   // if we're not skipping this redraw, update all windows
174189   if (!skip_redraw)
175      for (win_window_info *window = win_window_list; window != NULL; window = window->next)
176         winwindow_video_window_update(window);
190      for (win_window_info *window = win_window_list; window != NULL; window = window->m_next)
191         window->update();
177192
178193   // poll the joystick values here
179194   winwindow_process_events(machine(), TRUE, FALSE);
r31854r31855
234249   (void)result; // to silence gcc 4.6
235250
236251   // allocate a new monitor info
237   monitor = global_alloc_clear(win_monitor_info);
252   monitor = global_alloc(win_monitor_info);
238253
239254   // copy in the data
240255   monitor->handle = handle;
241256   monitor->info = info;
242257
243258   // guess the aspect ratio assuming square pixels
244   monitor->aspect = (float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top);
259   monitor->set_aspect((float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top));
245260
246261   // save the primary monitor handle
247262   if (monitor->info.dwFlags & MONITORINFOF_PRIMARY)
r31854r31855
309324
310325finishit:
311326   if (aspect != 0)
312      monitor->aspect = aspect;
327      monitor->set_aspect(aspect);
313328   return monitor;
314329}
315330
trunk/src/osd/windows/winmain.h
r31854r31855
261261   virtual void debugger_register();
262262
263263   virtual bool video_init();
264   virtual bool window_init();
264265   virtual bool input_init();
265266   virtual void input_pause();
266267   virtual void input_resume();
r31854r31855
270271   #endif
271272
272273   virtual void video_exit();
274   virtual void window_exit();
273275   virtual void input_exit();
274276   virtual void output_exit();
275277   #ifdef USE_NETWORK
trunk/src/osd/windows/video.h
r31854r31855
2929//  TYPE DEFINITIONS
3030//============================================================
3131
32struct win_monitor_info
32class win_monitor_info
3333{
34public:
35   win_monitor_info();
36   virtual ~win_monitor_info();
37
38   void refresh();
39   float get_aspect();
40   void set_aspect(float a) { aspect = a; }
41   
3442   win_monitor_info  * next;                   // pointer to next monitor in list
3543   HMONITOR            handle;                 // handle to the monitor
36   MONITORINFOEX       info;                   // most recently retrieved info
44   MONITORINFOEX       info;                   // most recently retrieved info   
45private:   
3746   float               aspect;                 // computed/configured aspect ratio of the physical device
3847   int                 reqwidth;               // requested width for this monitor
3948   int                 reqheight;              // requested height for this monitor
r31854r31855
8190//  GLOBAL VARIABLES
8291//============================================================
8392
84extern win_monitor_info *win_monitor_list;
8593extern win_video_config video_config;
8694
8795
r31854r31855
8997//  PROTOTYPES
9098//============================================================
9199
92void winvideo_monitor_refresh(win_monitor_info *monitor);
93float winvideo_monitor_get_aspect(win_monitor_info *monitor);
94100win_monitor_info *winvideo_monitor_from_handle(HMONITOR monitor);
95101
96102#endif
trunk/src/osd/windows/drawnone.c
r31854r31855
8787static render_primitive_list *drawnone_window_get_primitives(win_window_info *window)
8888{
8989   RECT client;
90   GetClientRect(window->hwnd, &client);
91   window->target->set_bounds(rect_width(&client), rect_height(&client), winvideo_monitor_get_aspect(window->monitor));
92   return &window->target->get_primitives();
90   GetClientRect(window->m_hwnd, &client);
91   window->m_target->set_bounds(rect_width(&client), rect_height(&client), window->m_monitor->get_aspect());
92   return &window->m_target->get_primitives();
9393}
9494
9595
trunk/src/osd/windows/drawd3d.c
r31854r31855
196196{
197197   // allocate memory for our structures
198198   d3d::renderer *d3d = global_alloc(d3d::renderer(window));
199   window->drawdata = d3d;
199   window->m_drawdata = d3d;
200200
201201   if (!d3d->initialize())
202202   {
r31854r31855
220220
221221static void drawd3d_window_toggle_fsfx(win_window_info *window)
222222{
223   d3d::renderer *d3d = (d3d::renderer *)window->drawdata;
223   d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata;
224224   d3d->set_restarting(true);
225225}
226226
227227static void drawd3d_window_record(win_window_info *window)
228228{
229   d3d::renderer *d3d = (d3d::renderer *)window->drawdata;
229   d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata;
230230   d3d->get_shaders()->window_record();
231231}
232232
233233static void drawd3d_window_save(win_window_info *window)
234234{
235   d3d::renderer *d3d = (d3d::renderer *)window->drawdata;
235   d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata;
236236   d3d->get_shaders()->window_save();
237237}
238238
r31854r31855
244244
245245static void drawd3d_window_destroy(win_window_info *window)
246246{
247   d3d::renderer *d3d = (d3d::renderer *)window->drawdata;
247   d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata;
248248
249249   // skip if nothing
250250   if (d3d == NULL)
r31854r31855
255255
256256   // free the memory in the window
257257   global_free(d3d);
258   window->drawdata = NULL;
258   window->m_drawdata = NULL;
259259}
260260
261261
r31854r31855
266266
267267static render_primitive_list *drawd3d_window_get_primitives(win_window_info *window)
268268{
269   d3d::renderer *d3d = (d3d::renderer *)window->drawdata;
269   d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata;
270270   RECT client;
271271
272   GetClientRectExceptMenu(window->hwnd, &client, window->fullscreen);
272   GetClientRectExceptMenu(window->m_hwnd, &client, window->m_fullscreen);
273273   if (rect_width(&client) > 0 && rect_height(&client) > 0)
274274   {
275      window->target->set_bounds(rect_width(&client), rect_height(&client), winvideo_monitor_get_aspect(window->monitor));
276      window->target->set_max_update_rate((d3d->get_refresh() == 0) ? d3d->get_origmode().RefreshRate : d3d->get_refresh());
275      window->m_target->set_bounds(rect_width(&client), rect_height(&client), window->m_monitor->get_aspect());
276      window->m_target->set_max_update_rate((d3d->get_refresh() == 0) ? d3d->get_origmode().RefreshRate : d3d->get_refresh());
277277   }
278   return &window->target->get_primitives();
278   return &window->m_target->get_primitives();
279279}
280280
281281int drawd3d_init(running_machine &machine, win_draw_callbacks *callbacks)
r31854r31855
311311
312312static int drawd3d_window_draw(win_window_info *window, HDC dc, int update)
313313{
314   d3d::renderer *d3d = (d3d::renderer *)window->drawdata;
314   d3d::renderer *d3d = (d3d::renderer *)window->m_drawdata;
315315
316316   // if we haven't been created, just punt
317317   if (d3d == NULL)
r31854r31855
496496   osd_printf_verbose("Direct3D: YUV format = %s\n", (m_yuv_format == D3DFMT_YUY2) ? "YUY2" : (m_yuv_format == D3DFMT_UYVY) ? "UYVY" : "RGB");
497497
498498   // set the max texture size
499   d3d->get_window()->target->set_max_texture_size(m_texture_max_width, m_texture_max_height);
499   d3d->get_window()->m_target->set_max_texture_size(m_texture_max_width, m_texture_max_height);
500500   osd_printf_verbose("Direct3D: Max texture size = %dx%d\n", (int)m_texture_max_width, (int)m_texture_max_height);
501501}
502502
r31854r31855
672672      return false;
673673
674674   // create the device immediately for the full screen case (defer for window mode)
675   if (m_window->fullscreen && device_create())
675   if (m_window->m_fullscreen && device_create())
676676      return false;
677677
678678   return true;
r31854r31855
681681int renderer::pre_window_draw_check()
682682{
683683   // if we're in the middle of resizing, leave things alone
684   if (m_window->resize_state == RESIZE_STATE_RESIZING)
684   if (m_window->m_resize_state == RESIZE_STATE_RESIZING)
685685      return 0;
686686
687687   // if we're restarting the renderer, leave things alone
r31854r31855
706706   }
707707
708708   // in window mode, we need to track the window size
709   if (!m_window->fullscreen || m_device == NULL)
709   if (!m_window->m_fullscreen || m_device == NULL)
710710   {
711711      // if the size changes, skip this update since the render target will be out of date
712712      if (update_window_size())
r31854r31855
722722
723723void texture_manager::update_textures()
724724{
725   for (render_primitive *prim = m_renderer->get_window()->primlist->first(); prim != NULL; prim = prim->next())
725   for (render_primitive *prim = m_renderer->get_window()->m_primlist->first(); prim != NULL; prim = prim->next())
726726   {
727727      if (prim->texture.base != NULL)
728728      {
r31854r31855
759759
760760   m_shaders->begin_frame();
761761
762   m_window->primlist->acquire_lock();
762   m_window->m_primlist->acquire_lock();
763763
764764   // first update any textures
765765   m_texture_manager->update_textures();
r31854r31855
780780   m_line_count = 0;
781781
782782   // loop over primitives
783   for (render_primitive *prim = m_window->primlist->first(); prim != NULL; prim = prim->next())
783   for (render_primitive *prim = m_window->m_primlist->first(); prim != NULL; prim = prim->next())
784784      if (prim->type == render_primitive::LINE && PRIMFLAG_GET_VECTOR(prim->flags))
785785         m_line_count++;
786786}
r31854r31855
788788void renderer::process_primitives()
789789{
790790   // Rotating index for vector time offsets
791   for (render_primitive *prim = m_window->primlist->first(); prim != NULL; prim = prim->next())
791   for (render_primitive *prim = m_window->m_primlist->first(); prim != NULL; prim = prim->next())
792792   {
793793      switch (prim->type)
794794      {
r31854r31855
818818
819819void renderer::end_frame()
820820{
821   m_window->primlist->release_lock();
821   m_window->m_primlist->release_lock();
822822
823823   // flush any pending polygons
824824   primitive_flush_pending();
r31854r31855
893893   m_presentation.BackBufferCount               = video_config.triplebuf ? 2 : 1;
894894   m_presentation.MultiSampleType               = D3DMULTISAMPLE_NONE;
895895   m_presentation.SwapEffect                    = D3DSWAPEFFECT_DISCARD;
896   m_presentation.hDeviceWindow                 = m_window->hwnd;
897   m_presentation.Windowed                      = !m_window->fullscreen || win_has_menu(m_window);
896   m_presentation.hDeviceWindow                 = m_window->m_hwnd;
897   m_presentation.Windowed                      = !m_window->m_fullscreen || win_has_menu(m_window);
898898   m_presentation.EnableAutoDepthStencil        = FALSE;
899899   m_presentation.AutoDepthStencilFormat        = D3DFMT_D16;
900900   m_presentation.Flags                         = 0;
901901   m_presentation.FullScreen_RefreshRateInHz    = m_refresh;
902   m_presentation.PresentationInterval          = ((video_config.triplebuf && m_window->fullscreen) ||
902   m_presentation.PresentationInterval          = ((video_config.triplebuf && m_window->m_fullscreen) ||
903903                                       video_config.waitvsync || video_config.syncrefresh) ?
904904                                       D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
905905
906906   // create the D3D device
907   result = (*d3dintf->d3d.create_device)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_window->focus_hwnd,
907   result = (*d3dintf->d3d.create_device)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_window->m_focus_hwnd,
908908               D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE, &m_presentation, &m_device);
909909   if (result != D3D_OK)
910910   {
r31854r31855
927927   osd_printf_verbose("Direct3D: Device created at %dx%d\n", m_width, m_height);
928928
929929   // set the gamma if we need to
930   if (m_window->fullscreen)
930   if (m_window->m_fullscreen)
931931   {
932932      // only set the gamma if it's not 1.0f
933933      windows_options &options = downcast<windows_options &>(m_window->machine().options());
r31854r31855
12271227   }
12281228
12291229   // choose a resolution: window mode case
1230   if (!m_window->fullscreen || !video_config.switchres || win_has_menu(m_window))
1230   if (!m_window->m_fullscreen || !video_config.switchres || win_has_menu(m_window))
12311231   {
12321232      RECT client;
12331233
12341234      // bounds are from the window client rect
1235      GetClientRectExceptMenu(m_window->hwnd, &client, m_window->fullscreen);
1235      GetClientRectExceptMenu(m_window->m_hwnd, &client, m_window->m_fullscreen);
12361236      m_width = client.right - client.left;
12371237      m_height = client.bottom - client.top;
12381238
r31854r31855
12431243      // make sure it's a pixel format we can get behind
12441244      if (m_pixformat != D3DFMT_X1R5G5B5 && m_pixformat != D3DFMT_R5G6B5 && m_pixformat != D3DFMT_X8R8G8B8)
12451245      {
1246         char *utf8_device = utf8_from_tstring(m_window->monitor->info.szDevice);
1246         char *utf8_device = utf8_from_tstring(m_window->m_monitor->info.szDevice);
12471247         if (utf8_device != NULL)
12481248         {
12491249            osd_printf_error("Device %s currently in an unsupported mode\n", utf8_device);
r31854r31855
12681268   }
12691269
12701270   // see if we can handle the device type
1271   result = (*d3dintf->d3d.check_device_type)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_pixformat, m_pixformat, !m_window->fullscreen);
1271   result = (*d3dintf->d3d.check_device_type)(d3dintf, m_adapter, D3DDEVTYPE_HAL, m_pixformat, m_pixformat, !m_window->m_fullscreen);
12721272   if (result != D3D_OK)
12731273   {
1274      char *utf8_device = utf8_from_tstring(m_window->monitor->info.szDevice);
1274      char *utf8_device = utf8_from_tstring(m_window->m_monitor->info.szDevice);
12751275      if (utf8_device != NULL)
12761276      {
12771277         osd_printf_error("Proposed video mode not supported on device %s\n", utf8_device);
r31854r31855
12991299      HMONITOR curmonitor = (*d3dintf->d3d.get_adapter_monitor)(d3dintf, adapternum);
13001300
13011301      // if we match the proposed monitor, this is it
1302      if (curmonitor == m_window->monitor->handle)
1302      if (curmonitor == m_window->m_monitor->handle)
13031303      {
13041304         return adapternum;
13051305      }
r31854r31855
13321332   // note: technically we should not be calling this from an alternate window
13331333   // thread; however, it is only done during init time, and the init code on
13341334   // the main thread is waiting for us to finish, so it is safe to do so here
1335   m_window->target->compute_minimum_size(minwidth, minheight);
1335   m_window->m_target->compute_minimum_size(minwidth, minheight);
13361336
13371337   // use those as the target for now
13381338   INT32 target_width = minwidth;
r31854r31855
13671367         size_score *= 0.1f;
13681368
13691369      // if we're looking for a particular mode, that's a winner
1370      if (mode.Width == m_window->maxwidth && mode.Height == m_window->maxheight)
1370      if (mode.Width == m_window->m_maxwidth && mode.Height == m_window->m_maxheight)
13711371         size_score = 2.0f;
13721372
13731373      // compute refresh score
r31854r31855
13781378         refresh_score *= 0.1f;
13791379
13801380      // if we're looking for a particular refresh, make sure it matches
1381      if (mode.RefreshRate == m_window->refresh)
1381      if (mode.RefreshRate == m_window->m_refresh)
13821382         refresh_score = 2.0f;
13831383
13841384      // weight size and refresh equally
r31854r31855
14081408{
14091409   // get the current window bounds
14101410   RECT client;
1411   GetClientRectExceptMenu(m_window->hwnd, &client, m_window->fullscreen);
1411   GetClientRectExceptMenu(m_window->m_hwnd, &client, m_window->m_fullscreen);
14121412
14131413   // if we have a device and matching width/height, nothing to do
14141414   if (m_device != NULL && rect_width(&client) == m_width && rect_height(&client) == m_height)
14151415   {
14161416      // clear out any pending resizing if the area didn't change
1417      if (m_window->resize_state == RESIZE_STATE_PENDING)
1418         m_window->resize_state = RESIZE_STATE_NORMAL;
1417      if (m_window->m_resize_state == RESIZE_STATE_PENDING)
1418         m_window->m_resize_state = RESIZE_STATE_NORMAL;
14191419      return FALSE;
14201420   }
14211421
14221422   // if we're in the middle of resizing, leave it alone as well
1423   if (m_window->resize_state == RESIZE_STATE_RESIZING)
1423   if (m_window->m_resize_state == RESIZE_STATE_RESIZING)
14241424      return FALSE;
14251425
14261426   // set the new bounds and create the device again
r31854r31855
14301430      return FALSE;
14311431
14321432   // reset the resize state to normal, and indicate we made a change
1433   m_window->resize_state = RESIZE_STATE_NORMAL;
1433   m_window->m_resize_state = RESIZE_STATE_NORMAL;
14341434   return TRUE;
14351435}
14361436
r31854r31855
14501450   int line_index = 0;
14511451   float period = options.screen_vector_time_period();
14521452   UINT32 cached_flags = 0;
1453   for (render_primitive *prim = m_window->primlist->first(); prim != NULL; prim = prim->next())
1453   for (render_primitive *prim = m_window->m_primlist->first(); prim != NULL; prim = prim->next())
14541454   {
14551455      switch (prim->type)
14561456      {
trunk/src/osd/windows/d3dhlsl.c
r31854r31855
224224   if (!master_enable || !d3dintf->post_fx_available)
225225      return;
226226
227   renderer *d3d = (renderer *)window->drawdata;
227   renderer *d3d = (renderer *)window->m_drawdata;
228228
229229   HRESULT result = (*d3dintf->device.create_texture)(d3d->get_device(), snap_width, snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &snap_copy_texture);
230230   if (result != D3D_OK)
r31854r31855
276276   if (!master_enable || !d3dintf->post_fx_available)
277277      return;
278278
279   renderer *d3d = (renderer *)window->drawdata;
279   renderer *d3d = (renderer *)window->m_drawdata;
280280
281281   D3DLOCKED_RECT rect;
282282
r31854r31855
326326   if (!master_enable || !d3dintf->post_fx_available)
327327      return;
328328
329   renderer *d3d = (renderer *)window->drawdata;
329   renderer *d3d = (renderer *)window->m_drawdata;
330330
331331   D3DLOCKED_RECT rect;
332332
r31854r31855
519519   if (!master_enable || !d3dintf->post_fx_available)
520520      return;
521521
522   renderer *d3d = (renderer *)window->drawdata;
522   renderer *d3d = (renderer *)window->m_drawdata;
523523
524524   // stop any existing recording
525525   end_avi_recording();
r31854r31855
678678   if (!master_enable || !d3dintf->post_fx_available)
679679      return;
680680
681   renderer *d3d = (renderer *)window->drawdata;
681   renderer *d3d = (renderer *)window->m_drawdata;
682682
683683   if(texture != NULL)
684684   {
r31854r31855
820820   if (!master_enable || !d3dintf->post_fx_available)
821821      return;
822822
823   renderer *d3d = (renderer *)window->drawdata;
823   renderer *d3d = (renderer *)window->m_drawdata;
824824
825825   // get a pointer to the vertex buffer
826826   fsfx_vertices = (vertex *)vertbuf;
r31854r31855
892892   if (!master_enable || !d3dintf->post_fx_available)
893893      return 0;
894894
895   renderer *d3d = (renderer *)window->drawdata;
895   renderer *d3d = (renderer *)window->m_drawdata;
896896
897897   HRESULT result = (*d3dintf->device.get_render_target)(d3d->get_device(), 0, &backbuffer);
898898   if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device get_render_target call\n", (int)result);
r31854r31855
10661066   if (!master_enable || !d3dintf->post_fx_available)
10671067      return;
10681068
1069   renderer *d3d = (renderer *)window->drawdata;
1069   renderer *d3d = (renderer *)window->m_drawdata;
10701070
10711071   curr_effect = default_effect;
10721072
r31854r31855
11011101void shaders::blit(surface *dst, texture *src, surface *new_dst, D3DPRIMITIVETYPE prim_type,
11021102                  UINT32 prim_index, UINT32 prim_count, int dstw, int dsth)
11031103{
1104   renderer *d3d = (renderer *)window->drawdata;
1104   renderer *d3d = (renderer *)window->m_drawdata;
11051105
11061106   HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, dst);
11071107   if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
r31854r31855
11461146void shaders::blit(surface *dst, texture *src, surface *new_dst, D3DPRIMITIVETYPE prim_type,
11471147                  UINT32 prim_index, UINT32 prim_count)
11481148{
1149   renderer *d3d = (renderer *)window->drawdata;
1149   renderer *d3d = (renderer *)window->m_drawdata;
11501150
11511151   HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, dst);
11521152   if (result != D3D_OK) osd_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
r31854r31855
12311231   if (!master_enable || !d3dintf->post_fx_available)
12321232      return;
12331233
1234   renderer *d3d = (renderer *)window->drawdata;
1234   renderer *d3d = (renderer *)window->m_drawdata;
12351235   texture_info *texture = poly->get_texture();
12361236
12371237   if(PRIMFLAG_GET_SCREENTEX(d3d->get_last_texture_flags()) && texture != NULL)
r31854r31855
13081308
13091309void shaders::ntsc_pass(render_target *rt, vec2f &sourcedims, vec2f &delta)
13101310{
1311   renderer *d3d = (renderer *)window->drawdata;
1311   renderer *d3d = (renderer *)window->m_drawdata;
13121312   UINT num_passes = 0;
13131313
13141314   if(options->yiq_enable)
r31854r31855
13701370
13711371void shaders::color_convolution_pass(render_target *rt, vec2f &texsize, vec2f &sourcedims)
13721372{
1373   renderer *d3d = (renderer *)window->drawdata;
1373   renderer *d3d = (renderer *)window->m_drawdata;
13741374   UINT num_passes = 0;
13751375
13761376   curr_effect = color_effect;
r31854r31855
13981398
13991399void shaders::prescale_pass(render_target *rt, vec2f &texsize, vec2f &sourcedims)
14001400{
1401   renderer *d3d = (renderer *)window->drawdata;
1401   renderer *d3d = (renderer *)window->m_drawdata;
14021402   UINT num_passes = 0;
14031403
14041404   curr_effect = prescale_effect;
r31854r31855
14261426
14271427void shaders::deconverge_pass(render_target *rt, vec2f &texsize, vec2f &delta, vec2f &sourcedims)
14281428{
1429   renderer *d3d = (renderer *)window->drawdata;
1429   renderer *d3d = (renderer *)window->m_drawdata;
14301430   UINT num_passes = 0;
14311431
14321432   curr_effect = deconverge_effect;
r31854r31855
14541454
14551455void shaders::defocus_pass(render_target *rt, vec2f &texsize)
14561456{
1457   renderer *d3d = (renderer *)window->drawdata;
1457   renderer *d3d = (renderer *)window->m_drawdata;
14581458   UINT num_passes = 0;
14591459
14601460   // Defocus pass 1
r31854r31855
15031503
15041504void shaders::phosphor_pass(render_target *rt, cache_target *ct, vec2f &texsize, bool focus_enable)
15051505{
1506   renderer *d3d = (renderer *)window->drawdata;
1506   renderer *d3d = (renderer *)window->m_drawdata;
15071507   UINT num_passes = 0;
15081508
15091509   curr_effect = phosphor_effect;
r31854r31855
15611561
15621562void shaders::avi_post_pass(render_target *rt, vec2f &texsize, vec2f &delta, vec2f &sourcedims, poly_info *poly, int vertnum)
15631563{
1564   renderer *d3d = (renderer *)window->drawdata;
1564   renderer *d3d = (renderer *)window->m_drawdata;
15651565   UINT num_passes = 0;
15661566
15671567   curr_effect = post_effect;
r31854r31855
16161616
16171617void shaders::screen_post_pass(render_target *rt, vec2f &texsize, vec2f &delta, vec2f &sourcedims, poly_info *poly, int vertnum)
16181618{
1619   renderer *d3d = (renderer *)window->drawdata;
1619   renderer *d3d = (renderer *)window->m_drawdata;
16201620   UINT num_passes = 0;
16211621
16221622   curr_effect = post_effect;
r31854r31855
16501650
16511651void shaders::raster_bloom_pass(render_target *rt, vec2f &texsize, vec2f &delta, poly_info *poly, int vertnum)
16521652{
1653   renderer *d3d = (renderer *)window->drawdata;
1653   renderer *d3d = (renderer *)window->m_drawdata;
16541654   UINT num_passes = 0;
16551655
16561656   curr_effect = downsample_effect;
r31854r31855
17551755      return;
17561756
17571757   UINT num_passes = 0;
1758   renderer *d3d = (renderer *)window->drawdata;
1758   renderer *d3d = (renderer *)window->m_drawdata;
17591759   curr_texture = poly->get_texture();
17601760
17611761   if(PRIMFLAG_GET_SCREENTEX(d3d->get_last_texture_flags()) && curr_texture != NULL)
r31854r31855
20802080      return NULL;
20812081   }
20822082
2083   renderer *d3d = (renderer *)window->drawdata;
2083   renderer *d3d = (renderer *)window->m_drawdata;
20842084
20852085   return find_render_target(d3d->get_width(), d3d->get_height(), 0, 0);
20862086}
20872087
20882088void shaders::create_vector_target(render_primitive *prim)
20892089{
2090   renderer *d3d = (renderer *)window->drawdata;
2090   renderer *d3d = (renderer *)window->m_drawdata;
20912091   if (!add_render_target(d3d, NULL, d3d->get_width(), d3d->get_height(), 1, 1))
20922092   {
20932093      vector_enable = false;
r31854r31855
22022202
22032203   enumerate_screens();
22042204
2205   renderer *d3d = (renderer *)window->drawdata;
2205   renderer *d3d = (renderer *)window->m_drawdata;
22062206
22072207   int hlsl_prescale_x = prescale_force_x;
22082208   int hlsl_prescale_y = prescale_force_y;
r31854r31855
29942994   }
29952995
29962996   shaders *shadersys = m_shader->m_shaders;
2997   renderer *d3d = (renderer *)shadersys->window->drawdata;
2997   renderer *d3d = (renderer *)shadersys->window->m_drawdata;
29982998   hlsl_options *options = shadersys->options;
29992999
30003000   switch(m_id)
trunk/src/osd/windows/drawdd.c
r31854r31855
219219
220220   // allocate memory for our structures
221221   dd = global_alloc_clear(dd_info);
222   window->drawdata = dd;
222   window->m_drawdata = dd;
223223
224224   // configure the adapter for the mode we want
225225   if (config_adapter_mode(window))
r31854r31855
245245
246246static void drawdd_window_destroy(win_window_info *window)
247247{
248   dd_info *dd = (dd_info *)window->drawdata;
248   dd_info *dd = (dd_info *)window->m_drawdata;
249249
250250   // skip if nothing
251251   if (dd == NULL)
r31854r31855
256256
257257   // free the memory in the window
258258   global_free(dd);
259   window->drawdata = NULL;
259   window->m_drawdata = NULL;
260260}
261261
262262
r31854r31855
267267
268268static render_primitive_list *drawdd_window_get_primitives(win_window_info *window)
269269{
270   dd_info *dd = (dd_info *)window->drawdata;
270   dd_info *dd = (dd_info *)window->m_drawdata;
271271
272272   compute_blit_surface_size(window);
273   window->target->set_bounds(dd->blitwidth, dd->blitheight, 0);
274   window->target->set_max_update_rate((dd->refresh == 0) ? dd->origmode.dwRefreshRate : dd->refresh);
273   window->m_target->set_bounds(dd->blitwidth, dd->blitheight, 0);
274   window->m_target->set_max_update_rate((dd->refresh == 0) ? dd->origmode.dwRefreshRate : dd->refresh);
275275
276   return &window->target->get_primitives();
276   return &window->m_target->get_primitives();
277277}
278278
279279
r31854r31855
284284
285285static int drawdd_window_draw(win_window_info *window, HDC dc, int update)
286286{
287   dd_info *dd = (dd_info *)window->drawdata;
287   dd_info *dd = (dd_info *)window->m_drawdata;
288288   render_primitive *prim;
289289   int usemembuffer = FALSE;
290290   HRESULT result;
r31854r31855
324324   }
325325
326326   // render to it
327   window->primlist->acquire_lock();
327   window->m_primlist->acquire_lock();
328328
329329   // scan the list of primitives for tricky stuff
330   for (prim = window->primlist->first(); prim != NULL; prim = prim->next())
330   for (prim = window->m_primlist->first(); prim != NULL; prim = prim->next())
331331      if (PRIMFLAG_GET_BLENDMODE(prim->flags) != BLENDMODE_NONE ||
332332         (prim->texture.base != NULL && PRIMFLAG_GET_TEXFORMAT(prim->flags) == TEXFORMAT_ARGB32))
333333      {
r31854r31855
343343      // based on the target format, use one of our standard renderers
344344      switch (dd->blitdesc.ddpfPixelFormat.dwRBitMask)
345345      {
346         case 0x00ff0000:    software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(*window->primlist, dd->membuffer, dd->blitwidth, dd->blitheight, dd->blitwidth);  break;
347         case 0x000000ff:    software_renderer<UINT32, 0,0,0, 0,8,16>::draw_primitives(*window->primlist, dd->membuffer, dd->blitwidth, dd->blitheight, dd->blitwidth);  break;
348         case 0xf800:        software_renderer<UINT16, 3,2,3, 11,5,0>::draw_primitives(*window->primlist, dd->membuffer, dd->blitwidth, dd->blitheight, dd->blitwidth);  break;
349         case 0x7c00:        software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window->primlist, dd->membuffer, dd->blitwidth, dd->blitheight, dd->blitwidth);  break;
346         case 0x00ff0000:    software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(*window->m_primlist, dd->membuffer, dd->blitwidth, dd->blitheight, dd->blitwidth);  break;
347         case 0x000000ff:    software_renderer<UINT32, 0,0,0, 0,8,16>::draw_primitives(*window->m_primlist, dd->membuffer, dd->blitwidth, dd->blitheight, dd->blitwidth);  break;
348         case 0xf800:        software_renderer<UINT16, 3,2,3, 11,5,0>::draw_primitives(*window->m_primlist, dd->membuffer, dd->blitwidth, dd->blitheight, dd->blitwidth);  break;
349         case 0x7c00:        software_renderer<UINT16, 3,3,3, 10,5,0>::draw_primitives(*window->m_primlist, dd->membuffer, dd->blitwidth, dd->blitheight, dd->blitwidth);  break;
350350         default:
351351            osd_printf_verbose("DirectDraw: Unknown target mode: R=%08X G=%08X B=%08X\n", (int)dd->blitdesc.ddpfPixelFormat.dwRBitMask, (int)dd->blitdesc.ddpfPixelFormat.dwGBitMask, (int)dd->blitdesc.ddpfPixelFormat.dwBBitMask);
352352            break;
r31854r31855
379379      // based on the target format, use one of our standard renderers
380380      switch (dd->blitdesc.ddpfPixelFormat.dwRBitMask)
381381      {
382         case 0x00ff0000:    software_renderer<UINT32, 0,0,0, 16,8,0, true>::draw_primitives(*window->primlist, dd->blitdesc.lpSurface, dd->blitwidth, dd->blitheight, dd->blitdesc.lPitch / 4); break;
383         case 0x000000ff:    software_renderer<UINT32, 0,0,0, 0,8,16, true>::draw_primitives(*window->primlist, dd->blitdesc.lpSurface, dd->blitwidth, dd->blitheight, dd->blitdesc.lPitch / 4); break;
384         case 0xf800:        software_renderer<UINT16, 3,2,3, 11,5,0, true>::draw_primitives(*window->primlist, dd->blitdesc.lpSurface, dd->blitwidth, dd->blitheight, dd->blitdesc.lPitch / 2); break;
385         case 0x7c00:        software_renderer<UINT16, 3,3,3, 10,5,0, true>::draw_primitives(*window->primlist, dd->blitdesc.lpSurface, dd->blitwidth, dd->blitheight, dd->blitdesc.lPitch / 2); break;
382         case 0x00ff0000:    software_renderer<UINT32, 0,0,0, 16,8,0, true>::draw_primitives(*window->m_primlist, dd->blitdesc.lpSurface, dd->blitwidth, dd->blitheight, dd->blitdesc.lPitch / 4); break;
383         case 0x000000ff:    software_renderer<UINT32, 0,0,0, 0,8,16, true>::draw_primitives(*window->m_primlist, dd->blitdesc.lpSurface, dd->blitwidth, dd->blitheight, dd->blitdesc.lPitch / 4); break;
384         case 0xf800:        software_renderer<UINT16, 3,2,3, 11,5,0, true>::draw_primitives(*window->m_primlist, dd->blitdesc.lpSurface, dd->blitwidth, dd->blitheight, dd->blitdesc.lPitch / 2); break;
385         case 0x7c00:        software_renderer<UINT16, 3,3,3, 10,5,0, true>::draw_primitives(*window->m_primlist, dd->blitdesc.lpSurface, dd->blitwidth, dd->blitheight, dd->blitdesc.lPitch / 2); break;
386386         default:
387387            osd_printf_verbose("DirectDraw: Unknown target mode: R=%08X G=%08X B=%08X\n", (int)dd->blitdesc.ddpfPixelFormat.dwRBitMask, (int)dd->blitdesc.ddpfPixelFormat.dwGBitMask, (int)dd->blitdesc.ddpfPixelFormat.dwBBitMask);
388388            break;
389389      }
390390   }
391   window->primlist->release_lock();
391   window->m_primlist->release_lock();
392392
393393   // unlock and blit
394394   result = IDirectDrawSurface7_Unlock(dd->blit, NULL);
395395   if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X unlocking blit surface\n", (int)result);
396396
397397   // sync to VBLANK
398   if ((video_config.waitvsync || video_config.syncrefresh) && window->machine().video().throttled() && (!window->fullscreen || dd->back == NULL))
398   if ((video_config.waitvsync || video_config.syncrefresh) && window->machine().video().throttled() && (!window->m_fullscreen || dd->back == NULL))
399399   {
400400      result = IDirectDraw7_WaitForVerticalBlank(dd->ddraw, DDWAITVB_BLOCKBEGIN, NULL);
401401      if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X waiting for VBLANK\n", (int)result);
r31854r31855
414414
415415static int ddraw_create(win_window_info *window)
416416{
417   dd_info *dd = (dd_info *)window->drawdata;
417   dd_info *dd = (dd_info *)window->m_drawdata;
418418   HRESULT result;
419419   int verify;
420420
r31854r31855
442442
443443   // set the cooperative level
444444   // for non-window modes, we will use full screen here
445   result = IDirectDraw7_SetCooperativeLevel(dd->ddraw, win_window_list->hwnd, DDSCL_SETFOCUSWINDOW);
445   result = IDirectDraw7_SetCooperativeLevel(dd->ddraw, win_window_list->m_hwnd, DDSCL_SETFOCUSWINDOW);
446446   if (result != DD_OK)
447447   {
448448      osd_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_SetCooperativeLevel(FOCUSWINDOW) call\n", (int)result);
449449      goto error;
450450   }
451   result = IDirectDraw7_SetCooperativeLevel(dd->ddraw, window->hwnd, DDSCL_SETDEVICEWINDOW | (window->fullscreen ? DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE : DDSCL_NORMAL));
451   result = IDirectDraw7_SetCooperativeLevel(dd->ddraw, window->m_hwnd, DDSCL_SETDEVICEWINDOW | (window->m_fullscreen ? DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE : DDSCL_NORMAL));
452452   if (result != DD_OK)
453453   {
454454      osd_printf_verbose("DirectDraw: Error %08X during IDirectDraw7_SetCooperativeLevel(DEVICEWINDOW) call\n", (int)result);
r31854r31855
456456   }
457457
458458   // full screen mode: set the resolution
459   if (window->fullscreen && video_config.switchres)
459   if (window->m_fullscreen && video_config.switchres)
460460   {
461461      result = IDirectDraw7_SetDisplayMode(dd->ddraw, dd->width, dd->height, 32, dd->refresh, 0);
462462      if (result != DD_OK)
r31854r31855
481481
482482static int ddraw_create_surfaces(win_window_info *window)
483483{
484   dd_info *dd = (dd_info *)window->drawdata;
484   dd_info *dd = (dd_info *)window->m_drawdata;
485485   HRESULT result;
486486
487487   // make a description of the primary surface
r31854r31855
491491   dd->primarydesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
492492
493493   // for triple-buffered full screen mode, allocate flipping surfaces
494   if (window->fullscreen && video_config.triplebuf)
494   if (window->m_fullscreen && video_config.triplebuf)
495495   {
496496      dd->primarydesc.dwFlags |= DDSD_BACKBUFFERCOUNT;
497497      dd->primarydesc.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX;
r31854r31855
504504
505505   // full screen mode: get the back surface
506506   dd->back = NULL;
507   if (window->fullscreen && video_config.triplebuf)
507   if (window->m_fullscreen && video_config.triplebuf)
508508   {
509509      DDSCAPS2 caps = { DDSCAPS_BACKBUFFER };
510510      result = IDirectDrawSurface7_GetAttachedSurface(dd->primary, &caps, &dd->back);
r31854r31855
544544      goto error;
545545
546546   // create a clipper for windowed mode
547   if (!window->fullscreen && create_clipper(window))
547   if (!window->m_fullscreen && create_clipper(window))
548548      goto error;
549549
550550   // full screen mode: set the gamma
551   if (window->fullscreen)
551   if (window->m_fullscreen)
552552   {
553553      // only set the gamma if it's not 1.0f
554554      windows_options &options = downcast<windows_options &>(window->machine().options());
r31854r31855
600600
601601static void ddraw_delete(win_window_info *window)
602602{
603   dd_info *dd = (dd_info *)window->drawdata;
603   dd_info *dd = (dd_info *)window->m_drawdata;
604604
605605   // free surfaces
606606   ddraw_delete_surfaces(window);
r31854r31855
610610      IDirectDraw7_RestoreDisplayMode(dd->ddraw);
611611
612612   // reset cooperative level
613   if (dd->ddraw != NULL && window->hwnd != NULL)
614      IDirectDraw7_SetCooperativeLevel(dd->ddraw, window->hwnd, DDSCL_NORMAL);
613   if (dd->ddraw != NULL && window->m_hwnd != NULL)
614      IDirectDraw7_SetCooperativeLevel(dd->ddraw, window->m_hwnd, DDSCL_NORMAL);
615615
616616   // release the DirectDraw object itself
617617   if (dd->ddraw != NULL)
r31854r31855
627627
628628static void ddraw_delete_surfaces(win_window_info *window)
629629{
630   dd_info *dd = (dd_info *)window->drawdata;
630   dd_info *dd = (dd_info *)window->m_drawdata;
631631
632632   // release the gamma control
633633   if (dd->gamma != NULL)
r31854r31855
699699
700700static int ddraw_test_cooperative(win_window_info *window)
701701{
702   dd_info *dd = (dd_info *)window->drawdata;
702   dd_info *dd = (dd_info *)window->m_drawdata;
703703   HRESULT result;
704704
705705   // check our current status; if we lost the device, punt to GDI
r31854r31855
769769
770770static int create_clipper(win_window_info *window)
771771{
772   dd_info *dd = (dd_info *)window->drawdata;
772   dd_info *dd = (dd_info *)window->m_drawdata;
773773   HRESULT result;
774774
775775   // create a clipper for the primary surface
r31854r31855
781781   }
782782
783783   // set the clipper's hwnd
784   result = IDirectDrawClipper_SetHWnd(dd->clipper, 0, window->hwnd);
784   result = IDirectDrawClipper_SetHWnd(dd->clipper, 0, window->m_hwnd);
785785   if (result != DD_OK)
786786   {
787787      osd_printf_verbose("DirectDraw: Error %08X setting clipper hwnd\n", (int)result);
r31854r31855
806806
807807static void compute_blit_surface_size(win_window_info *window)
808808{
809   dd_info *dd = (dd_info *)window->drawdata;
809   dd_info *dd = (dd_info *)window->m_drawdata;
810810   INT32 newwidth, newheight;
811811   int xscale, yscale;
812812   RECT client;
813813
814814   // start with the minimum size
815   window->target->compute_minimum_size(newwidth, newheight);
815   window->m_target->compute_minimum_size(newwidth, newheight);
816816
817817   // get the window's client rectangle
818   GetClientRect(window->hwnd, &client);
818   GetClientRect(window->m_hwnd, &client);
819819
820820   // hardware stretch case: apply prescale
821821   if (video_config.hwstretch)
r31854r31855
842842      if (video_config.keepaspect)
843843      {
844844         win_monitor_info *monitor = winwindow_video_window_monitor(window, NULL);
845         window->target->compute_visible_area(target_width, target_height, winvideo_monitor_get_aspect(monitor), window->target->orientation(), target_width, target_height);
845         window->m_target->compute_visible_area(target_width, target_height, monitor->get_aspect(), window->m_target->orientation(), target_width, target_height);
846846         desired_aspect = (float)target_width / (float)target_height;
847847      }
848848
r31854r31855
930930
931931static void blit_to_primary(win_window_info *window, int srcwidth, int srcheight)
932932{
933   dd_info *dd = (dd_info *)window->drawdata;
933   dd_info *dd = (dd_info *)window->m_drawdata;
934934   IDirectDrawSurface7 *target = (dd->back != NULL) ? dd->back : dd->primary;
935935   win_monitor_info *monitor = winwindow_video_window_monitor(window, NULL);
936936   DDBLTFX blitfx = { sizeof(DDBLTFX) };
r31854r31855
944944   source.bottom = srcheight;
945945
946946   // compute outer rect -- windowed version
947   if (!window->fullscreen)
947   if (!window->m_fullscreen)
948948   {
949      GetClientRect(window->hwnd, &outer);
950      ClientToScreen(window->hwnd, &((LPPOINT)&outer)[0]);
951      ClientToScreen(window->hwnd, &((LPPOINT)&outer)[1]);
949      GetClientRect(window->m_hwnd, &outer);
950      ClientToScreen(window->m_hwnd, &((LPPOINT)&outer)[0]);
951      ClientToScreen(window->m_hwnd, &((LPPOINT)&outer)[1]);
952952
953953      // adjust to be relative to the monitor
954954      outer.left -= monitor->info.rcMonitor.left;
r31854r31855
987987   else if (video_config.keepaspect)
988988   {
989989      // compute the appropriate visible area
990      window->target->compute_visible_area(rect_width(&outer), rect_height(&outer), winvideo_monitor_get_aspect(monitor), window->target->orientation(), dstwidth, dstheight);
990      window->m_target->compute_visible_area(rect_width(&outer), rect_height(&outer), monitor->get_aspect(), window->m_target->orientation(), dstwidth, dstheight);
991991   }
992992
993993   // center within
r31854r31855
10501050   if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X blitting to the screen\n", (int)result);
10511051
10521052   // page flip if triple buffered
1053   if (window->fullscreen && dd->back != NULL)
1053   if (window->m_fullscreen && dd->back != NULL)
10541054   {
10551055      result = IDirectDrawSurface7_Flip(dd->primary, NULL, DDFLIP_WAIT);
10561056      if (result != DD_OK) osd_printf_verbose("DirectDraw: Error %08X waiting for VBLANK\n", (int)result);
r31854r31855
10661066static int config_adapter_mode(win_window_info *window)
10671067{
10681068   DDDEVICEIDENTIFIER2 identifier;
1069   dd_info *dd = (dd_info *)window->drawdata;
1069   dd_info *dd = (dd_info *)window->m_drawdata;
10701070   HRESULT result;
10711071
10721072   // choose the monitor number
1073   get_adapter_for_monitor(dd, window->monitor);
1073   get_adapter_for_monitor(dd, window->m_monitor);
10741074
10751075   // create a temporary DirectDraw object
10761076   result = (*directdrawcreateex)(dd->adapter_ptr, (LPVOID *)&dd->ddraw, WRAP_REFIID(IID_IDirectDraw7), NULL);
r31854r31855
11011101   }
11021102
11031103   // choose a resolution: full screen mode case
1104   if (window->fullscreen)
1104   if (window->m_fullscreen)
11051105   {
11061106      // default to the current mode exactly
11071107      dd->width = dd->origmode.dwWidth;
r31854r31855
11181118   dd->ddraw = NULL;
11191119
11201120   // if we're not changing resolutions, make sure we have a resolution we can handle
1121   if (!window->fullscreen || !video_config.switchres)
1121   if (!window->m_fullscreen || !video_config.switchres)
11221122   {
11231123      switch (dd->origmode.ddpfPixelFormat.dwRBitMask)
11241124      {
r31854r31855
11951195{
11961196   float size_score, refresh_score, final_score;
11971197   mode_enum_info *einfo = (mode_enum_info *)context;
1198   dd_info *dd = (dd_info *)einfo->window->drawdata;
1198   dd_info *dd = (dd_info *)einfo->window->m_drawdata;
11991199
12001200   // skip non-32 bit modes
12011201   if (desc->ddpfPixelFormat.dwRGBBitCount != 32)
r31854r31855
12131213      size_score *= 0.1f;
12141214
12151215   // if we're looking for a particular mode, that's a winner
1216   if (desc->dwWidth == einfo->window->maxwidth && desc->dwHeight == einfo->window->maxheight)
1216   if (desc->dwWidth == einfo->window->m_maxwidth && desc->dwHeight == einfo->window->m_maxheight)
12171217      size_score = 2.0f;
12181218
12191219   // compute refresh score
r31854r31855
12241224      refresh_score *= 0.1f;
12251225
12261226   // if we're looking for a particular refresh, make sure it matches
1227   if (desc->dwRefreshRate == einfo->window->refresh)
1227   if (desc->dwRefreshRate == einfo->window->m_refresh)
12281228      refresh_score = 2.0f;
12291229
12301230   // weight size and refresh equally
r31854r31855
12501250
12511251static void pick_best_mode(win_window_info *window)
12521252{
1253   dd_info *dd = (dd_info *)window->drawdata;
1253   dd_info *dd = (dd_info *)window->m_drawdata;
12541254   mode_enum_info einfo;
12551255   HRESULT result;
12561256
r31854r31855
12581258   // note: technically we should not be calling this from an alternate window
12591259   // thread; however, it is only done during init time, and the init code on
12601260   // the main thread is waiting for us to finish, so it is safe to do so here
1261   window->target->compute_minimum_size(einfo.minimum_width, einfo.minimum_height);
1261   window->m_target->compute_minimum_size(einfo.minimum_width, einfo.minimum_height);
12621262
12631263   // use those as the target for now
12641264   einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale);
trunk/src/osd/windows/window.c
r31854r31855
117117//  PROTOTYPES
118118//============================================================
119119
120static void winwindow_exit(running_machine &machine);
121120static void winwindow_video_window_destroy(win_window_info *window);
122121static void draw_video_contents(win_window_info *window, HDC dc, int update);
123122
r31854r31855
181180
182181
183182//============================================================
184//  winwindow_init
183//  window_init
185184//  (main thread)
186185//============================================================
187186
188void winwindow_init(running_machine &machine)
187bool windows_osd_interface::window_init()
189188{
190189   size_t temp;
191190
192191   // determine if we are using multithreading or not
193   multithreading_enabled = downcast<windows_options &>(machine.options()).multithreading();
192   multithreading_enabled = downcast<windows_options &>(machine().options()).multithreading();
194193
195194   // get the main thread ID before anything else
196195   main_threadid = GetCurrentThreadId();
197196
198   // ensure we get called on the way out
199   machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(winwindow_exit), &machine));
200
201197   // set up window class and register it
202198   create_window_class();
203199
r31854r31855
234230   // initialize the drawers
235231   if (video_config.mode == VIDEO_MODE_D3D)
236232   {
237      if (drawd3d_init(machine, &draw))
233      if (drawd3d_init(machine(), &draw))
238234         video_config.mode = VIDEO_MODE_GDI;
239235   }
240236   if (video_config.mode == VIDEO_MODE_DDRAW)
241237   {
242      if (drawdd_init(machine, &draw))
238      if (drawdd_init(machine(), &draw))
243239         video_config.mode = VIDEO_MODE_GDI;
244240   }
245241   if (video_config.mode == VIDEO_MODE_GDI)
246      drawgdi_init(machine, &draw);
242      drawgdi_init(machine(), &draw);
247243   if (video_config.mode == VIDEO_MODE_NONE)
248      drawnone_init(machine, &draw);
244      drawnone_init(machine(), &draw);
249245
250246   // set up the window list
251247   last_window_ptr = &win_window_list;
248   
249   return true;
252250}
253251
254252
r31854r31855
258256//  (main thread)
259257//============================================================
260258
261static void winwindow_exit(running_machine &machine)
259void windows_osd_interface::window_exit()
262260{
263261   assert(GetCurrentThreadId() == main_threadid);
264262
r31854r31855
266264   while (win_window_list != NULL)
267265   {
268266      win_window_info *temp = win_window_list;
269      win_window_list = temp->next;
267      win_window_list = temp->m_next;
270268      winwindow_video_window_destroy(temp);
271269   }
272270
r31854r31855
295293}
296294
297295
296win_window_info::win_window_info(running_machine &machine)
297      : m_next(NULL),
298      m_init_state(0),
299      m_hwnd(0),
300      m_focus_hwnd(0),
301      m_startmaximized(0),
302      m_isminimized(0),
303      m_ismaximized(0),
304      m_resize_state(0),
305      m_monitor(0),
306      m_fullscreen(0),
307      m_fullscreen_safe(0),
308      m_maxwidth(0),
309      m_maxheight(0),
310      m_refresh(0),
311      m_aspect(0),
312      m_render_lock(NULL),
313      m_target(NULL),
314      m_targetview(0),
315      m_targetorient(0),
316      m_primlist(NULL),       
317      m_lastclicktime(0),
318      m_lastclickx(0),
319      m_lastclicky(0),
320      m_drawdata(NULL),
321      m_machine(machine)
322{
323   memset(m_title,0,sizeof(m_title));
324   m_non_fullscreen_bounds.left = 0; 
325   m_non_fullscreen_bounds.top = 0; 
326   m_non_fullscreen_bounds.right  = 0; 
327   m_non_fullscreen_bounds.bottom = 0;
328}
298329
330win_window_info::~win_window_info()
331{
332}
333
334   
299335//============================================================
300336//  winwindow_process_events_periodic
301337//  (main thread)
r31854r31855
323359{
324360   win_window_info *window;
325361
326   for (window = win_window_list; window != NULL; window = window->next)
327      if (window->hwnd == hwnd)
362   for (window = win_window_list; window != NULL; window = window->m_next)
363      if (window->m_hwnd == hwnd)
328364         return TRUE;
329365
330366   return FALSE;
r31854r31855
473509   assert(GetCurrentThreadId() == main_threadid);
474510
475511   // iterate over windows and request a snap
476   for (window = win_window_list; window != NULL; window = window->next)
512   for (window = win_window_list; window != NULL; window = window->m_next)
477513   {
478514      (*draw.window_save)(window);
479515   }
r31854r31855
496532   assert(GetCurrentThreadId() == main_threadid);
497533
498534   // iterate over windows and request a snap
499   for (window = win_window_list; window != NULL; window = window->next)
535   for (window = win_window_list; window != NULL; window = window->m_next)
500536   {
501537      (*draw.window_toggle_fsfx)(window);
502538   }
r31854r31855
519555   assert(GetCurrentThreadId() == main_threadid);
520556
521557   // iterate over windows and request a snap
522   for (window = win_window_list; window != NULL; window = window->next)
558   for (window = win_window_list; window != NULL; window = window->m_next)
523559   {
524560      (*draw.window_record)(window);
525561   }
r31854r31855
539575   assert(GetCurrentThreadId() == main_threadid);
540576
541577   // if we are in debug mode, never go full screen
542   for (window = win_window_list; window != NULL; window = window->next)
578   for (window = win_window_list; window != NULL; window = window->m_next)
543579      if (window->machine().debug_flags & DEBUG_FLAG_OSD_ENABLED)
544580         return;
545581
r31854r31855
547583   video_config.windowed = !video_config.windowed;
548584
549585   // iterate over windows and toggle their fullscreen state
550   for (window = win_window_list; window != NULL; window = window->next)
551      SendMessage(window->hwnd, WM_USER_SET_FULLSCREEN, !video_config.windowed, 0);
552   SetForegroundWindow(win_window_list->hwnd);
586   for (window = win_window_list; window != NULL; window = window->m_next)
587      SendMessage(window->m_hwnd, WM_USER_SET_FULLSCREEN, !video_config.windowed, 0);
588   SetForegroundWindow(win_window_list->m_hwnd);
553589}
554590
555591
r31854r31855
565601   win_window_info *window;
566602
567603   // see if one of the video windows has focus
568   for (window = win_window_list; window != NULL; window = window->next)
569      if (focuswnd == window->hwnd)
604   for (window = win_window_list; window != NULL; window = window->m_next)
605      if (focuswnd == window->m_hwnd)
570606         return TRUE;
571607
572608   return FALSE;
r31854r31855
603639      GetCursorPos(&saved_cursor_pos);
604640
605641      // clip cursor to game video window
606      GetClientRect(window->hwnd, &bounds);
607      ClientToScreen(window->hwnd, &((POINT *)&bounds)[0]);
608      ClientToScreen(window->hwnd, &((POINT *)&bounds)[1]);
642      GetClientRect(window->m_hwnd, &bounds);
643      ClientToScreen(window->m_hwnd, &((POINT *)&bounds)[0]);
644      ClientToScreen(window->m_hwnd, &((POINT *)&bounds)[1]);
609645      ClipCursor(&bounds);
610646   }
611647   else
r31854r31855
638674   assert(GetCurrentThreadId() == main_threadid);
639675
640676   // allocate a new window object
641   window = global_alloc_clear(win_window_info(machine));
677   window = global_alloc(win_window_info(machine));
642678   //printf("%d, %d\n", config->width, config->height);
643   window->maxwidth = config->width;
644   window->maxheight = config->height;
645   window->refresh = config->refresh;
646   window->monitor = monitor;
647   window->fullscreen = !video_config.windowed;
679   window->m_maxwidth = config->width;
680   window->m_maxheight = config->height;
681   window->m_refresh = config->refresh;
682   window->m_monitor = monitor;
683   window->m_fullscreen = !video_config.windowed;
648684
649685   // see if we are safe for fullscreen
650   window->fullscreen_safe = TRUE;
651   for (win = win_window_list; win != NULL; win = win->next)
652      if (win->monitor == monitor)
653         window->fullscreen_safe = FALSE;
686   window->m_fullscreen_safe = TRUE;
687   for (win = win_window_list; win != NULL; win = win->m_next)
688      if (win->m_monitor == monitor)
689         window->m_fullscreen_safe = FALSE;
654690
655691   // add us to the list
656692   *last_window_ptr = window;
657   last_window_ptr = &window->next;
693   last_window_ptr = &window->m_next;
658694
659695   // create a lock that we can use to skip blitting
660   window->render_lock = osd_lock_alloc();
696   window->m_render_lock = osd_lock_alloc();
661697
662698   // load the layout
663   window->target = machine.render().target_alloc();
699   window->m_target = machine.render().target_alloc();
664700
665701   // set the specific view
666702   windows_options &options = downcast<windows_options &>(machine.options());
667703   set_starting_view(index, window, options.view(index));
668704
669705   // remember the current values in case they change
670   window->targetview = window->target->view();
671   window->targetorient = window->target->orientation();
672   window->targetlayerconfig = window->target->layer_config();
706   window->m_targetview = window->m_target->view();
707   window->m_targetorient = window->m_target->orientation();
708   window->m_targetlayerconfig = window->m_target->layer_config();
673709
674710   // make the window title
675711   if (video_config.numscreens == 1)
676      sprintf(window->title, "%s: %s [%s]", emulator_info::get_appname(), machine.system().description, machine.system().name);
712      sprintf(window->m_title, "%s: %s [%s]", emulator_info::get_appname(), machine.system().description, machine.system().name);
677713   else
678      sprintf(window->title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().description, machine.system().name, index);
714      sprintf(window->m_title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().description, machine.system().name, index);
679715
680716   // set the initial maximized state
681   window->startmaximized = options.maximize();
717   window->m_startmaximized = options.maximize();
682718
683719   // finish the window creation on the window thread
684720   if (multithreading_enabled)
r31854r31855
687723      WaitForSingleObject(window_thread_ready_event, INFINITE);
688724
689725      PostThreadMessage(window_threadid, WM_USER_FINISH_CREATE_WINDOW, 0, (LPARAM)window);
690      while (window->init_state == 0)
726      while (window->m_init_state == 0)
691727      {
692728         winwindow_process_events(machine, 0, 1); //pump the message queue
693729         Sleep(1);
694730      }
695731   }
696732   else
697      window->init_state = complete_create(window) ? -1 : 1;
733      window->m_init_state = complete_create(window) ? -1 : 1;
698734
699735   // handle error conditions
700   if (window->init_state == -1)
736   if (window->m_init_state == -1)
701737      fatalerror("Unable to complete window creation\n");
702738}
703739
r31854r31855
715751   assert(GetCurrentThreadId() == main_threadid);
716752
717753   // remove us from the list
718   for (prevptr = &win_window_list; *prevptr != NULL; prevptr = &(*prevptr)->next)
754   for (prevptr = &win_window_list; *prevptr != NULL; prevptr = &(*prevptr)->m_next)
719755      if (*prevptr == window)
720756      {
721         *prevptr = window->next;
757         *prevptr = window->m_next;
722758         break;
723759      }
724760
725761   // destroy the window
726   if (window->hwnd != NULL)
727      SendMessage(window->hwnd, WM_USER_SELF_TERMINATE, 0, 0);
762   if (window->m_hwnd != NULL)
763      SendMessage(window->m_hwnd, WM_USER_SELF_TERMINATE, 0, 0);
728764
729765   // free the render target
730   window->machine().render().target_free(window->target);
766   window->machine().render().target_free(window->m_target);
731767
732768   // free the lock
733   osd_lock_free(window->render_lock);
769   osd_lock_free(window->m_render_lock);
734770
735771   // free the window itself
736772   global_free(window);
r31854r31855
743779//  (main thread)
744780//============================================================
745781
746void winwindow_video_window_update(win_window_info *window)
782void win_window_info::update()
747783{
748784   int targetview, targetorient;
749785   render_layer_config targetlayerconfig;
r31854r31855
753789   mtlog_add("winwindow_video_window_update: begin");
754790
755791   // see if the target has changed significantly in window mode
756   targetview = window->target->view();
757   targetorient = window->target->orientation();
758   targetlayerconfig = window->target->layer_config();
759   if (targetview != window->targetview || targetorient != window->targetorient || targetlayerconfig != window->targetlayerconfig)
792   targetview = m_target->view();
793   targetorient = m_target->orientation();
794   targetlayerconfig = m_target->layer_config();
795   if (targetview != m_targetview || targetorient != m_targetorient || targetlayerconfig != m_targetlayerconfig)
760796   {
761      window->targetview = targetview;
762      window->targetorient = targetorient;
763      window->targetlayerconfig = targetlayerconfig;
797      m_targetview = targetview;
798      m_targetorient = targetorient;
799      m_targetlayerconfig = targetlayerconfig;
764800
765801      // in window mode, reminimize/maximize
766      if (!window->fullscreen)
802      if (!m_fullscreen)
767803      {
768         if (window->isminimized)
769            SendMessage(window->hwnd, WM_USER_SET_MINSIZE, 0, 0);
770         if (window->ismaximized)
771            SendMessage(window->hwnd, WM_USER_SET_MAXSIZE, 0, 0);
804         if (m_isminimized)
805            SendMessage(m_hwnd, WM_USER_SET_MINSIZE, 0, 0);
806         if (m_ismaximized)
807            SendMessage(m_hwnd, WM_USER_SET_MAXSIZE, 0, 0);
772808      }
773809   }
774810
775811   // if we're visible and running and not in the middle of a resize, draw
776   if (window->hwnd != NULL && window->target != NULL && window->drawdata != NULL)
812   if (m_hwnd != NULL && m_target != NULL && m_drawdata != NULL)
777813   {
778814      int got_lock = TRUE;
779815
780816      mtlog_add("winwindow_video_window_update: try lock");
781817
782818      // only block if we're throttled
783      if (window->machine().video().throttled() || timeGetTime() - last_update_time > 250)
784         osd_lock_acquire(window->render_lock);
819      if (machine().video().throttled() || timeGetTime() - last_update_time > 250)
820         osd_lock_acquire(m_render_lock);
785821      else
786         got_lock = osd_lock_try(window->render_lock);
822         got_lock = osd_lock_try(m_render_lock);
787823
788824      // only render if we were able to get the lock
789825      if (got_lock)
r31854r31855
793829         mtlog_add("winwindow_video_window_update: got lock");
794830
795831         // don't hold the lock; we just used it to see if rendering was still happening
796         osd_lock_release(window->render_lock);
832         osd_lock_release(m_render_lock);
797833
798834         // ensure the target bounds are up-to-date, and then get the primitives
799         primlist = (*draw.window_get_primitives)(window);
835         primlist = (*draw.window_get_primitives)(this);
800836
801837         // post a redraw request with the primitive list as a parameter
802838         last_update_time = timeGetTime();
803839         mtlog_add("winwindow_video_window_update: PostMessage start");
804840         if (multithreading_enabled)
805            PostMessage(window->hwnd, WM_USER_REDRAW, 0, (LPARAM)primlist);
841            PostMessage(m_hwnd, WM_USER_REDRAW, 0, (LPARAM)primlist);
806842         else
807            SendMessage(window->hwnd, WM_USER_REDRAW, 0, (LPARAM)primlist);
843            SendMessage(m_hwnd, WM_USER_REDRAW, 0, (LPARAM)primlist);
808844         mtlog_add("winwindow_video_window_update: PostMessage end");
809845      }
810846   }
r31854r31855
824860   win_monitor_info *monitor;
825861
826862   // in window mode, find the nearest
827   if (!window->fullscreen)
863   if (!window->m_fullscreen)
828864   {
829865      if (proposed != NULL)
830866         monitor = winvideo_monitor_from_handle(MonitorFromRect(proposed, MONITOR_DEFAULTTONEAREST));
831867      else
832         monitor = winvideo_monitor_from_handle(MonitorFromWindow(window->hwnd, MONITOR_DEFAULTTONEAREST));
868         monitor = winvideo_monitor_from_handle(MonitorFromWindow(window->m_hwnd, MONITOR_DEFAULTTONEAREST));
833869   }
834870
835871   // in full screen, just use the configured monitor
836872   else
837      monitor = window->monitor;
873      monitor = window->m_monitor;
838874
839875   // make sure we're up-to-date
840   winvideo_monitor_refresh(monitor);
876   monitor->refresh();
841877   return monitor;
842878}
843879
r31854r31855
891927      view = defview;
892928
893929   // query the video system to help us pick a view
894   viewindex = window->target->configured_view(view, index, video_config.numscreens);
930   viewindex = window->m_target->configured_view(view, index, video_config.numscreens);
895931
896932   // set the view
897   window->target->set_view(viewindex);
933   window->m_target->set_view(viewindex);
898934}
899935
900936
r31854r31855
10141050INLINE int wnd_extra_width(win_window_info *window)
10151051{
10161052   RECT temprect = { 100, 100, 200, 200 };
1017   if (window->fullscreen)
1053   if (window->m_fullscreen)
10181054      return 0;
10191055   AdjustWindowRectEx(&temprect, WINDOW_STYLE, win_has_menu(window), WINDOW_STYLE_EX);
10201056   return rect_width(&temprect) - 100;
r31854r31855
10301066INLINE int wnd_extra_height(win_window_info *window)
10311067{
10321068   RECT temprect = { 100, 100, 200, 200 };
1033   if (window->fullscreen)
1069   if (window->m_fullscreen)
10341070      return 0;
10351071   AdjustWindowRectEx(&temprect, WINDOW_STYLE, win_has_menu(window), WINDOW_STYLE_EX);
10361072   return rect_height(&temprect) - 100;
r31854r31855
11151151            case WM_USER_FINISH_CREATE_WINDOW:
11161152            {
11171153               win_window_info *window = (win_window_info *)message.lParam;
1118               window->init_state = complete_create(window) ? -1 : 1;
1154               window->m_init_state = complete_create(window) ? -1 : 1;
11191155               dispatch = FALSE;
11201156               break;
11211157            }
r31854r31855
11491185   assert(GetCurrentThreadId() == window_threadid);
11501186
11511187   // get the monitor bounds
1152   monitorbounds = window->monitor->info.rcMonitor;
1188   monitorbounds = window->m_monitor->info.rcMonitor;
11531189
11541190   // create the window menu if needed
11551191   if (downcast<windows_options &>(window->machine().options()).menu())
r31854r31855
11591195   }
11601196
11611197   // create the window, but don't show it yet
1162   window->hwnd = win_create_window_ex_utf8(
1163                  window->fullscreen ? FULLSCREEN_STYLE_EX : WINDOW_STYLE_EX,
1198   window->m_hwnd = win_create_window_ex_utf8(
1199                  window->m_fullscreen ? FULLSCREEN_STYLE_EX : WINDOW_STYLE_EX,
11641200                  "MAME",
1165                  window->title,
1166                  window->fullscreen ? FULLSCREEN_STYLE : WINDOW_STYLE,
1201                  window->m_title,
1202                  window->m_fullscreen ? FULLSCREEN_STYLE : WINDOW_STYLE,
11671203                  monitorbounds.left + 20, monitorbounds.top + 20,
11681204                  monitorbounds.left + 100, monitorbounds.top + 100,
1169                  NULL,//(win_window_list != NULL) ? win_window_list->hwnd : NULL,
1205                  NULL,//(win_window_list != NULL) ? win_window_list->m_hwnd : NULL,
11701206                  menu,
11711207                  GetModuleHandle(NULL),
11721208                  NULL);
1173   if (window->hwnd == NULL)
1209   if (window->m_hwnd == NULL)
11741210      return 1;
11751211
11761212   // set window #0 as the focus window for all windows, required for D3D & multimonitor
1177   window->focus_hwnd = win_window_list->hwnd;
1213   window->m_focus_hwnd = win_window_list->m_hwnd;
11781214
11791215   // set a pointer back to us
1180   SetWindowLongPtr(window->hwnd, GWLP_USERDATA, (LONG_PTR)window);
1216   SetWindowLongPtr(window->m_hwnd, GWLP_USERDATA, (LONG_PTR)window);
11811217
11821218   // skip the positioning stuff for -video none */
11831219   if (video_config.mode == VIDEO_MODE_NONE)
11841220      return 0;
11851221
11861222   // adjust the window position to the initial width/height
1187   tempwidth = (window->maxwidth != 0) ? window->maxwidth : 640;
1188   tempheight = (window->maxheight != 0) ? window->maxheight : 480;
1189   SetWindowPos(window->hwnd, NULL, monitorbounds.left + 20, monitorbounds.top + 20,
1223   tempwidth = (window->m_maxwidth != 0) ? window->m_maxwidth : 640;
1224   tempheight = (window->m_maxheight != 0) ? window->m_maxheight : 480;
1225   SetWindowPos(window->m_hwnd, NULL, monitorbounds.left + 20, monitorbounds.top + 20,
11901226         monitorbounds.left + tempwidth + wnd_extra_width(window),
11911227         monitorbounds.top + tempheight + wnd_extra_height(window),
11921228         SWP_NOZORDER);
11931229
11941230   // maximum or minimize as appropriate
1195   if (window->startmaximized)
1231   if (window->m_startmaximized)
11961232      maximize_window(window);
11971233   else
11981234      minimize_window(window);
11991235   adjust_window_position_after_major_change(window);
12001236
12011237   // show the window
1202   if (!window->fullscreen || window->fullscreen_safe)
1238   if (!window->m_fullscreen || window->m_fullscreen_safe)
12031239   {
12041240      // finish off by trying to initialize DirectX; if we fail, ignore it
12051241      if ((*draw.window_init)(window))
12061242         return 1;
1207      ShowWindow(window->hwnd, SW_SHOW);
1243      ShowWindow(window->m_hwnd, SW_SHOW);
12081244   }
12091245
12101246   // clear the window
1211   dc = GetDC(window->hwnd);
1212   GetClientRect(window->hwnd, &client);
1247   dc = GetDC(window->m_hwnd);
1248   GetClientRect(window->m_hwnd, &client);
12131249   FillRect(dc, &client, (HBRUSH)GetStockObject(BLACK_BRUSH));
1214   ReleaseDC(window->hwnd, dc);
1250   ReleaseDC(window->m_hwnd, dc);
12151251   return 0;
12161252}
12171253
r31854r31855
12441280         HDC hdc = BeginPaint(wnd, &pstruct);
12451281         draw_video_contents(window, hdc, TRUE);
12461282         if (win_has_menu(window))
1247            DrawMenuBar(window->hwnd);
1283            DrawMenuBar(window->m_hwnd);
12481284         EndPaint(wnd, &pstruct);
12491285         break;
12501286      }
12511287
12521288      // non-client paint: punt if full screen
12531289      case WM_NCPAINT:
1254         if (!window->fullscreen || win_has_menu(window))
1290         if (!window->m_fullscreen || win_has_menu(window))
12551291            return DefWindowProc(wnd, message, wparam, lparam);
12561292         break;
12571293
r31854r31855
12671303
12681304      // input events
12691305      case WM_MOUSEMOVE:
1270         ui_input_push_mouse_move_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
1306         ui_input_push_mouse_move_event(window->machine(), window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
12711307         break;
12721308
12731309      case WM_MOUSELEAVE:
1274         ui_input_push_mouse_leave_event(window->machine(), window->target);
1310         ui_input_push_mouse_leave_event(window->machine(), window->m_target);
12751311         break;
12761312
12771313      case WM_LBUTTONDOWN:
12781314      {
12791315         DWORD ticks = GetTickCount();
1280         ui_input_push_mouse_down_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
1316         ui_input_push_mouse_down_event(window->machine(), window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
12811317
12821318         // check for a double-click
1283         if (ticks - window->lastclicktime < GetDoubleClickTime() &&
1284            GET_X_LPARAM(lparam) >= window->lastclickx - 4 && GET_X_LPARAM(lparam) <= window->lastclickx + 4 &&
1285            GET_Y_LPARAM(lparam) >= window->lastclicky - 4 && GET_Y_LPARAM(lparam) <= window->lastclicky + 4)
1319         if (ticks - window->m_lastclicktime < GetDoubleClickTime() &&
1320            GET_X_LPARAM(lparam) >= window->m_lastclickx - 4 && GET_X_LPARAM(lparam) <= window->m_lastclickx + 4 &&
1321            GET_Y_LPARAM(lparam) >= window->m_lastclicky - 4 && GET_Y_LPARAM(lparam) <= window->m_lastclicky + 4)
12861322         {
1287            window->lastclicktime = 0;
1288            ui_input_push_mouse_double_click_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
1323            window->m_lastclicktime = 0;
1324            ui_input_push_mouse_double_click_event(window->machine(), window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
12891325         }
12901326         else
12911327         {
1292            window->lastclicktime = ticks;
1293            window->lastclickx = GET_X_LPARAM(lparam);
1294            window->lastclicky = GET_Y_LPARAM(lparam);
1328            window->m_lastclicktime = ticks;
1329            window->m_lastclickx = GET_X_LPARAM(lparam);
1330            window->m_lastclicky = GET_Y_LPARAM(lparam);
12951331         }
12961332         break;
12971333      }
12981334
12991335      case WM_LBUTTONUP:
1300         ui_input_push_mouse_up_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
1336         ui_input_push_mouse_up_event(window->machine(), window->m_target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
13011337         break;
13021338
13031339      case WM_CHAR:
1304         ui_input_push_char_event(window->machine(), window->target, (unicode_char) wparam);
1340         ui_input_push_char_event(window->machine(), window->m_target, (unicode_char) wparam);
13051341         break;
13061342
13071343      // pause the system when we start a menu or resize
13081344      case WM_ENTERSIZEMOVE:
1309         window->resize_state = RESIZE_STATE_RESIZING;
1345         window->m_resize_state = RESIZE_STATE_RESIZING;
13101346      case WM_ENTERMENULOOP:
13111347         winwindow_ui_pause_from_window_thread(window->machine(), TRUE);
13121348         break;
13131349
13141350      // unpause the system when we stop a menu or resize and force a redraw
13151351      case WM_EXITSIZEMOVE:
1316         window->resize_state = RESIZE_STATE_PENDING;
1352         window->m_resize_state = RESIZE_STATE_PENDING;
13171353      case WM_EXITMENULOOP:
13181354         winwindow_ui_pause_from_window_thread(window->machine(), FALSE);
13191355         InvalidateRect(wnd, NULL, FALSE);
r31854r31855
13541390         if (cmd == SC_MAXIMIZE)
13551391         {
13561392            update_minmax_state(window);
1357            if (window->ismaximized)
1393            if (window->m_ismaximized)
13581394               minimize_window(window);
13591395            else
13601396               maximize_window(window);
r31854r31855
13791415      // destroy: clean up all attached rendering bits and NULL out our hwnd
13801416      case WM_DESTROY:
13811417         (*draw.window_destroy)(window);
1382         window->hwnd = NULL;
1418         window->m_hwnd = NULL;
13831419         return DefWindowProc(wnd, message, wparam, lparam);
13841420
13851421      // self redraw: draw ourself in a non-painty way
r31854r31855
13881424         HDC hdc = GetDC(wnd);
13891425
13901426         mtlog_add("winwindow_video_window_proc: WM_USER_REDRAW begin");
1391         window->primlist = (render_primitive_list *)lparam;
1427         window->m_primlist = (render_primitive_list *)lparam;
13921428         draw_video_contents(window, hdc, FALSE);
13931429         mtlog_add("winwindow_video_window_proc: WM_USER_REDRAW end");
13941430
r31854r31855
13981434
13991435      // self destruct
14001436      case WM_USER_SELF_TERMINATE:
1401         DestroyWindow(window->hwnd);
1437         DestroyWindow(window->m_hwnd);
14021438         break;
14031439
14041440      // fullscreen set
r31854r31855
14201456      // commented out ATM because this prevents us from resizing secondary windows
14211457//      case WM_SETFOCUS:
14221458//          if (window != win_window_list && win_window_list != NULL)
1423//              SetFocus(win_window_list->hwnd);
1459//              SetFocus(win_window_list->m_hwnd);
14241460//          break;
14251461
14261462      // everything else: defaults
r31854r31855
14451481   mtlog_add("draw_video_contents: begin");
14461482
14471483   mtlog_add("draw_video_contents: render lock acquire");
1448   osd_lock_acquire(window->render_lock);
1484   osd_lock_acquire(window->m_render_lock);
14491485   mtlog_add("draw_video_contents: render lock acquired");
14501486
14511487   // if we're iconic, don't bother
1452   if (window->hwnd != NULL && !IsIconic(window->hwnd))
1488   if (window->m_hwnd != NULL && !IsIconic(window->m_hwnd))
14531489   {
14541490      // if no bitmap, just fill
1455      if (window->primlist == NULL)
1491      if (window->m_primlist == NULL)
14561492      {
14571493         RECT fill;
1458         GetClientRect(window->hwnd, &fill);
1494         GetClientRect(window->m_hwnd, &fill);
14591495         FillRect(dc, &fill, (HBRUSH)GetStockObject(BLACK_BRUSH));
14601496      }
14611497
r31854r31855
14671503      }
14681504   }
14691505
1470   osd_lock_release(window->render_lock);
1506   osd_lock_release(window->m_render_lock);
14711507   mtlog_add("draw_video_contents: render lock released");
14721508
14731509   mtlog_add("draw_video_contents: end");
r31854r31855
14951531   assert(GetCurrentThreadId() == window_threadid);
14961532
14971533   // get the pixel aspect ratio for the target monitor
1498   pixel_aspect = winvideo_monitor_get_aspect(monitor);
1534   pixel_aspect = monitor->get_aspect();
14991535
15001536   // determine the proposed width/height
15011537   propwidth = rect_width(rect) - extrawidth;
r31854r31855
15071543   {
15081544      case WMSZ_BOTTOM:
15091545      case WMSZ_TOP:
1510         window->target->compute_visible_area(10000, propheight, pixel_aspect, window->target->orientation(), propwidth, propheight);
1546         window->m_target->compute_visible_area(10000, propheight, pixel_aspect, window->m_target->orientation(), propwidth, propheight);
15111547         break;
15121548
15131549      case WMSZ_LEFT:
15141550      case WMSZ_RIGHT:
1515         window->target->compute_visible_area(propwidth, 10000, pixel_aspect, window->target->orientation(), propwidth, propheight);
1551         window->m_target->compute_visible_area(propwidth, 10000, pixel_aspect, window->m_target->orientation(), propwidth, propheight);
15161552         break;
15171553
15181554      default:
1519         window->target->compute_visible_area(propwidth, propheight, pixel_aspect, window->target->orientation(), propwidth, propheight);
1555         window->m_target->compute_visible_area(propwidth, propheight, pixel_aspect, window->m_target->orientation(), propwidth, propheight);
15201556         break;
15211557   }
15221558
15231559   // get the minimum width/height for the current layout
1524   window->target->compute_minimum_size(minwidth, minheight);
1560   window->m_target->compute_minimum_size(minwidth, minheight);
15251561
15261562   // clamp against the absolute minimum
15271563   propwidth = MAX(propwidth, MIN_WINDOW_DIM);
r31854r31855
15321568   propheight = MAX(propheight, minheight);
15331569
15341570   // clamp against the maximum (fit on one screen for full screen mode)
1535   if (window->fullscreen)
1571   if (window->m_fullscreen)
15361572   {
15371573      maxwidth = rect_width(&monitor->info.rcMonitor) - extrawidth;
15381574      maxheight = rect_height(&monitor->info.rcMonitor) - extraheight;
r31854r31855
15431579      maxheight = rect_height(&monitor->info.rcWork) - extraheight;
15441580
15451581      // further clamp to the maximum width/height in the window
1546      if (window->maxwidth != 0)
1547         maxwidth = MIN(maxwidth, window->maxwidth + extrawidth);
1548      if (window->maxheight != 0)
1549         maxheight = MIN(maxheight, window->maxheight + extraheight);
1582      if (window->m_maxwidth != 0)
1583         maxwidth = MIN(maxwidth, window->m_maxwidth + extrawidth);
1584      if (window->m_maxheight != 0)
1585         maxheight = MIN(maxheight, window->m_maxheight + extraheight);
15501586   }
15511587
15521588   // clamp to the maximum
r31854r31855
15541590   propheight = MIN(propheight, maxheight);
15551591
15561592   // compute the visible area based on the proposed rectangle
1557   window->target->compute_visible_area(propwidth, propheight, pixel_aspect, window->target->orientation(), viswidth, visheight);
1593   window->m_target->compute_visible_area(propwidth, propheight, pixel_aspect, window->m_target->orientation(), viswidth, visheight);
15581594
15591595   // compute the adjustments we need to make
15601596   adjwidth = (viswidth + extrawidth) - rect_width(rect);
r31854r31855
16031639   assert(GetCurrentThreadId() == window_threadid);
16041640
16051641   // get the minimum target size
1606   window->target->compute_minimum_size(minwidth, minheight);
1642   window->m_target->compute_minimum_size(minwidth, minheight);
16071643
16081644   // expand to our minimum dimensions
16091645   if (minwidth < MIN_WINDOW_DIM)
r31854r31855
16461682   }
16471683
16481684   // get the window rect
1649   GetWindowRect(window->hwnd, bounds);
1685   GetWindowRect(window->m_hwnd, bounds);
16501686
16511687   // now adjust
16521688   bounds->right = bounds->left + minwidth;
r31854r31855
16671703   assert(GetCurrentThreadId() == window_threadid);
16681704
16691705   // compute the maximum client area
1670   winvideo_monitor_refresh(window->monitor);
1671   maximum = window->monitor->info.rcWork;
1706   window->m_monitor->refresh();
1707   maximum = window->m_monitor->info.rcWork;
16721708
16731709   // clamp to the window's max
1674   if (window->maxwidth != 0)
1710   if (window->m_maxwidth != 0)
16751711   {
1676      int temp = window->maxwidth + wnd_extra_width(window);
1712      int temp = window->m_maxwidth + wnd_extra_width(window);
16771713      if (temp < rect_width(&maximum))
16781714         maximum.right = maximum.left + temp;
16791715   }
1680   if (window->maxheight != 0)
1716   if (window->m_maxheight != 0)
16811717   {
1682      int temp = window->maxheight + wnd_extra_height(window);
1718      int temp = window->m_maxheight + wnd_extra_height(window);
16831719      if (temp < rect_height(&maximum))
16841720         maximum.bottom = maximum.top + temp;
16851721   }
r31854r31855
16941730   }
16951731
16961732   // center within the work area
1697   bounds->left = window->monitor->info.rcWork.left + (rect_width(&window->monitor->info.rcWork) - rect_width(&maximum)) / 2;
1698   bounds->top = window->monitor->info.rcWork.top + (rect_height(&window->monitor->info.rcWork) - rect_height(&maximum)) / 2;
1733   bounds->left = window->m_monitor->info.rcWork.left + (rect_width(&window->m_monitor->info.rcWork) - rect_width(&maximum)) / 2;
1734   bounds->top = window->m_monitor->info.rcWork.top + (rect_height(&window->m_monitor->info.rcWork) - rect_height(&maximum)) / 2;
16991735   bounds->right = bounds->left + rect_width(&maximum);
17001736   bounds->bottom = bounds->top + rect_height(&maximum);
17011737}
r31854r31855
17111747{
17121748   assert(GetCurrentThreadId() == window_threadid);
17131749
1714   if (!window->fullscreen)
1750   if (!window->m_fullscreen)
17151751   {
17161752      RECT bounds, minbounds, maxbounds;
17171753
17181754      // compare the maximum bounds versus the current bounds
17191755      get_min_bounds(window, &minbounds, video_config.keepaspect);
17201756      get_max_bounds(window, &maxbounds, video_config.keepaspect);
1721      GetWindowRect(window->hwnd, &bounds);
1757      GetWindowRect(window->m_hwnd, &bounds);
17221758
17231759      // if either the width or height matches, we were maximized
1724      window->isminimized = (rect_width(&bounds) == rect_width(&minbounds) ||
1760      window->m_isminimized = (rect_width(&bounds) == rect_width(&minbounds) ||
17251761                        rect_height(&bounds) == rect_height(&minbounds));
1726      window->ismaximized = (rect_width(&bounds) == rect_width(&maxbounds) ||
1762      window->m_ismaximized = (rect_width(&bounds) == rect_width(&maxbounds) ||
17271763                        rect_height(&bounds) == rect_height(&maxbounds));
17281764   }
17291765   else
17301766   {
1731      window->isminimized = FALSE;
1732      window->ismaximized = TRUE;
1767      window->m_isminimized = FALSE;
1768      window->m_ismaximized = TRUE;
17331769   }
17341770}
17351771
r31854r31855
17471783   assert(GetCurrentThreadId() == window_threadid);
17481784
17491785   get_min_bounds(window, &newsize, video_config.keepaspect);
1750   SetWindowPos(window->hwnd, NULL, newsize.left, newsize.top, rect_width(&newsize), rect_height(&newsize), SWP_NOZORDER);
1786   SetWindowPos(window->m_hwnd, NULL, newsize.left, newsize.top, rect_width(&newsize), rect_height(&newsize), SWP_NOZORDER);
17511787}
17521788
17531789
r31854r31855
17641800   assert(GetCurrentThreadId() == window_threadid);
17651801
17661802   get_max_bounds(window, &newsize, video_config.keepaspect);
1767   SetWindowPos(window->hwnd, NULL, newsize.left, newsize.top, rect_width(&newsize), rect_height(&newsize), SWP_NOZORDER);
1803   SetWindowPos(window->m_hwnd, NULL, newsize.left, newsize.top, rect_width(&newsize), rect_height(&newsize), SWP_NOZORDER);
17681804}
17691805
17701806
r31854r31855
17811817   assert(GetCurrentThreadId() == window_threadid);
17821818
17831819   // get the current size
1784   GetWindowRect(window->hwnd, &oldrect);
1820   GetWindowRect(window->m_hwnd, &oldrect);
17851821
17861822   // adjust the window size so the client area is what we want
1787   if (!window->fullscreen)
1823   if (!window->m_fullscreen)
17881824   {
17891825      // constrain the existing size to the aspect ratio
17901826      newrect = oldrect;
r31854r31855
18021838   // adjust the position if different
18031839   if (oldrect.left != newrect.left || oldrect.top != newrect.top ||
18041840      oldrect.right != newrect.right || oldrect.bottom != newrect.bottom)
1805      SetWindowPos(window->hwnd, window->fullscreen ? HWND_TOPMOST : HWND_TOP,
1841      SetWindowPos(window->m_hwnd, window->m_fullscreen ? HWND_TOPMOST : HWND_TOP,
18061842            newrect.left, newrect.top,
18071843            rect_width(&newrect), rect_height(&newrect), 0);
18081844
r31854r31855
18271863   assert(GetCurrentThreadId() == window_threadid);
18281864
18291865   // if we're in the right state, punt
1830   if (window->fullscreen == fullscreen)
1866   if (window->m_fullscreen == fullscreen)
18311867      return;
1832   window->fullscreen = fullscreen;
1868   window->m_fullscreen = fullscreen;
18331869
18341870   // kill off the drawers
18351871   (*draw.window_destroy)(window);
18361872
18371873   // hide ourself
1838   ShowWindow(window->hwnd, SW_HIDE);
1874   ShowWindow(window->m_hwnd, SW_HIDE);
18391875
18401876   // configure the window if non-fullscreen
18411877   if (!fullscreen)
18421878   {
18431879      // adjust the style
1844      SetWindowLong(window->hwnd, GWL_STYLE, WINDOW_STYLE);
1845      SetWindowLong(window->hwnd, GWL_EXSTYLE, WINDOW_STYLE_EX);
1846      SetWindowPos(window->hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
1880      SetWindowLong(window->m_hwnd, GWL_STYLE, WINDOW_STYLE);
1881      SetWindowLong(window->m_hwnd, GWL_EXSTYLE, WINDOW_STYLE_EX);
1882      SetWindowPos(window->m_hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
18471883
18481884      // force to the bottom, then back on top
1849      SetWindowPos(window->hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
1850      SetWindowPos(window->hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
1885      SetWindowPos(window->m_hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
1886      SetWindowPos(window->m_hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
18511887
18521888      // if we have previous non-fullscreen bounds, use those
1853      if (window->non_fullscreen_bounds.right != window->non_fullscreen_bounds.left)
1889      if (window->m_non_fullscreen_bounds.right != window->m_non_fullscreen_bounds.left)
18541890      {
1855         SetWindowPos(window->hwnd, HWND_TOP, window->non_fullscreen_bounds.left, window->non_fullscreen_bounds.top,
1856                  rect_width(&window->non_fullscreen_bounds), rect_height(&window->non_fullscreen_bounds),
1891         SetWindowPos(window->m_hwnd, HWND_TOP, window->m_non_fullscreen_bounds.left, window->m_non_fullscreen_bounds.top,
1892                  rect_width(&window->m_non_fullscreen_bounds), rect_height(&window->m_non_fullscreen_bounds),
18571893                  SWP_NOZORDER);
18581894      }
18591895
18601896      // otherwise, set a small size and maximize from there
18611897      else
18621898      {
1863         SetWindowPos(window->hwnd, HWND_TOP, 0, 0, MIN_WINDOW_DIM, MIN_WINDOW_DIM, SWP_NOZORDER);
1899         SetWindowPos(window->m_hwnd, HWND_TOP, 0, 0, MIN_WINDOW_DIM, MIN_WINDOW_DIM, SWP_NOZORDER);
18641900         maximize_window(window);
18651901      }
18661902   }
r31854r31855
18691905   else
18701906   {
18711907      // save the bounds
1872      GetWindowRect(window->hwnd, &window->non_fullscreen_bounds);
1908      GetWindowRect(window->m_hwnd, &window->m_non_fullscreen_bounds);
18731909
18741910      // adjust the style
1875      SetWindowLong(window->hwnd, GWL_STYLE, FULLSCREEN_STYLE);
1876      SetWindowLong(window->hwnd, GWL_EXSTYLE, FULLSCREEN_STYLE_EX);
1877      SetWindowPos(window->hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
1911      SetWindowLong(window->m_hwnd, GWL_STYLE, FULLSCREEN_STYLE);
1912      SetWindowLong(window->m_hwnd, GWL_EXSTYLE, FULLSCREEN_STYLE_EX);
1913      SetWindowPos(window->m_hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
18781914
18791915      // set topmost
1880      SetWindowPos(window->hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
1916      SetWindowPos(window->m_hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
18811917   }
18821918
18831919   // adjust the window to compensate for the change
18841920   adjust_window_position_after_major_change(window);
18851921
18861922   // show ourself
1887   if (!window->fullscreen || window->fullscreen_safe)
1923   if (!window->m_fullscreen || window->m_fullscreen_safe)
18881924   {
18891925      if (video_config.mode != VIDEO_MODE_NONE)
1890         ShowWindow(window->hwnd, SW_SHOW);
1926         ShowWindow(window->m_hwnd, SW_SHOW);
18911927      if ((*draw.window_init)(window))
18921928         exit(1);
18931929   }
trunk/src/osd/windows/window.h
r31854r31855
3232//  TYPE DEFINITIONS
3333//============================================================
3434
35struct win_window_info
35class win_window_info
3636{
3737public:
38   win_window_info(running_machine &machine)
39      : m_machine(machine) { }
38   win_window_info(running_machine &machine);
39   virtual ~win_window_info();     
4040
4141   running_machine &machine() const { return m_machine; }
4242
43   win_window_info *   next;
44   volatile int        init_state;
43   void update();
44   
45   win_window_info *   m_next;
46   volatile int        m_init_state;
4547
4648   // window handle and info
47   HWND                hwnd;
48   HWND                focus_hwnd;
49   char                title[256];
50   RECT                non_fullscreen_bounds;
51   int                 startmaximized;
52   int                 isminimized;
53   int                 ismaximized;
54   int                 resize_state;
49   HWND                m_hwnd;
50   HWND                m_focus_hwnd;
51   char                m_title[256];
52   RECT                m_non_fullscreen_bounds;
53   int                 m_startmaximized;
54   int                 m_isminimized;
55   int                 m_ismaximized;
56   int                 m_resize_state;
5557
5658   // monitor info
57   win_monitor_info *  monitor;
58   int                 fullscreen;
59   int                 fullscreen_safe;
60   int                 maxwidth, maxheight;
61   int                 refresh;
62   float               aspect;
59   win_monitor_info *  m_monitor;
60   int                 m_fullscreen;
61   int                 m_fullscreen_safe;
62   int                 m_maxwidth, m_maxheight;
63   int                 m_refresh;
64   float               m_aspect;
6365
6466   // rendering info
65   osd_lock *          render_lock;
66   render_target *     target;
67   int                 targetview;
68   int                 targetorient;
69   render_layer_config targetlayerconfig;
70   render_primitive_list *primlist;
67   osd_lock *          m_render_lock;
68   render_target *     m_target;
69   int                 m_targetview;
70   int                 m_targetorient;
71   render_layer_config m_targetlayerconfig;
72   render_primitive_list *m_primlist;
7173
7274   // input info
73   DWORD               lastclicktime;
74   int                 lastclickx;
75   int                 lastclicky;
75   DWORD               m_lastclicktime;
76   int                 m_lastclickx;
77   int                 m_lastclicky;
7678
7779   // drawing data
78   void *              drawdata;
80   void *              m_drawdata;
7981
8082private:
8183   running_machine &   m_machine;
r31854r31855
110112//  PROTOTYPES
111113//============================================================
112114
113// core initialization
114void winwindow_init(running_machine &machine);
115
116115// creation/deletion of windows
117116void winwindow_video_window_create(running_machine &machine, int index, win_monitor_info *monitor, const win_window_config *config);
118117
119118BOOL winwindow_has_focus(void);
120119void winwindow_update_cursor_state(running_machine &machine);
121void winwindow_video_window_update(win_window_info *window);
122120win_monitor_info *winwindow_video_window_monitor(win_window_info *window, const RECT *proposed);
123121
124122LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam);
r31854r31855
149147
150148INLINE BOOL win_has_menu(win_window_info *window)
151149{
152   return GetMenu(window->hwnd) ? TRUE : FALSE;
150   return GetMenu(window->m_hwnd) ? TRUE : FALSE;
153151}
154152
155153
trunk/src/osd/windows/drawgdi.c
r31854r31855
8282{
8383   // allocate memory for our structures
8484   gdi_info *gdi = global_alloc_clear(gdi_info);
85   window->drawdata = gdi;
85   window->m_drawdata = gdi;
8686
8787   // fill in the bitmap info header
8888   gdi->bminfo.bmiHeader.biSize            = sizeof(gdi->bminfo.bmiHeader);
r31854r31855
106106
107107static void drawgdi_window_destroy(win_window_info *window)
108108{
109   gdi_info *gdi = (gdi_info *)window->drawdata;
109   gdi_info *gdi = (gdi_info *)window->m_drawdata;
110110
111111   // skip if nothing
112112   if (gdi == NULL)
r31854r31855
116116   if (gdi->bmdata != NULL)
117117      global_free_array(gdi->bmdata);
118118   global_free(gdi);
119   window->drawdata = NULL;
119   window->m_drawdata = NULL;
120120}
121121
122122
r31854r31855
128128static render_primitive_list *drawgdi_window_get_primitives(win_window_info *window)
129129{
130130   RECT client;
131   GetClientRect(window->hwnd, &client);
132   window->target->set_bounds(rect_width(&client), rect_height(&client), winvideo_monitor_get_aspect(window->monitor));
133   return &window->target->get_primitives();
131   GetClientRect(window->m_hwnd, &client);
132   window->m_target->set_bounds(rect_width(&client), rect_height(&client), window->m_monitor->get_aspect());
133   return &window->m_target->get_primitives();
134134}
135135
136136
r31854r31855
141141
142142static int drawgdi_window_draw(win_window_info *window, HDC dc, int update)
143143{
144   gdi_info *gdi = (gdi_info *)window->drawdata;
144   gdi_info *gdi = (gdi_info *)window->m_drawdata;
145145   int width, height, pitch;
146146   RECT bounds;
147147
148148   // we don't have any special resize behaviors
149   if (window->resize_state == RESIZE_STATE_PENDING)
150      window->resize_state = RESIZE_STATE_NORMAL;
149   if (window->m_resize_state == RESIZE_STATE_PENDING)
150      window->m_resize_state = RESIZE_STATE_NORMAL;
151151
152152   // get the target bounds
153   GetClientRect(window->hwnd, &bounds);
153   GetClientRect(window->m_hwnd, &bounds);
154154
155155   // compute width/height/pitch of target
156156   width = rect_width(&bounds);
r31854r31855
166166   }
167167
168168   // draw the primitives to the bitmap
169   window->primlist->acquire_lock();
170   software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(*window->primlist, gdi->bmdata, width, height, pitch);
171   window->primlist->release_lock();
169   window->m_primlist->acquire_lock();
170   software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(*window->m_primlist, gdi->bmdata, width, height, pitch);
171   window->m_primlist->release_lock();
172172
173173   // fill in bitmap-specific info
174174   gdi->bminfo.bmiHeader.biWidth = pitch;
trunk/src/osd/osdepend.c
r31854r31855
417417   return true;
418418}
419419
420bool osd_interface::window_init()
421{
422   return true;
423}
424
420425bool osd_interface::sound_init()
421426{
422427   osd_sound_type sound = m_sound_options.find(machine().options().sound());
r31854r31855
495500{
496501}
497502
503void osd_interface::window_exit()
504{
505}
506
498507void osd_interface::sound_exit()
499508{
500509   global_free(m_sound);
trunk/src/osd/sdl/video.c
r31854r31855
109109   video_config.beamwidth = machine().options().beam();
110110
111111   // initialize the window system so we can make windows
112   if (sdlwindow_init(machine()))
112   if (!window_init())
113113      return false;
114114
115115   // create the windows
r31854r31855
133133
134134void sdl_osd_interface::video_exit()
135135{
136   window_exit();
137   
136138   // free all of our monitor information
137139   while (sdl_monitor_list != NULL)
138140   {
trunk/src/osd/sdl/osdsdl.h
r31854r31855
201201   virtual void debugger_register();
202202
203203   virtual bool video_init();
204   virtual bool window_init();
204205   virtual bool input_init();
205206   virtual void input_pause();
206207   virtual void input_resume();
r31854r31855
210211   #endif
211212
212213   virtual void video_exit();
214   virtual void window_exit();
213215   virtual void input_exit();
214216   virtual void output_exit();
215217   #ifdef USE_NETWORK
trunk/src/osd/sdl/window.c
r31854r31855
114114//  PROTOTYPES
115115//============================================================
116116
117static void sdlwindow_exit(running_machine &machine);
118117static void sdlwindow_video_window_destroy(running_machine &machine, sdl_window_info *window);
119118static OSDWORK_CALLBACK( draw_video_contents_wt );
120119static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt );
r31854r31855
202201
203202
204203//============================================================
205//  win_init_window
204//  window_init
206205//  (main thread)
207206//============================================================
208207
209int sdlwindow_init(running_machine &machine)
208bool sdl_osd_interface::window_init()
210209{
211210   osd_printf_verbose("Enter sdlwindow_init\n");
212211   // determine if we are using multithreading or not
213   multithreading_enabled = downcast<sdl_options &>(machine.options()).multithreading();
212   multithreading_enabled = downcast<sdl_options &>(machine().options()).multithreading();
214213
215214   // get the main thread ID before anything else
216215   main_threadid = SDL_ThreadID();
217216
218   // ensure we get called on the way out
219   machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(sdlwindow_exit), &machine));
220
221217   // if multithreading, create a thread to run the windows
222218   if (multithreading_enabled)
223219   {
224220      // create a thread to run the windows from
225221      work_queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_IO);
226222      if (work_queue == NULL)
227         return 1;
223         return false;
228224      osd_work_item_queue(work_queue, &sdlwindow_thread_id, NULL, WORK_ITEM_FLAG_AUTO_RELEASE);
229225   }
230226   else
r31854r31855
238234#if USE_OPENGL
239235   if (video_config.mode == VIDEO_MODE_OPENGL)
240236   {
241      if (drawogl_init(machine, &draw))
237      if (drawogl_init(machine(), &draw))
242238         video_config.mode = VIDEO_MODE_SOFT;
243239   }
244240#endif
245241#if SDLMAME_SDL2
246242   if (video_config.mode == VIDEO_MODE_SDL13)
247243   {
248      if (draw13_init(machine, &draw))
244      if (draw13_init(machine(), &draw))
249245         video_config.mode = VIDEO_MODE_SOFT;
250246   }
251247#endif
252248   if (video_config.mode == VIDEO_MODE_SOFT)
253249   {
254250      if (drawsdl_init(&draw))
255         return 1;
251         return false;
256252   }
257253
258254   // set up the window list
259255   last_window_ptr = &sdl_window_list;
260256   osd_printf_verbose("Leave sdlwindow_init\n");
261   return 0;
257   return true;
262258}
263259
264260
r31854r31855
296292}
297293
298294
299static void sdlwindow_exit(running_machine &machine)
295void sdl_osd_interface::window_exit()
300296{
301297   ASSERT_MAIN_THREAD();
302298
r31854r31855
307303   {
308304      sdl_window_info *temp = sdl_window_list;
309305      sdl_window_list = temp->next;
310      sdlwindow_video_window_destroy(machine, temp);
306      sdlwindow_video_window_destroy(machine(), temp);
311307   }
312308
313309   // if we're multithreaded, clean up the window thread
trunk/src/osd/sdl/window.h
r31854r31855
119119//  PROTOTYPES
120120//============================================================
121121
122// core initialization
123int sdlwindow_init(running_machine &machine);
124
125122// creation/deletion of windows
126123int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config);
127124void sdlwindow_video_window_update(running_machine &machine, sdl_window_info *window);
trunk/src/osd/osdepend.h
r31854r31855
171171
172172   virtual bool video_init();
173173   virtual void video_register();
174   virtual bool window_init();
174175
175176   bool sound_init();
176177   virtual void sound_register();
r31854r31855
185186
186187   void exit_subsystems();
187188   virtual void video_exit();
189   virtual void window_exit();
188190   void sound_exit();
189191   virtual void input_exit();
190192   virtual void output_exit();
trunk/src/osd/modules/debugger/debugwin.c
r31854r31855
512512   // create the window
513513   info->handler = handler;
514514   info->wnd = win_create_window_ex_utf8(DEBUG_WINDOW_STYLE_EX, "MAMEDebugWindow", title, DEBUG_WINDOW_STYLE,
515         0, 0, 100, 100, win_window_list->hwnd, create_standard_menubar(), GetModuleHandle(NULL), info);
515         0, 0, 100, 100, win_window_list->m_hwnd, create_standard_menubar(), GetModuleHandle(NULL), info);
516516   if (info->wnd == NULL)
517517      goto cleanup;
518518
r31854r31855
30743074{
30753075   debugwin_info *info;
30763076   if (!show)
3077      SetForegroundWindow(win_window_list->hwnd);
3077      SetForegroundWindow(win_window_list->m_hwnd);
30783078   for (info = window_list; info != NULL; info = info->next)
30793079      smart_show_window(info->wnd, show);
30803080}
trunk/src/osd/modules/sound/direct_sound.c
r31854r31855
234234   }
235235
236236   // set the cooperative level
237   result = IDirectSound_SetCooperativeLevel(dsound, win_window_list->hwnd, DSSCL_PRIORITY);
237   result = IDirectSound_SetCooperativeLevel(dsound, win_window_list->m_hwnd, DSSCL_PRIORITY);
238238   if (result != DS_OK)
239239   {
240240      osd_printf_error("Error setting DirectSound cooperative level: %08x\n", (UINT32)result);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team