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
This commit is contained in:
couriersud 2015-01-13 20:23:00 +01:00
parent ba71152805
commit e216457fcd
15 changed files with 410 additions and 323 deletions

View File

@ -21,6 +21,8 @@
#include "clifront.h"
#include "xmlfile.h"
#include "drivenum.h"
#include <new>
#include <ctype.h>
@ -67,6 +69,34 @@ const options_entry cli_options::s_option_entries[] =
{ NULL }
};
// media_identifier class identifies media by hash via a search in
// the driver database
class media_identifier
{
public:
// construction/destruction
media_identifier(cli_options &options);
// getters
int total() const { return m_total; }
int matches() const { return m_matches; }
int nonroms() const { return m_nonroms; }
// operations
void reset() { m_total = m_matches = m_nonroms = 0; }
void identify(const char *name);
void identify_file(const char *name);
void identify_data(const char *name, const UINT8 *data, int length);
int find_by_hash(const hash_collection &hashes, int length);
private:
// internal state
driver_enumerator m_drivlist;
int m_total;
int m_matches;
int m_nonroms;
};
//**************************************************************************
@ -78,8 +108,9 @@ const options_entry cli_options::s_option_entries[] =
//-------------------------------------------------
cli_options::cli_options()
: emu_options()
{
add_entries(s_option_entries);
add_entries(cli_options::s_option_entries);
}

View File

@ -13,61 +13,14 @@
#ifndef __CLIFRONT_H__
#define __CLIFRONT_H__
#include "emuopts.h"
#include "drivenum.h"
//**************************************************************************
// CONSTANTS
//**************************************************************************
// core commands
#define CLICOMMAND_HELP "help"
#define CLICOMMAND_VALIDATE "validate"
// configuration commands
#define CLICOMMAND_CREATECONFIG "createconfig"
#define CLICOMMAND_SHOWCONFIG "showconfig"
#define CLICOMMAND_SHOWUSAGE "showusage"
// frontend commands
#define CLICOMMAND_LISTXML "listxml"
#define CLICOMMAND_LISTFULL "listfull"
#define CLICOMMAND_LISTSOURCE "listsource"
#define CLICOMMAND_LISTCLONES "listclones"
#define CLICOMMAND_LISTBROTHERS "listbrothers"
#define CLICOMMAND_LISTCRC "listcrc"
#define CLICOMMAND_LISTROMS "listroms"
#define CLICOMMAND_LISTSAMPLES "listsamples"
#define CLICOMMAND_VERIFYROMS "verifyroms"
#define CLICOMMAND_VERIFYSAMPLES "verifysamples"
#define CLICOMMAND_ROMIDENT "romident"
#define CLICOMMAND_LISTDEVICES "listdevices"
#define CLICOMMAND_LISTSLOTS "listslots"
#define CLICOMMAND_LISTMEDIA "listmedia" // needed by MESS
#define CLICOMMAND_LISTSOFTWARE "listsoftware"
#define CLICOMMAND_VERIFYSOFTWARE "verifysoftware"
#define CLICOMMAND_GETSOFTLIST "getsoftlist"
#define CLICOMMAND_VERIFYSOFTLIST "verifysoftlist"
#define CLICOMMAND_LIST_MIDI_DEVICES "listmidi"
#define CLICOMMAND_LIST_NETWORK_ADAPTERS "listnetwork"
#include "cliopts.h"
#include "osdepend.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// cli_options wraps the general emu options with CLI-specific additions
class cli_options : public emu_options
{
public:
// construction/destruction
cli_options();
private:
static const options_entry s_option_entries[];
};
// cli_frontend handles command-line processing and emulator execution
class cli_frontend
@ -120,34 +73,6 @@ private:
};
// media_identifier class identifies media by hash via a search in
// the driver database
class media_identifier
{
public:
// construction/destruction
media_identifier(cli_options &options);
// getters
int total() const { return m_total; }
int matches() const { return m_matches; }
int nonroms() const { return m_nonroms; }
// operations
void reset() { m_total = m_matches = m_nonroms = 0; }
void identify(const char *name);
void identify_file(const char *name);
void identify_data(const char *name, const UINT8 *data, int length);
int find_by_hash(const hash_collection &hashes, int length);
private:
// internal state
driver_enumerator m_drivlist;
int m_total;
int m_matches;
int m_nonroms;
};
#endif /* __CLIFRONT_H__ */

