mirror of
https://github.com/holub/mame
synced 2025-04-21 16:01:56 +03:00
Added new function video_get_view_for_target() which selects a view based
on a command-line parameter and the configuration. Changed Windows OSD code to use this instead of its own logic. Changed -snapview to share the logic as well, enabling 'auto' as a -snapview option.
This commit is contained in:
parent
69ba0bd294
commit
a7be43dc68
@ -487,8 +487,9 @@ Core state/playback options
|
||||
Note that <viewname> does not need to be a perfect match; rather, it
|
||||
will select the first view whose name matches all the characters
|
||||
specified by <viewname>. For example, -snapview native will match the
|
||||
"Native (15:14)" view even though it is not a perfect match. The
|
||||
default value is 'internal'.
|
||||
"Native (15:14)" view even though it is not a perfect match.
|
||||
<viewname> can also be 'auto', which selects the first view with all
|
||||
screens present. The default value is 'internal'.
|
||||
|
||||
-mngwrite <filename>
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
#ifndef __RENDER_H__
|
||||
#define __RENDER_H__
|
||||
|
||||
#include "driver.h"
|
||||
#include "osdepend.h"
|
||||
|
||||
#include <math.h>
|
||||
|
@ -360,24 +360,7 @@ void video_init(running_machine *machine)
|
||||
|
||||
/* otherwise, find the requested view and select it */
|
||||
else
|
||||
{
|
||||
int viewindex;
|
||||
|
||||
/* scan for a match or partial match */
|
||||
for (viewindex = 0; ; viewindex++)
|
||||
{
|
||||
const char *name = render_target_get_view_name(global.snap_target, viewindex);
|
||||
|
||||
/* stop scanning when we hit NULL */
|
||||
if (name == NULL)
|
||||
break;
|
||||
if (mame_strnicmp(name, viewname, strlen(viewname)) == 0)
|
||||
{
|
||||
render_target_set_view(global.snap_target, viewindex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
render_target_set_view(global.snap_target, video_get_view_for_target(machine, global.snap_target, viewname, 0, 1));
|
||||
|
||||
/* extract snap resolution if present */
|
||||
if (sscanf(options_get_string(mame_options(), OPTION_SNAPSIZE), "%dx%d", &global.snap_width, &global.snap_height) != 2)
|
||||
@ -2620,6 +2603,83 @@ void video_avi_add_sound(running_machine *machine, const INT16 *sound, int numsa
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
CONFIGURATION HELPERS
|
||||
***************************************************************************/
|
||||
|
||||
/*-------------------------------------------------
|
||||
video_get_view_for_target - select a view
|
||||
for a given target
|
||||
-------------------------------------------------*/
|
||||
|
||||
int video_get_view_for_target(running_machine *machine, render_target *target, const char *viewname, int targetindex, int numtargets)
|
||||
{
|
||||
int viewindex = -1;
|
||||
|
||||
/* auto view just selects the nth view */
|
||||
if (strcmp(viewname, "auto") != 0)
|
||||
{
|
||||
/* scan for a matching view name */
|
||||
for (viewindex = 0; ; viewindex++)
|
||||
{
|
||||
const char *name = render_target_get_view_name(target, viewindex);
|
||||
|
||||
/* stop scanning when we hit NULL */
|
||||
if (name == NULL)
|
||||
{
|
||||
viewindex = -1;
|
||||
break;
|
||||
}
|
||||
if (mame_strnicmp(name, viewname, strlen(viewname)) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* if we don't have a match, default to the nth view */
|
||||
if (viewindex == -1)
|
||||
{
|
||||
int scrcount = video_screen_count(machine->config);
|
||||
|
||||
/* if we have enough targets to be one per screen, assign in order */
|
||||
if (numtargets >= scrcount)
|
||||
{
|
||||
/* find the first view with this screen and this screen only */
|
||||
for (viewindex = 0; ; viewindex++)
|
||||
{
|
||||
UINT32 viewscreens = render_target_get_view_screens(target, viewindex);
|
||||
if (viewscreens == (1 << targetindex))
|
||||
break;
|
||||
if (viewscreens == 0)
|
||||
{
|
||||
viewindex = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* otherwise, find the first view that has all the screens */
|
||||
if (viewindex == -1)
|
||||
{
|
||||
for (viewindex = 0; ; viewindex++)
|
||||
{
|
||||
UINT32 viewscreens = render_target_get_view_screens(target, viewindex);
|
||||
if (viewscreens == (1 << scrcount) - 1)
|
||||
break;
|
||||
if (viewscreens == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* make sure it's a valid view */
|
||||
if (render_target_get_view_name(target, viewindex) == NULL)
|
||||
viewindex = 0;
|
||||
|
||||
return viewindex;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
SOFTWARE RENDERING
|
||||
***************************************************************************/
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "mamecore.h"
|
||||
#include "devintrf.h"
|
||||
#include "timer.h"
|
||||
#include "render.h"
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@ -271,4 +272,10 @@ void video_avi_begin_recording(running_machine *machine, const char *name);
|
||||
void video_avi_end_recording(running_machine *machine);
|
||||
void video_avi_add_sound(running_machine *machine, const INT16 *sound, int numsamples);
|
||||
|
||||
|
||||
/* ----- configuration helpers ----- */
|
||||
|
||||
/* select a view for a given target */
|
||||
int video_get_view_for_target(running_machine *machine, render_target *target, const char *viewname, int targetindex, int numtargets);
|
||||
|
||||
#endif /* __VIDEO_H__ */
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
// MAME headers
|
||||
#include "mamecore.h"
|
||||
#include "restrack.h"
|
||||
|
||||
// MAMEOS headers
|
||||
#include "window.h"
|
||||
|
@ -843,72 +843,16 @@ static void create_window_class(void)
|
||||
static void set_starting_view(running_machine *machine, int index, win_window_info *window, const char *view)
|
||||
{
|
||||
const char *defview = options_get_string(mame_options(), WINOPTION_VIEW);
|
||||
int viewindex = -1;
|
||||
int viewindex;
|
||||
|
||||
assert(GetCurrentThreadId() == main_threadid);
|
||||
|
||||
// choose non-auto over auto
|
||||
if (strcmp(view, "auto") == 0 && strcmp(defview, "auto") != 0)
|
||||
view = defview;
|
||||
|
||||
// auto view just selects the nth view
|
||||
if (strcmp(view, "auto") != 0)
|
||||
{
|
||||
// scan for a matching view name
|
||||
for (viewindex = 0; ; viewindex++)
|
||||
{
|
||||
const char *name = render_target_get_view_name(window->target, viewindex);
|
||||
|
||||
// stop scanning if we hit NULL
|
||||
if (name == NULL)
|
||||
{
|
||||
viewindex = -1;
|
||||
break;
|
||||
}
|
||||
if (mame_strnicmp(name, view, strlen(view)) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we don't have a match, default to the nth view
|
||||
if (viewindex == -1)
|
||||
{
|
||||
int scrcount = video_screen_count(machine->config);
|
||||
|
||||
// if we have enough screens to be one per monitor, assign in order
|
||||
if (video_config.numscreens >= scrcount)
|
||||
{
|
||||
// find the first view with this screen and this screen only
|
||||
for (viewindex = 0; ; viewindex++)
|
||||
{
|
||||
UINT32 viewscreens = render_target_get_view_screens(window->target, viewindex);
|
||||
if (viewscreens == (1 << index))
|
||||
break;
|
||||
if (viewscreens == 0)
|
||||
{
|
||||
viewindex = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise, find the first view that has all the screens
|
||||
if (viewindex == -1)
|
||||
{
|
||||
for (viewindex = 0; ; viewindex++)
|
||||
{
|
||||
UINT32 viewscreens = render_target_get_view_screens(window->target, viewindex);
|
||||
if (viewscreens == (1 << scrcount) - 1)
|
||||
break;
|
||||
if (viewscreens == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make sure it's a valid view
|
||||
if (render_target_get_view_name(window->target, viewindex) == NULL)
|
||||
viewindex = 0;
|
||||
|
||||
// query the video system to help us pick a view
|
||||
viewindex = video_get_view_for_target(machine, window->target, view, index, video_config.numscreens);
|
||||
|
||||
// set the view
|
||||
render_target_set_view(window->target, viewindex);
|
||||
|
Loading…
Reference in New Issue
Block a user