summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/lib/osdobj_common.c
diff options
context:
space:
mode:
author couriersud <couriersud@arcor.de>2015-01-13 20:23:00 +0100
committer couriersud <couriersud@arcor.de>2015-01-13 20:23:00 +0100
commite216457fcd3418cb125c5e3b33e2a6ccf5c97994 (patch)
treed14712811cb92590b50b27ee87e6a00e59823646 /src/osd/modules/lib/osdobj_common.c
parentba711528052ae9ff57596ec19f9726db16f2009f (diff)
Untangled options inheritance. Previously code locked in osd_options
locking any potential future OSD to these. Options inheritance now is core_options emu_options cli_options osd_options [sdl|win]_osd_options This required a number of minor changes to other code as well. Tested on linux-sdl, windows-sdl, windows-mainline, osx-sdl
Diffstat (limited to 'src/osd/modules/lib/osdobj_common.c')
-rw-r--r--src/osd/modules/lib/osdobj_common.c148
1 files changed, 113 insertions, 35 deletions
diff --git a/src/osd/modules/lib/osdobj_common.c b/src/osd/modules/lib/osdobj_common.c
index 90d51c4e4de..79c7eb15c2f 100644
--- a/src/osd/modules/lib/osdobj_common.c
+++ b/src/osd/modules/lib/osdobj_common.c
@@ -14,25 +14,117 @@
#include "modules/sound/none.h"
#include "modules/debugger/none.h"
#include "modules/debugger/debugint.h"
+#include "modules/lib/osdobj_common.h"
extern bool g_print_verbose;
+const options_entry osd_options::s_option_entries[] =
+{
+ // debugging options
+ { NULL, NULL, OPTION_HEADER, "OSD DEBUGGING OPTIONS" },
+ { OSDOPTION_DEBUGGER, OSDOPTVAL_AUTO, OPTION_STRING, "debugger used : " },
+ { OSDOPTION_WATCHDOG ";wdog", "0", OPTION_INTEGER, "force the program to terminate if no updates within specified number of seconds" },
+
+ // performance options
+ { NULL, NULL, OPTION_HEADER, "OSD PERFORMANCE OPTIONS" },
+ { OSDOPTION_MULTITHREADING ";mt", "0", OPTION_BOOLEAN, "enable multithreading; this enables rendering and blitting on a separate thread" },
+ { OSDOPTION_NUMPROCESSORS ";np", OSDOPTVAL_AUTO, OPTION_STRING, "number of processors; this overrides the number the system reports" },
+ { OSDOPTION_BENCH, "0", OPTION_INTEGER, "benchmark for the given number of emulated seconds; implies -video none -sound none -nothrottle" },
+ // video options
+ { NULL, NULL, OPTION_HEADER, "OSD VIDEO OPTIONS" },
+// OS X can be trusted to have working hardware OpenGL, so default to it on for the best user experience
+ { OSDOPTION_VIDEO, OSDOPTVAL_AUTO, OPTION_STRING, "video output method: " },
+ { OSDOPTION_NUMSCREENS "(1-4)", "1", OPTION_INTEGER, "number of screens to create; usually, you want just one" },
+ { OSDOPTION_WINDOW ";w", "0", OPTION_BOOLEAN, "enable window mode; otherwise, full screen mode is assumed" },
+ { OSDOPTION_MAXIMIZE ";max", "1", OPTION_BOOLEAN, "default to maximized windows; otherwise, windows will be minimized" },
+ { OSDOPTION_KEEPASPECT ";ka", "1", OPTION_BOOLEAN, "constrain to the proper aspect ratio" },
+ { OSDOPTION_UNEVENSTRETCH ";ues", "1", OPTION_BOOLEAN, "allow non-integer stretch factors" },
+ { OSDOPTION_WAITVSYNC ";vs", "0", OPTION_BOOLEAN, "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" },
+ { OSDOPTION_SYNCREFRESH ";srf", "0", OPTION_BOOLEAN, "enable using the start of VBLANK for throttling instead of the game time" },
+
+ // per-window options
+ { NULL, NULL, OPTION_HEADER, "OSD PER-WINDOW VIDEO OPTIONS" },
+ { OSDOPTION_SCREEN, OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" },
+ { OSDOPTION_ASPECT ";screen_aspect", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio for all screens; 'auto' here will try to make a best guess" },
+ { OSDOPTION_RESOLUTION ";r", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution for all screens; format is <width>x<height>[@<refreshrate>] or 'auto'" },
+ { OSDOPTION_VIEW, OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for all screens" },
+
+ { OSDOPTION_SCREEN "0", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" },
+ { OSDOPTION_ASPECT "0", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the first screen; 'auto' here will try to make a best guess" },
+ { OSDOPTION_RESOLUTION "0;r0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the first screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
+ { OSDOPTION_VIEW "0", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the first screen" },
+
+ { OSDOPTION_SCREEN "1", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the second screen; 'auto' here will try to make a best guess" },
+ { OSDOPTION_ASPECT "1", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the second screen; 'auto' here will try to make a best guess" },
+ { OSDOPTION_RESOLUTION "1;r1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the second screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
+ { OSDOPTION_VIEW "1", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the second screen" },
+
+ { OSDOPTION_SCREEN "2", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the third screen; 'auto' here will try to make a best guess" },
+ { OSDOPTION_ASPECT "2", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the third screen; 'auto' here will try to make a best guess" },
+ { OSDOPTION_RESOLUTION "2;r2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the third screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
+ { OSDOPTION_VIEW "2", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the third screen" },
+
+ { OSDOPTION_SCREEN "3", OSDOPTVAL_AUTO, OPTION_STRING, "explicit name of the fourth screen; 'auto' here will try to make a best guess" },
+ { OSDOPTION_ASPECT "3", OSDOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" },
+ { OSDOPTION_RESOLUTION "3;r3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the fourth screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
+ { OSDOPTION_VIEW "3", OSDOPTVAL_AUTO, OPTION_STRING, "preferred view for the fourth screen" },
+
+ // full screen options
+ { NULL, NULL, OPTION_HEADER, "OSD FULL SCREEN OPTIONS" },
+ { OSDOPTION_SWITCHRES, "0", OPTION_BOOLEAN, "enable resolution switching" },
+
+ // sound options
+ { NULL, NULL, OPTION_HEADER, "OSD SOUND OPTIONS" },
+ { OSDOPTION_SOUND, OSDOPTVAL_AUTO, OPTION_STRING, "sound output method: " },
+ { OSDOPTION_AUDIO_LATENCY "(1-5)", "2", OPTION_INTEGER, "set audio latency (increase to reduce glitches, decrease for responsiveness)" },
+
+ // End of list
+ { NULL }
+};
+
+osd_options::osd_options()
+: cli_options()
+{
+ add_entries(osd_options::s_option_entries);
+};
+
//-------------------------------------------------
// osd_interface - constructor
//-------------------------------------------------
-osd_common_t::osd_common_t()
+osd_common_t::osd_common_t(osd_options &options)
: m_machine(NULL),
- m_sound(NULL),
- m_debugger(NULL)
+ m_options(options),
+ m_sound(NULL),
+ m_debugger(NULL)
{
}
-void osd_common_t::update_option(osd_options &options, const char * key, dynamic_array<const char *> &values)
+
+void osd_common_t::register_options()
+{
+ // Register video options and update options
+ video_options_add("none", NULL);
+ video_register();
+ update_option(OSDOPTION_VIDEO, m_video_names);
+
+ // Register sound options and update options
+ sound_options_add("none", OSD_SOUND_NONE);
+ sound_register();
+ update_option(OSDOPTION_SOUND, m_sound_names);
+
+ // Register debugger options and update options
+ debugger_options_add("none", OSD_DEBUGGER_NONE);
+ debugger_options_add("internal", OSD_DEBUGGER_INTERNAL);
+ debugger_register();
+ update_option(OSDOPTION_DEBUGGER, m_debugger_names);
+}
+
+void osd_common_t::update_option(const char * key, dynamic_array<const char *> &values)
{
- astring current_value(options.description(key));
+ astring current_value(m_options.description(key));
astring new_option_value("");
for (int index = 0; index < values.count(); index++)
{
@@ -47,29 +139,9 @@ void osd_common_t::update_option(osd_options &options, const char * key, dynamic
new_option_value.cat(t);
}
// TODO: core_strdup() is leaked
- options.set_description(key, core_strdup(current_value.cat(new_option_value).cstr()));
+ m_options.set_description(key, core_strdup(current_value.cat(new_option_value).cstr()));
}
-void osd_common_t::register_options(osd_options &options)
-{
- // Register video options and update options
- video_options_add("none", NULL);
- video_register();
- update_option(options, OSDOPTION_VIDEO, m_video_names);
-
- // Register sound options and update options
- sound_options_add("none", OSD_SOUND_NONE);
- sound_register();
- update_option(options, OSDOPTION_SOUND, m_sound_names);
-
- // Register debugger options and update options
- debugger_options_add("none", OSD_DEBUGGER_NONE);
- debugger_options_add("internal", OSD_DEBUGGER_INTERNAL);
- debugger_register();
- update_option(options, OSDOPTION_DEBUGGER, m_debugger_names);
-}
-
-
//-------------------------------------------------
// osd_interface - destructor
//-------------------------------------------------
@@ -167,10 +239,10 @@ void osd_common_t::init_debugger()
// is active. This gives any OSD debugger interface a chance to
// create all of its structures.
//
- osd_debugger_type debugger = m_debugger_options.find(machine().options().debugger());
+ osd_debugger_type debugger = m_debugger_options.find(options().debugger());
if (debugger==NULL)
{
- osd_printf_warning("debugger_init: option %s not found switching to auto\n",machine().options().debugger());
+ osd_printf_warning("debugger_init: option %s not found switching to auto\n",options().debugger());
debugger = m_debugger_options.find("auto");
}
m_debugger = (*debugger)(*this);
@@ -222,7 +294,8 @@ void osd_common_t::update_audio_stream(const INT16 *buffer, int samples_this_fra
// It provides an array of stereo samples in L-R order which should be
// output at the configured sample_rate.
//
- m_sound->update_audio_stream(buffer,samples_this_frame);
+ if (m_sound != NULL)
+ m_sound->update_audio_stream(buffer,samples_this_frame);
}
@@ -239,7 +312,8 @@ void osd_common_t::set_mastervolume(int attenuation)
// while (attenuation++ < 0)
// volume /= 1.122018454; // = (10 ^ (1/20)) = 1dB
//
- m_sound->set_mastervolume(attenuation);
+ if (m_sound != NULL)
+ m_sound->set_mastervolume(attenuation);
}
@@ -342,19 +416,22 @@ bool osd_common_t::window_init()
bool osd_common_t::sound_init()
{
- osd_sound_type sound = m_sound_options.find(machine().options().sound());
+ osd_sound_type sound = m_sound_options.find(options().sound());
if (sound==NULL)
{
- osd_printf_warning("sound_init: option %s not found switching to auto\n",machine().options().sound());
+ osd_printf_warning("sound_init: option %s not found switching to auto\n",options().sound());
sound = m_sound_options.find("auto");
}
- m_sound = (*sound)(*this, machine());
+ if (sound != NULL)
+ m_sound = (*sound)(*this, machine());
+ else
+ m_sound = NULL;
return true;
}
bool osd_common_t::no_sound()
{
- return (strcmp(machine().options().sound(),"none")==0) ? true : false;
+ return (strcmp(options().sound(),"none")==0) ? true : false;
}
void osd_common_t::video_register()
@@ -415,7 +492,8 @@ void osd_common_t::window_exit()
void osd_common_t::sound_exit()
{
- global_free(m_sound);
+ if (m_sound != NULL)
+ global_free(m_sound);
}
void osd_common_t::input_exit()