52
src/emu/cliopts.c Normal file
View File

@ -0,0 +1,52 @@
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/***************************************************************************
cliopts.c
***************************************************************************/
#include "cliopts.h"
//**************************************************************************
// COMMAND-LINE OPTIONS
//**************************************************************************
const options_entry cli_options::s_option_entries[] =
{
/* core commands */
{ NULL, NULL, OPTION_HEADER, "CORE COMMANDS" },
{ CLICOMMAND_HELP ";h;?", "0", OPTION_COMMAND, "show help message" },
{ CLICOMMAND_VALIDATE ";valid", "0", OPTION_COMMAND, "perform driver validation on all game drivers" },
/* configuration commands */
{ NULL, NULL, OPTION_HEADER, "CONFIGURATION COMMANDS" },
{ CLICOMMAND_CREATECONFIG ";cc", "0", OPTION_COMMAND, "create the default configuration file" },
{ CLICOMMAND_SHOWCONFIG ";sc", "0", OPTION_COMMAND, "display running parameters" },
{ CLICOMMAND_SHOWUSAGE ";su", "0", OPTION_COMMAND, "show this help" },
/* frontend commands */
{ NULL, NULL, OPTION_HEADER, "FRONTEND COMMANDS" },
{ CLICOMMAND_LISTXML ";lx", "0", OPTION_COMMAND, "all available info on driver in XML format" },
{ CLICOMMAND_LISTFULL ";ll", "0", OPTION_COMMAND, "short name, full name" },
{ CLICOMMAND_LISTSOURCE ";ls", "0", OPTION_COMMAND, "driver sourcefile" },
{ CLICOMMAND_LISTCLONES ";lc", "0", OPTION_COMMAND, "show clones" },
{ CLICOMMAND_LISTBROTHERS ";lb", "0", OPTION_COMMAND, "show \"brothers\", or other drivers from same sourcefile" },
{ CLICOMMAND_LISTCRC, "0", OPTION_COMMAND, "CRC-32s" },
{ CLICOMMAND_LISTROMS ";lr", "0", OPTION_COMMAND, "list required roms for a driver" },
{ CLICOMMAND_LISTSAMPLES, "0", OPTION_COMMAND, "list optional samples for a driver" },
{ CLICOMMAND_VERIFYROMS, "0", OPTION_COMMAND, "report romsets that have problems" },
{ CLICOMMAND_VERIFYSAMPLES, "0", OPTION_COMMAND, "report samplesets that have problems" },
{ CLICOMMAND_ROMIDENT, "0", OPTION_COMMAND, "compare files with known MAME roms" },
{ CLICOMMAND_LISTDEVICES ";ld", "0", OPTION_COMMAND, "list available devices" },
{ CLICOMMAND_LISTSLOTS ";lslot", "0", OPTION_COMMAND, "list available slots and slot devices" },
{ CLICOMMAND_LISTMEDIA ";lm", "0", OPTION_COMMAND, "list available media for the system" },
{ CLICOMMAND_LISTSOFTWARE ";lsoft", "0", OPTION_COMMAND, "list known software for the system" },
{ CLICOMMAND_VERIFYSOFTWARE ";vsoft", "0", OPTION_COMMAND, "verify known software for the system" },
{ CLICOMMAND_GETSOFTLIST ";glist", "0", OPTION_COMMAND, "retrieve software list by name" },
{ CLICOMMAND_VERIFYSOFTLIST ";vlist", "0", OPTION_COMMAND, "verify software list by name" },
{ CLICOMMAND_LIST_MIDI_DEVICES ";mlist", "0", OPTION_COMMAND, "list available MIDI I/O devices" },
{ CLICOMMAND_LIST_NETWORK_ADAPTERS ";nlist", "0", OPTION_COMMAND, "list available network adapters" },
{ NULL }
};

69
src/emu/cliopts.h Normal file
View File

@ -0,0 +1,69 @@
// license:BSD-3-Clause
// copyright-holders:Aaron Giles
/***************************************************************************
clifront.h
Command-line interface frontend for MAME.
***************************************************************************/
#pragma once
#ifndef __CLIOPTS_H__
#define __CLIOPTS_H__
#include "emuopts.h"
//**************************************************************************
// CONSTANTS
//**************************************************************************
// core commands
#define CLICOMMAND_HELP "help"
#define CLICOMMAND_VALIDATE "validate"
// configuration commands
#define CLICOMMAND_CREATECONFIG "createconfig"
#define CLICOMMAND_SHOWCONFIG "showconfig"
#define CLICOMMAND_SHOWUSAGE "showusage"
// frontend commands
#define CLICOMMAND_LISTXML "listxml"
#define CLICOMMAND_LISTFULL "listfull"
#define CLICOMMAND_LISTSOURCE "listsource"
#define CLICOMMAND_LISTCLONES "listclones"
#define CLICOMMAND_LISTBROTHERS "listbrothers"
#define CLICOMMAND_LISTCRC "listcrc"
#define CLICOMMAND_LISTROMS "listroms"
#define CLICOMMAND_LISTSAMPLES "listsamples"
#define CLICOMMAND_VERIFYROMS "verifyroms"
#define CLICOMMAND_VERIFYSAMPLES "verifysamples"
#define CLICOMMAND_ROMIDENT "romident"
#define CLICOMMAND_LISTDEVICES "listdevices"
#define CLICOMMAND_LISTSLOTS "listslots"
#define CLICOMMAND_LISTMEDIA "listmedia" // needed by MESS
#define CLICOMMAND_LISTSOFTWARE "listsoftware"
#define CLICOMMAND_VERIFYSOFTWARE "verifysoftware"
#define CLICOMMAND_GETSOFTLIST "getsoftlist"
#define CLICOMMAND_VERIFYSOFTLIST "verifysoftlist"
#define CLICOMMAND_LIST_MIDI_DEVICES "listmidi"
#define CLICOMMAND_LIST_NETWORK_ADAPTERS "listnetwork"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// cli_options wraps the general emu options with CLI-specific additions
class cli_options : public emu_options
{
public:
// construction/destruction
cli_options();
private:
static const options_entry s_option_entries[];
};
#endif /* __CLIFRONT_H__ */

View File

@ -150,6 +150,10 @@ const options_entry emu_options::s_option_entries[] =
// debugging options
{ NULL, NULL, OPTION_HEADER, "CORE DEBUGGING OPTIONS" },
{ OPTION_VERBOSE ";v", "0", OPTION_BOOLEAN, "display additional diagnostic information" },
{ OPTION_LOG, "0", OPTION_BOOLEAN, "generate an error.log file" },
{ OPTION_OSLOG, "0", OPTION_BOOLEAN, "output error.log data to the system debugger" },
{ OPTION_DEBUG ";d", "0", OPTION_BOOLEAN, "enable/disable debugger" },
{ OPTION_UPDATEINPAUSE, "0", OPTION_BOOLEAN, "keep calling video updates while in pause" },
{ OPTION_DEBUGSCRIPT, NULL, OPTION_STRING, "script for debugger" },
@ -187,9 +191,9 @@ const options_entry emu_options::s_option_entries[] =
//-------------------------------------------------
emu_options::emu_options()
: core_options()
{
add_entries(s_option_entries);
add_osd_options();
add_entries(emu_options::s_option_entries);
}
@ -504,18 +508,6 @@ void emu_options::set_system_name(const char *name)
}
}
//-------------------------------------------------
// device_option - return the value of the
// device-specific option
//-------------------------------------------------
const char *emu_options::device_option(device_image_interface &image)
{
return value(image.instance_name());
}
//-------------------------------------------------
// parse_one_ini - parse a single INI file
//-------------------------------------------------

View File

@ -15,7 +15,6 @@
#include "options.h"
//**************************************************************************
// CONSTANTS
//**************************************************************************
@ -154,6 +153,10 @@ enum
#define OPTION_MOUSE_DEVICE "mouse_device"
// core debugging options
#define OPTION_LOG "log"
#define OPTION_DEBUG "debug"
#define OPTION_VERBOSE "verbose"
#define OPTION_OSLOG "oslog"
#define OPTION_UPDATEINPAUSE "update_in_pause"
#define OPTION_DEBUGSCRIPT "debugscript"
@ -188,7 +191,7 @@ enum
struct game_driver;
class emu_options : public osd_options
class emu_options : public core_options
{
static const UINT32 OPTION_FLAG_DEVICE = 0x80000000;
@ -315,7 +318,11 @@ public:
bool joystick_contradictory() const { return bool_value(OPTION_JOYSTICK_CONTRADICTORY); }
int coin_impulse() const { return int_value(OPTION_COIN_IMPULSE); }
// core debugging options
// core debugging options
bool log() const { return bool_value(OPTION_LOG); }
bool debug() const { return bool_value(OPTION_DEBUG); }
bool verbose() const { return bool_value(OPTION_VERBOSE); }
bool oslog() const { return bool_value(OPTION_OSLOG); }
const char *debug_script() const { return value(OPTION_DEBUGSCRIPT); }
bool update_in_pause() const { return bool_value(OPTION_UPDATEINPAUSE); }
@ -342,9 +349,7 @@ public:
const char *http_path() const { return value(OPTION_HTTP_PATH); }
bool console() const { return bool_value(OPTION_CONSOLE); }
// device-specific options
const char *device_option(device_image_interface &image);
// FIXME: Couriersud: This should be in image_device_exit
void remove_device_options();
const char *main_value(astring &buffer, const char *option) const;

View File

@ -210,7 +210,7 @@ void image_device_init(running_machine &machine)
for (device_image_interface *image = iter.first(); image != NULL; image = iter.next())
{
/* is an image specified for this image */
image_name = machine.options().device_option(*image);
image_name = machine.options().value(image->instance_name());
if ((image_name != NULL) && (image_name[0] != '\0'))
{

View File

@ -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()
{
astring current_value(options.description(key));
// 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(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()

View File

@ -14,14 +14,105 @@
#define __OSDOBJ_COMMON__
#include "osdepend.h"
#include "options.h"
#include "cliopts.h"
//============================================================
// Defines
//============================================================
#if 0
// forward references
class input_type_entry;
class device_t;
#endif
/* FIXME: void cli_frontend::listnetworkadapters should be
* moved here.
*/
#define OSDOPTION_DEBUGGER "debugger"
#define OSDOPTION_WATCHDOG "watchdog"
#define OSDOPTION_MULTITHREADING "multithreading"
#define OSDOPTION_NUMPROCESSORS "numprocessors"
#define OSDOPTION_BENCH "bench"
#define OSDOPTION_VIDEO "video"
#define OSDOPTION_NUMSCREENS "numscreens"
#define OSDOPTION_WINDOW "window"
#define OSDOPTION_MAXIMIZE "maximize"
#define OSDOPTION_KEEPASPECT "keepaspect"
#define OSDOPTION_UNEVENSTRETCH "unevenstretch"
#define OSDOPTION_WAITVSYNC "waitvsync"
#define OSDOPTION_SYNCREFRESH "syncrefresh"
#define OSDOPTION_SCREEN "screen"
#define OSDOPTION_ASPECT "aspect"
#define OSDOPTION_RESOLUTION "resolution"
#define OSDOPTION_VIEW "view"
#define OSDOPTION_SWITCHRES "switchres"
#define OSDOPTION_SOUND "sound"
#define OSDOPTION_AUDIO_LATENCY "audio_latency"
#define OSDOPTVAL_AUTO "auto"
//============================================================
// TYPE DEFINITIONS
//============================================================
/* FIXME: core_options inherits from osd_options. This will force any
* future osd implementation to use the options below. Actually, these
* options are *private* to the osd_core. This object should actually be an
* accessor object. Later ...
*/
/* FIXME: core_options inherits from osd_options. This will force any
* future osd implementation to use the options below. Actually, these
* options are *private* to the osd_core. This object should actually be an
* accessor object. Later ...
*/
class osd_options : public cli_options
{
public:
// construction/destruction
osd_options();
// debugging options
const char *debugger() const { return value(OSDOPTION_DEBUGGER); }
int watchdog() const { return int_value(OSDOPTION_WATCHDOG); }
// performance options
bool multithreading() const { return bool_value(OSDOPTION_MULTITHREADING); }
const char *numprocessors() const { return value(OSDOPTION_NUMPROCESSORS); }
int bench() const { return int_value(OSDOPTION_BENCH); }
// video options
const char *video() const { return value(OSDOPTION_VIDEO); }
int numscreens() const { return int_value(OSDOPTION_NUMSCREENS); }
bool window() const { return bool_value(OSDOPTION_WINDOW); }
bool maximize() const { return bool_value(OSDOPTION_MAXIMIZE); }
bool keep_aspect() const { return bool_value(OSDOPTION_KEEPASPECT); }
bool uneven_stretch() const { return bool_value(OSDOPTION_UNEVENSTRETCH); }
bool wait_vsync() const { return bool_value(OSDOPTION_WAITVSYNC); }
bool sync_refresh() const { return bool_value(OSDOPTION_SYNCREFRESH); }
// per-window options
const char *screen() const { return value(OSDOPTION_SCREEN); }
const char *aspect() const { return value(OSDOPTION_ASPECT); }
const char *resolution() const { return value(OSDOPTION_RESOLUTION); }
const char *view() const { return value(OSDOPTION_VIEW); }
const char *screen(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_SCREEN, index)); }
const char *aspect(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_ASPECT, index)); }
const char *resolution(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_RESOLUTION, index)); }
const char *view(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_VIEW, index)); }
// full screen options
bool switch_res() const { return bool_value(OSDOPTION_SWITCHRES); }
// sound options
const char *sound() const { return value(OSDOPTION_SOUND); }
int audio_latency() const { return int_value(OSDOPTION_AUDIO_LATENCY); }
private:
static const options_entry s_option_entries[];
};
class osd_sound_interface;
class osd_debugger_interface;
@ -40,10 +131,11 @@ class osd_common_t : public osd_interface
{
public:
// construction/destruction
osd_common_t();
osd_common_t(osd_options &options);
virtual ~osd_common_t();
virtual void register_options(osd_options &options);
// FIXME: simply option handling
virtual void register_options();
// general overridables
virtual void init(running_machine &machine);
@ -123,11 +215,14 @@ public:
virtual void sound_options_add(const char *name, osd_sound_type type);
virtual void debugger_options_add(const char *name, osd_debugger_type type);
osd_options &options() { return m_options; }
private:
// internal state
running_machine * m_machine;
osd_options& m_options;
void update_option(osd_options &options, const char * key, dynamic_array<const char *> &values);
void update_option(const char * key, dynamic_array<const char *> &values);
protected:
osd_sound_interface* m_sound;

View File

@ -1,69 +1,2 @@
#include "osdepend.h"
const options_entry osd_options::s_option_entries[] =
{
// debugging options
{ NULL, NULL, OPTION_HEADER, "OSD DEBUGGING OPTIONS" },
{ OSDOPTION_LOG, "0", OPTION_BOOLEAN, "generate an error.log file" },
{ OSDOPTION_VERBOSE ";v", "0", OPTION_BOOLEAN, "display additional diagnostic information" },
{ OSDOPTION_DEBUG ";d", "0", OPTION_BOOLEAN, "enable/disable debugger" },
{ OSDOPTION_DEBUGGER, OSDOPTVAL_AUTO, OPTION_STRING, "debugger used : " },
{ OSDOPTION_OSLOG, "0", OPTION_BOOLEAN, "output error.log data to the system debugger" },
{ 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 }
};

View File

@ -16,116 +16,16 @@
#include "emucore.h"
#include "osdcore.h"
#include "unicode.h"
#include "cliopts.h"
// forward references
class input_type_entry; // FIXME: including emu.h does not work because emu.h includes osdepend.h
//============================================================
// Defines
//============================================================
/* FIXME: void cli_frontend::listnetworkadapters should be
* moved here.
*/
#include "options.h"
#define OSDOPTION_LOG "log"
#define OSDOPTION_VERBOSE "verbose"
#define OSDOPTION_DEBUG "debug"
#define OSDOPTION_DEBUGGER "debugger"
#define OSDOPTION_OSLOG "oslog"
#define OSDOPTION_WATCHDOG "watchdog"
#define OSDOPTION_MULTITHREADING "multithreading"
#define OSDOPTION_NUMPROCESSORS "numprocessors"
#define OSDOPTION_BENCH "bench"
#define OSDOPTION_VIDEO "video"
#define OSDOPTION_NUMSCREENS "numscreens"
#define OSDOPTION_WINDOW "window"
#define OSDOPTION_MAXIMIZE "maximize"
#define OSDOPTION_KEEPASPECT "keepaspect"
#define OSDOPTION_UNEVENSTRETCH "unevenstretch"
#define OSDOPTION_WAITVSYNC "waitvsync"
#define OSDOPTION_SYNCREFRESH "syncrefresh"
#define OSDOPTION_SCREEN "screen"
#define OSDOPTION_ASPECT "aspect"
#define OSDOPTION_RESOLUTION "resolution"
#define OSDOPTION_VIEW "view"
#define OSDOPTION_SWITCHRES "switchres"
#define OSDOPTION_SOUND "sound"
#define OSDOPTION_AUDIO_LATENCY "audio_latency"
#define OSDOPTVAL_AUTO "auto"
//============================================================
// TYPE DEFINITIONS
//============================================================
/* FIXME: core_options inherits from osd_options. This will force any
* future osd implementation to use the options below. Actually, these
* options are *private* to the osd_core. This object should actually be an
* accessor object. Later ...
*/
class osd_options : public core_options
{
public:
// construction/destruction
osd_options() : core_options() {};
// debugging options
bool verbose() const { return bool_value(OSDOPTION_VERBOSE); }
bool log() const { return bool_value(OSDOPTION_LOG); }
bool debug() const { return bool_value(OSDOPTION_DEBUG); }
const char *debugger() const { return value(OSDOPTION_DEBUGGER); }
bool oslog() const { return bool_value(OSDOPTION_OSLOG); }
int watchdog() const { return int_value(OSDOPTION_WATCHDOG); }
// performance options
bool multithreading() const { return bool_value(OSDOPTION_MULTITHREADING); }
const char *numprocessors() const { return value(OSDOPTION_NUMPROCESSORS); }
int bench() const { return int_value(OSDOPTION_BENCH); }
// video options
const char *video() const { return value(OSDOPTION_VIDEO); }
int numscreens() const { return int_value(OSDOPTION_NUMSCREENS); }
bool window() const { return bool_value(OSDOPTION_WINDOW); }
bool maximize() const { return bool_value(OSDOPTION_MAXIMIZE); }
bool keep_aspect() const { return bool_value(OSDOPTION_KEEPASPECT); }
bool uneven_stretch() const { return bool_value(OSDOPTION_UNEVENSTRETCH); }
bool wait_vsync() const { return bool_value(OSDOPTION_WAITVSYNC); }
bool sync_refresh() const { return bool_value(OSDOPTION_SYNCREFRESH); }
// per-window options
const char *screen() const { return value(OSDOPTION_SCREEN); }
const char *aspect() const { return value(OSDOPTION_ASPECT); }
const char *resolution() const { return value(OSDOPTION_RESOLUTION); }
const char *view() const { return value(OSDOPTION_VIEW); }
const char *screen(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_SCREEN, index)); }
const char *aspect(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_ASPECT, index)); }
const char *resolution(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_RESOLUTION, index)); }
const char *view(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_VIEW, index)); }
// full screen options
bool switch_res() const { return bool_value(OSDOPTION_SWITCHRES); }
// sound options
const char *sound() const { return value(OSDOPTION_SOUND); }
int audio_latency() const { return int_value(OSDOPTION_AUDIO_LATENCY); }
void add_osd_options()
{
this->add_entries(s_option_entries);
}
private:
static const options_entry s_option_entries[];
};
// FIXME: We can do better than this
typedef void *osd_font;

View File

@ -120,7 +120,7 @@ typedef void *osd_font;
// TYPE DEFINITIONS
//============================================================
class sdl_options : public cli_options
class sdl_options : public osd_options
{
public:
// construction/destruction
@ -181,7 +181,7 @@ class sdl_osd_interface : public osd_common_t
{
public:
// construction/destruction
sdl_osd_interface();
sdl_osd_interface(sdl_options &options);
virtual ~sdl_osd_interface();
// general overridables
@ -220,8 +220,11 @@ public:
#endif
//virtual void midi_exit();
sdl_options &options() { return m_options; }
private:
virtual void osd_exit();
sdl_options &m_options;
watchdog *m_watchdog;

View File

@ -255,9 +255,10 @@ void MorphToPM()
//============================================================
sdl_options::sdl_options()
: osd_options()
{
astring ini_path(INI_PATH);
add_entries(s_option_entries);
add_entries(sdl_options::s_option_entries);
ini_path.replace(0, "APP_NAME", emulator_info::get_appname_lower());
set_default_value(SDLOPTION_INIPATH, ini_path.cstr());
}
@ -333,9 +334,9 @@ int main(int argc, char *argv[])
#endif
{
sdl_osd_interface osd;
sdl_options options;
osd.register_options(options);
sdl_options options;
sdl_osd_interface osd(options);
osd.register_options();
cli_frontend frontend(options, osd);
res = frontend.execute(argc, argv);
}
@ -380,7 +381,8 @@ static void output_oslog(running_machine &machine, const char *buffer)
// constructor
//============================================================
sdl_osd_interface::sdl_osd_interface()
sdl_osd_interface::sdl_osd_interface(sdl_options &options)
: osd_common_t(options), m_options(options)
{
m_watchdog = NULL;
}

View File

@ -421,8 +421,8 @@ int main(int argc, char *argv[])
DWORD result = 0;
{
windows_options options;
windows_osd_interface osd;
osd.register_options(options);
windows_osd_interface osd(options);
osd.register_options();
cli_frontend frontend(options, osd);
result = frontend.execute(argc, argv);
}
@ -437,6 +437,7 @@ int main(int argc, char *argv[])
//============================================================
windows_options::windows_options()
: osd_options()
{
add_entries(s_option_entries);
}
@ -512,7 +513,8 @@ static void output_oslog(running_machine &machine, const char *buffer)
// constructor
//============================================================
windows_osd_interface::windows_osd_interface()
windows_osd_interface::windows_osd_interface(windows_options &options)
: osd_common_t(options)
{
}

View File

@ -114,7 +114,7 @@
// TYPE DEFINITIONS
//============================================================
class windows_options : public cli_options
class windows_options : public osd_options
{
public:
// construction/destruction
@ -239,7 +239,7 @@ class windows_osd_interface : public osd_common_t
{
public:
// construction/destruction
windows_osd_interface();
windows_osd_interface(windows_options &options);
virtual ~windows_osd_interface();
// general overridables