From a532231701babdff7b9f551fbd4923326c214874 Mon Sep 17 00:00:00 2001 From: couriersud Date: Mon, 12 Jan 2015 02:19:14 +0100 Subject: Converted back osd_interface into a pure interface. The previous version just exhibited any member of osd_interface to the core. This one limits core access to osd to those functions originally specified. There is room for improvement going forward here in the design. Left FIXMEs where appropriate. (nw) --- src/emu/clifront.c | 4 +- src/osd/modules/debugger/debugint.c | 15 +- src/osd/modules/debugger/debugint.h | 5 +- src/osd/modules/debugger/debugosx.h | 5 +- src/osd/modules/debugger/debugosx.m | 7 +- src/osd/modules/debugger/debugqt.c | 18 +- src/osd/modules/debugger/debugqt.h | 7 +- src/osd/modules/debugger/debugwin.c | 17 +- src/osd/modules/debugger/debugwin.h | 5 +- src/osd/modules/debugger/none.c | 7 +- src/osd/modules/debugger/none.h | 5 +- src/osd/modules/lib/osdobj_common.c | 509 ++++++++++++++++++++++++++++ src/osd/modules/lib/osdobj_common.h | 189 +++++++++++ src/osd/modules/sound/direct_sound.c | 10 +- src/osd/modules/sound/direct_sound.h | 3 +- src/osd/modules/sound/none.c | 4 +- src/osd/modules/sound/none.h | 3 +- src/osd/modules/sound/sdl_sound.c | 18 +- src/osd/modules/sound/sdl_sound.h | 3 +- src/osd/osdepend.c | 625 ++++------------------------------- src/osd/osdepend.h | 257 +++++--------- src/osd/sdl/osdsdl.h | 5 +- src/osd/sdl/output.c | 2 +- src/osd/sdl/sdl.mak | 1 + src/osd/sdl/sdlmain.c | 29 +- src/osd/windows/windows.mak | 1 + src/osd/windows/winmain.c | 31 +- src/osd/windows/winmain.h | 3 +- 28 files changed, 936 insertions(+), 852 deletions(-) create mode 100644 src/osd/modules/lib/osdobj_common.c create mode 100644 src/osd/modules/lib/osdobj_common.h diff --git a/src/emu/clifront.c b/src/emu/clifront.c index a5f146bb7cf..0d5486b8b45 100644 --- a/src/emu/clifront.c +++ b/src/emu/clifront.c @@ -791,9 +791,7 @@ void cli_frontend::listmididevices(const char *gamename) void cli_frontend::listnetworkadapters(const char *gamename) { - m_osd.network_init(); - osd_list_network_adapters(); - m_osd.network_exit(); + m_osd.list_network_adapters(); } diff --git a/src/osd/modules/debugger/debugint.c b/src/osd/modules/debugger/debugint.c index e97a548675e..39728cf94f7 100644 --- a/src/osd/modules/debugger/debugint.c +++ b/src/osd/modules/debugger/debugint.c @@ -851,18 +851,21 @@ void debugger_internal::debugger_exit() } if (debug_font != NULL) { - m_osd.machine().render().font_free(debug_font); + m_machine->render().font_free(debug_font); debug_font = NULL; } if (menu) global_free(menu); } -void debugger_internal::init_debugger() +void debugger_internal::init_debugger(running_machine &machine) { unicode_char ch; int chw; - debug_font = m_osd.machine().render().font_alloc("ui.bdf"); //ui_get_font(machine); + + m_machine = &machine; + + debug_font = m_machine->render().font_alloc("ui.bdf"); //ui_get_font(machine); debug_font_width = 0; debug_font_height = 15; @@ -871,7 +874,7 @@ void debugger_internal::init_debugger() list = NULL; focus_view = NULL; - debug_font_aspect = m_osd.machine().render().ui_aspect(); + debug_font_aspect = m_machine->render().ui_aspect(); for (ch=0;ch<=127;ch++) { @@ -1442,7 +1445,7 @@ void debugger_internal::wait_for_debugger(device_t &device, bool firststop) void debugger_internal::debugger_update() { - if (!debug_cpu_is_stopped(m_osd.machine()) && m_osd.machine().phase() == MACHINE_PHASE_RUNNING) + if (!debug_cpu_is_stopped(*m_machine) && m_machine->phase() == MACHINE_PHASE_RUNNING) { update_views(); } @@ -1452,6 +1455,6 @@ void debugger_internal::debugger_update() // debugger_internal - constructor //------------------------------------------------- debugger_internal::debugger_internal(const osd_interface &osd) - : osd_debugger_interface(osd) + : osd_debugger_interface(osd), m_machine(NULL) { } diff --git a/src/osd/modules/debugger/debugint.h b/src/osd/modules/debugger/debugint.h index a3f0a441df8..e3733b10dd4 100644 --- a/src/osd/modules/debugger/debugint.h +++ b/src/osd/modules/debugger/debugint.h @@ -15,6 +15,7 @@ #define __DEBUGGER_INTERNAL_H__ #include "osdepend.h" +#include "modules/lib/osdobj_common.h" class debugger_internal : public osd_debugger_interface { @@ -23,10 +24,12 @@ public: debugger_internal(const osd_interface &osd); virtual ~debugger_internal() { } - virtual void init_debugger(); + virtual void init_debugger(running_machine &machine); virtual void wait_for_debugger(device_t &device, bool firststop); virtual void debugger_update(); virtual void debugger_exit(); +private: + running_machine *m_machine; }; extern const osd_debugger_type OSD_DEBUGGER_INTERNAL; diff --git a/src/osd/modules/debugger/debugosx.h b/src/osd/modules/debugger/debugosx.h index 8de62ed911f..46e7b18305f 100644 --- a/src/osd/modules/debugger/debugosx.h +++ b/src/osd/modules/debugger/debugosx.h @@ -18,6 +18,7 @@ // MAME headers #include "emu.h" #include "debug/debugvw.h" +#include "modules/lib/osdobj_common.h" #ifdef __OBJC__ @@ -373,10 +374,12 @@ public: debugger_osx(const osd_interface &osd); virtual ~debugger_osx() { } - virtual void init_debugger(); + virtual void init_debugger(running_machine &machine); virtual void wait_for_debugger(device_t &device, bool firststop); virtual void debugger_update(); virtual void debugger_exit(); +private: + running_machine *m_machine; }; extern const osd_debugger_type OSD_DEBUGGER_OSX; diff --git a/src/osd/modules/debugger/debugosx.m b/src/osd/modules/debugger/debugosx.m index 196cc94bc18..1df4a9a27ac 100644 --- a/src/osd/modules/debugger/debugosx.m +++ b/src/osd/modules/debugger/debugosx.m @@ -73,7 +73,7 @@ const osd_debugger_type OSD_DEBUGGER_OSX = &osd_debugger_creator; // debugger_osx - constructor //------------------------------------------------- debugger_osx::debugger_osx(const osd_interface &osd) - : osd_debugger_interface(osd) + : osd_debugger_interface(osd), m_machine(NULL) { } @@ -81,8 +81,9 @@ debugger_osx::debugger_osx(const osd_interface &osd) // debugger_osx::init_debugger //============================================================ -void debugger_osx::init_debugger() +void debugger_osx::init_debugger(running_machine &machine) { + m_machine = &machine; } //============================================================ @@ -93,7 +94,7 @@ void debugger_osx::wait_for_debugger(device_t &device, bool firststop) { // create a console window if (main_console == nil) - console_create_window(m_osd.machine()); + console_create_window(*m_machine); // make sure the debug windows are visible waiting_for_debugger = YES; diff --git a/src/osd/modules/debugger/debugqt.c b/src/osd/modules/debugger/debugqt.c index 7ae32540b0a..9b196675450 100644 --- a/src/osd/modules/debugger/debugqt.c +++ b/src/osd/modules/debugger/debugqt.c @@ -19,6 +19,7 @@ #include "emu.h" #include "config.h" #include "debugger.h" +#include "modules/lib/osdobj_common.h" #include "qt/debugqtlogwindow.h" #include "qt/debugqtmainwindow.h" @@ -50,7 +51,7 @@ static MainWindow* mainQtWindow = NULL; // debugger_qt - constructor //------------------------------------------------- debugger_qt::debugger_qt(const osd_interface &osd) - : osd_debugger_interface(osd) + : osd_debugger_interface(osd), m_machine(NULL) { } @@ -227,7 +228,7 @@ static void bring_main_window_to_front() bool winwindow_qt_filter(void *message); #endif -void debugger_qt::init_debugger() +void debugger_qt::init_debugger(running_machine &machine) { if (qApp == NULL) { @@ -249,11 +250,12 @@ void debugger_qt::init_debugger() oneShot = true; } + m_machine = &machine; // Setup the configuration XML saving and loading - config_register(m_osd.machine(), + config_register(machine, "debugger", - config_saveload_delegate(FUNC(xml_configuration_load), &m_osd.machine()), - config_saveload_delegate(FUNC(xml_configuration_save), &m_osd.machine())); + config_saveload_delegate(FUNC(xml_configuration_load), &machine), + config_saveload_delegate(FUNC(xml_configuration_save), &machine)); } @@ -276,9 +278,9 @@ void debugger_qt::wait_for_debugger(device_t &device, bool firststop) // Dialog initialization if (oneShot) { - mainQtWindow = new MainWindow(&m_osd.machine()); + mainQtWindow = new MainWindow(m_machine); load_and_clear_main_window_config(xmlConfigurations); - setup_additional_startup_windows(m_osd.machine(), xmlConfigurations); + setup_additional_startup_windows(*m_machine, xmlConfigurations); mainQtWindow->show(); oneShot = false; } @@ -325,7 +327,7 @@ void debugger_qt::wait_for_debugger(device_t &device, bool firststop) } // Exit if the machine has been instructed to do so (scheduled event == exit || hard_reset) - if (m_osd.machine().scheduled_event_pending()) + if (m_machine->scheduled_event_pending()) { // Keep a list of windows we want to save. // We need to do this here because by the time xml_configuration_save gets called diff --git a/src/osd/modules/debugger/debugqt.h b/src/osd/modules/debugger/debugqt.h index 6accc743a83..51bf3cf27b2 100644 --- a/src/osd/modules/debugger/debugqt.h +++ b/src/osd/modules/debugger/debugqt.h @@ -14,7 +14,7 @@ #ifndef __DEBUGGER_QT_H__ #define __DEBUGGER_QT_H__ -#include "osdepend.h" +#include "emu.h" class debugger_qt : public osd_debugger_interface { @@ -23,10 +23,13 @@ public: debugger_qt(const osd_interface &osd); virtual ~debugger_qt(); - virtual void init_debugger(); + virtual void init_debugger(running_machine &machine); virtual void wait_for_debugger(device_t &device, bool firststop); virtual void debugger_update(); virtual void debugger_exit(); + +private: + running_machine *m_machine; }; extern const osd_debugger_type OSD_DEBUGGER_QT; diff --git a/src/osd/modules/debugger/debugwin.c b/src/osd/modules/debugger/debugwin.c index 7092f870bda..f6e536554d9 100644 --- a/src/osd/modules/debugger/debugwin.c +++ b/src/osd/modules/debugger/debugwin.c @@ -257,7 +257,7 @@ void debugger_windows::wait_for_debugger(device_t &device, bool firststop) // create a console window if (main_console == NULL) - console_create_window(m_osd.machine()); + console_create_window(*m_machine); // update the views in the console to reflect the current CPU if (main_console != NULL) @@ -276,7 +276,7 @@ void debugger_windows::wait_for_debugger(device_t &device, bool firststop) smart_show_all(TRUE); // run input polling to ensure that our status is in sync - wininput_poll(m_osd.machine()); + wininput_poll(*m_machine); // get and process messages GetMessage(&message, NULL, 0, 0); @@ -294,7 +294,7 @@ void debugger_windows::wait_for_debugger(device_t &device, bool firststop) // process everything else default: - winwindow_dispatch_message(m_osd.machine(), &message); + winwindow_dispatch_message(*m_machine, &message); break; } @@ -368,10 +368,11 @@ static int debugwin_seq_pressed(running_machine &machine) // debugwin_init_windows //============================================================ -void debugger_windows::init_debugger() +void debugger_windows::init_debugger(running_machine &machine) { static int class_registered; + m_machine = &machine; // register the window classes if (!class_registered) { @@ -414,7 +415,7 @@ void debugger_windows::init_debugger() if (temp_dc != NULL) { - windows_options &options = downcast(m_osd.machine().options()); + windows_options &options = downcast(m_machine->options()); int size = options.debugger_font_size(); TCHAR *t_face; @@ -474,15 +475,15 @@ void debugger_windows::debugger_exit() void debugger_windows::debugger_update() { // if we're running live, do some checks - if (!winwindow_has_focus() && !debug_cpu_is_stopped(m_osd.machine()) && m_osd.machine().phase() == MACHINE_PHASE_RUNNING) + if (!winwindow_has_focus() && !debug_cpu_is_stopped(*m_machine) && m_machine->phase() == MACHINE_PHASE_RUNNING) { // see if the interrupt key is pressed and break if it is - if (debugwin_seq_pressed(m_osd.machine())) + if (debugwin_seq_pressed(*m_machine)) { HWND focuswnd = GetFocus(); debugwin_info *info; - debug_cpu_get_visible_cpu(m_osd.machine())->debug()->halt_on_next_instruction("User-initiated break\n"); + debug_cpu_get_visible_cpu(*m_machine)->debug()->halt_on_next_instruction("User-initiated break\n"); // if we were focused on some window's edit box, reset it to default for (info = window_list; info != NULL; info = info->next) diff --git a/src/osd/modules/debugger/debugwin.h b/src/osd/modules/debugger/debugwin.h index e35fe20b1b0..9891c227d9f 100644 --- a/src/osd/modules/debugger/debugwin.h +++ b/src/osd/modules/debugger/debugwin.h @@ -13,6 +13,7 @@ #define __DEBUGGER_WINDOWS_H__ #include "osdepend.h" +#include "modules/lib/osdobj_common.h" class debugger_windows : public osd_debugger_interface { @@ -21,10 +22,12 @@ public: debugger_windows(const osd_interface &osd); virtual ~debugger_windows() { } - virtual void init_debugger(); + virtual void init_debugger(running_machine &machine); virtual void wait_for_debugger(device_t &device, bool firststop); virtual void debugger_update(); virtual void debugger_exit(); +private: + running_machine *m_machine; }; extern const osd_debugger_type OSD_DEBUGGER_WINDOWS; diff --git a/src/osd/modules/debugger/none.c b/src/osd/modules/debugger/none.c index fd6d55ca3dc..a3a29b290d5 100644 --- a/src/osd/modules/debugger/none.c +++ b/src/osd/modules/debugger/none.c @@ -13,17 +13,18 @@ const osd_debugger_type OSD_DEBUGGER_NONE = &osd_debugger_creator // debugger_none - constructor //------------------------------------------------- debugger_none::debugger_none(const osd_interface &osd) - : osd_debugger_interface(osd) + : osd_debugger_interface(osd), m_machine(NULL) { } -void debugger_none::init_debugger() +void debugger_none::init_debugger(running_machine &machine) { + m_machine = &machine; } void debugger_none::wait_for_debugger(device_t &device, bool firststop) { - debug_cpu_get_visible_cpu(m_osd.machine())->debug()->go(); + debug_cpu_get_visible_cpu(*m_machine)->debug()->go(); } void debugger_none::debugger_update() diff --git a/src/osd/modules/debugger/none.h b/src/osd/modules/debugger/none.h index a93001b572b..ee87e22548a 100644 --- a/src/osd/modules/debugger/none.h +++ b/src/osd/modules/debugger/none.h @@ -14,6 +14,7 @@ #define __DEBUGGER_NONE_H__ #include "osdepend.h" +#include "modules/lib/osdobj_common.h" class debugger_none : public osd_debugger_interface { @@ -22,10 +23,12 @@ public: debugger_none(const osd_interface &osd); virtual ~debugger_none() { } - virtual void init_debugger(); + virtual void init_debugger(running_machine &machine); virtual void wait_for_debugger(device_t &device, bool firststop); virtual void debugger_update(); virtual void debugger_exit(); +private: + running_machine *m_machine; }; extern const osd_debugger_type OSD_DEBUGGER_NONE; diff --git a/src/osd/modules/lib/osdobj_common.c b/src/osd/modules/lib/osdobj_common.c new file mode 100644 index 00000000000..90d51c4e4de --- /dev/null +++ b/src/osd/modules/lib/osdobj_common.c @@ -0,0 +1,509 @@ +// license:BSD-3-Clause +// copyright-holders:Aaron Giles +/*************************************************************************** + + osdepend.c + + OS-dependent code interface. + +*******************************************************************c********/ + + +#include "emu.h" +#include "osdepend.h" +#include "modules/sound/none.h" +#include "modules/debugger/none.h" +#include "modules/debugger/debugint.h" + +extern bool g_print_verbose; + + +//------------------------------------------------- +// osd_interface - constructor +//------------------------------------------------- + +osd_common_t::osd_common_t() + : m_machine(NULL), + m_sound(NULL), + m_debugger(NULL) + +{ +} + +void osd_common_t::update_option(osd_options &options, const char * key, dynamic_array &values) +{ + astring current_value(options.description(key)); + astring new_option_value(""); + for (int index = 0; index < values.count(); index++) + { + astring t(values[index]); + if (new_option_value.len() > 0) + { + if( index != (values.count()-1)) + new_option_value.cat(", "); + else + new_option_value.cat(" or "); + } + new_option_value.cat(t); + } + // TODO: core_strdup() is leaked + 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 +//------------------------------------------------- + +osd_common_t::~osd_common_t() +{ + for(int i= 0; i < m_video_names.count(); ++i) + osd_free(const_cast(m_video_names[i])); + //m_video_options,reset(); + + for(int i= 0; i < m_sound_names.count(); ++i) + osd_free(const_cast(m_sound_names[i])); + m_sound_options.reset(); + + for(int i= 0; i < m_debugger_names.count(); ++i) + osd_free(const_cast(m_debugger_names[i])); + m_debugger_options.reset(); +} + + +//------------------------------------------------- +// init - initialize the OSD system. +//------------------------------------------------- + +void osd_common_t::init(running_machine &machine) +{ + // + // This function is responsible for initializing the OSD-specific + // video and input functionality, and registering that functionality + // with the MAME core. + // + // In terms of video, this function is expected to create one or more + // render_targets that will be used by the MAME core to provide graphics + // data to the system. Although it is possible to do this later, the + // assumption in the MAME core is that the user interface will be + // visible starting at init() time, so you will have some work to + // do to avoid these assumptions. + // + // In terms of input, this function is expected to enumerate all input + // devices available and describe them to the MAME core by adding + // input devices and their attached items (buttons/axes) via the input + // system. + // + // Beyond these core responsibilities, init() should also initialize + // any other OSD systems that require information about the current + // running_machine. + // + // This callback is also the last opportunity to adjust the options + // before they are consumed by the rest of the core. + // + // Future work/changes: + // + // Audio initialization may eventually move into here as well, + // instead of relying on independent callbacks from each system. + // + + m_machine = &machine; + + osd_options &options = downcast(machine.options()); + // extract the verbose printing option + if (options.verbose()) + g_print_verbose = true; + + // ensure we get called on the way out + machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_common_t::osd_exit), this)); +} + + +//------------------------------------------------- +// update - periodic system update +//------------------------------------------------- + +void osd_common_t::update(bool skip_redraw) +{ + // + // This method is called periodically to flush video updates to the + // screen, and also to allow the OSD a chance to update other systems + // on a regular basis. In general this will be called at the frame + // rate of the system being run; however, it may be called at more + // irregular intervals in some circumstances (e.g., multi-screen games + // or games with asynchronous updates). + // +} + + +//------------------------------------------------- +// init_debugger - perform debugger-specific +// initialization +//------------------------------------------------- + +void osd_common_t::init_debugger() +{ + // + // Unlike init() above, this method is only called if the 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()); + if (debugger==NULL) + { + osd_printf_warning("debugger_init: option %s not found switching to auto\n",machine().options().debugger()); + debugger = m_debugger_options.find("auto"); + } + m_debugger = (*debugger)(*this); + + m_debugger->init_debugger(machine()); +} + + +//------------------------------------------------- +// wait_for_debugger - wait for a debugger +// command to be processed +//------------------------------------------------- + +void osd_common_t::wait_for_debugger(device_t &device, bool firststop) +{ + // + // When implementing an OSD-driver debugger, this method should be + // overridden to wait for input, process it, and return. It will be + // called repeatedly until a command is issued that resumes + // execution. + // + m_debugger->wait_for_debugger(device, firststop); +} + +void osd_common_t::debugger_update() +{ + if (m_debugger) m_debugger->debugger_update(); +} + +void osd_common_t::debugger_exit() +{ + if (m_debugger) + { + m_debugger->debugger_exit(); + global_free(m_debugger); + m_debugger = NULL; + } +} + +//------------------------------------------------- +// update_audio_stream - update the stereo audio +// stream +//------------------------------------------------- + +void osd_common_t::update_audio_stream(const INT16 *buffer, int samples_this_frame) +{ + // + // This method is called whenever the system has new audio data to stream. + // 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); +} + + +//------------------------------------------------- +// set_mastervolume - set the system volume +//------------------------------------------------- + +void osd_common_t::set_mastervolume(int attenuation) +{ + // + // Attenuation is the attenuation in dB (a negative number). + // To convert from dB to a linear volume scale do the following: + // volume = MAX_VOLUME; + // while (attenuation++ < 0) + // volume /= 1.122018454; // = (10 ^ (1/20)) = 1dB + // + m_sound->set_mastervolume(attenuation); +} + + +//------------------------------------------------- +// customize_input_type_list - provide OSD +// additions/modifications to the input list +//------------------------------------------------- + +void osd_common_t::customize_input_type_list(simple_list &typelist) +{ + // + // inptport.c defines some general purpose defaults for key and joystick bindings. + // They may be further adjusted by the OS dependent code to better match the + // available keyboard, e.g. one could map pause to the Pause key instead of P, or + // snapshot to PrtScr instead of F12. Of course the user can further change the + // settings to anything he/she likes. + // + // This function is called on startup, before reading the configuration from disk. + // Scan the list, and change the keys/joysticks you want. + // +} + + +//------------------------------------------------- +// font_open - attempt to "open" a handle to the +// font with the given name +//------------------------------------------------- + +osd_font osd_common_t::font_open(const char *name, int &height) +{ + return NULL; +} + + +//------------------------------------------------- +// font_close - release resources associated with +// a given OSD font +//------------------------------------------------- + +void osd_common_t::font_close(osd_font font) +{ +} + + +//------------------------------------------------- +// font_get_bitmap - allocate and populate a +// BITMAP_FORMAT_ARGB32 bitmap containing the +// pixel values rgb_t(0xff,0xff,0xff,0xff) +// or rgb_t(0x00,0xff,0xff,0xff) for each +// pixel of a black & white font +//------------------------------------------------- + +bool osd_common_t::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) +{ + return false; +} + +//------------------------------------------------- +// get_slider_list - allocate and populate a +// list of OS-dependent slider values. +//------------------------------------------------- +void *osd_common_t::get_slider_list() +{ + return NULL; +} + +void osd_common_t::init_subsystems() +{ + if (!video_init()) + { + video_exit(); + osd_printf_error("video_init: Initialization failed!\n\n\n"); + fflush(stderr); + fflush(stdout); + exit(-1); + } + + sound_init(); + input_init(); + // we need pause callbacks + machine().add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(osd_common_t::input_pause), this)); + machine().add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(osd_common_t::input_resume), this)); + + output_init(); +#ifdef USE_NETWORK + network_init(); +#endif + midi_init(); +} + +bool osd_common_t::video_init() +{ + return true; +} + +bool osd_common_t::window_init() +{ + return true; +} + +bool osd_common_t::sound_init() +{ + osd_sound_type sound = m_sound_options.find(machine().options().sound()); + if (sound==NULL) + { + osd_printf_warning("sound_init: option %s not found switching to auto\n",machine().options().sound()); + sound = m_sound_options.find("auto"); + } + m_sound = (*sound)(*this, machine()); + return true; +} + +bool osd_common_t::no_sound() +{ + return (strcmp(machine().options().sound(),"none")==0) ? true : false; +} + +void osd_common_t::video_register() +{ +} + +void osd_common_t::sound_register() +{ +} + +void osd_common_t::debugger_register() +{ +} + +bool osd_common_t::input_init() +{ + return true; +} + +void osd_common_t::input_pause() +{ +} + +void osd_common_t::input_resume() +{ +} + +bool osd_common_t::output_init() +{ + return true; +} + +bool osd_common_t::network_init() +{ + return true; +} + +void osd_common_t::exit_subsystems() +{ + video_exit(); + sound_exit(); + input_exit(); + output_exit(); + #ifdef USE_NETWORK + network_exit(); + #endif + midi_exit(); + debugger_exit(); +} + +void osd_common_t::video_exit() +{ +} + +void osd_common_t::window_exit() +{ +} + +void osd_common_t::sound_exit() +{ + global_free(m_sound); +} + +void osd_common_t::input_exit() +{ +} + +void osd_common_t::output_exit() +{ +} + +void osd_common_t::network_exit() +{ +} + +void osd_common_t::osd_exit() +{ + exit_subsystems(); +} + +void osd_common_t::video_options_add(const char *name, void *type) +{ + //m_video_options.add(name, type, false); + m_video_names.append(core_strdup(name)); +} + +void osd_common_t::sound_options_add(const char *name, osd_sound_type type) +{ + m_sound_options.add(name, type, false); + m_sound_names.append(core_strdup(name)); +} + +void osd_common_t::debugger_options_add(const char *name, osd_debugger_type type) +{ + m_debugger_options.add(name, type, false); + m_debugger_names.append(core_strdup(name)); +} + +bool osd_common_t::midi_init() +{ + // this should be done on the OS_level + return osd_midi_init(); +} + +//------------------------------------------------- +// list_midi_devices - list available midi devices +//------------------------------------------------- + +void osd_common_t::list_midi_devices(void) +{ + osd_list_midi_devices(); +} + +void osd_common_t::midi_exit() +{ + osd_midi_exit(); +} + +//------------------------------------------------- +// osd_sound_interface - constructor +//------------------------------------------------- + +osd_sound_interface::osd_sound_interface(const osd_interface &osd, running_machine &machine) + : m_osd(osd), m_machine(machine) +{ +} + +//------------------------------------------------- +// osd_sound_interface - destructor +//------------------------------------------------- + +osd_sound_interface::~osd_sound_interface() +{ +} + +//------------------------------------------------- +// osd_debugger_interface - constructor +//------------------------------------------------- + +osd_debugger_interface::osd_debugger_interface(const osd_interface &osd) + : m_osd(osd) +{ +} + +//------------------------------------------------- +// osd_debugger_interface - destructor +//------------------------------------------------- + +osd_debugger_interface::~osd_debugger_interface() +{ +} + diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h new file mode 100644 index 00000000000..4b11c72b8d8 --- /dev/null +++ b/src/osd/modules/lib/osdobj_common.h @@ -0,0 +1,189 @@ +// license:BSD-3-Clause +// copyright-holders:Aaron Giles +/*************************************************************************** + + osdepend.h + + OS-dependent code interface. + +*******************************************************************c********/ + +#pragma once + +#ifndef __OSDOBJ_COMMON_H__ +#define __OSDOBJ_COMMON__ + +#include "osdepend.h" +#include "options.h" + + +#if 0 +// forward references +class input_type_entry; +class device_t; +#endif + +class osd_sound_interface; +class osd_debugger_interface; + +// a osd_sound_type is simply a pointer to its alloc function +typedef osd_sound_interface *(*osd_sound_type)(const osd_interface &osd, running_machine &machine); + +// a osd_sound_type is simply a pointer to its alloc function +typedef osd_debugger_interface *(*osd_debugger_type)(const osd_interface &osd); + + +// ======================> osd_interface + +// description of the currently-running machine +class osd_common_t : public osd_interface +{ +public: + // construction/destruction + osd_common_t(); + virtual ~osd_common_t(); + + virtual void register_options(osd_options &options); + + // general overridables + virtual void init(running_machine &machine); + virtual void update(bool skip_redraw); + + // debugger overridables + virtual void init_debugger(); + virtual void wait_for_debugger(device_t &device, bool firststop); + + // audio overridables + virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); + virtual void set_mastervolume(int attenuation); + virtual bool no_sound(); + + // input overridables + virtual void customize_input_type_list(simple_list &typelist); + + // font overridables + virtual osd_font font_open(const char *name, int &height); + virtual void font_close(osd_font font); + virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); + + // video overridables + virtual void *get_slider_list(); + + // midi overridables + // FIXME: this should return a list of devices, not list them on stdout + virtual void list_midi_devices(void); + + virtual void list_network_adapters() + { + network_init(); + osd_list_network_adapters(); + network_exit(); + } + + + // FIXME: everything below seems to be osd specific and not part of + // this INTERFACE but part of the osd IMPLEMENTATION + + // getters + running_machine &machine() { assert(m_machine != NULL); return *m_machine; } + + + virtual void debugger_update(); + virtual void debugger_exit(); + virtual void debugger_register(); + + virtual void init_subsystems(); + + virtual bool video_init(); + virtual void video_register(); + virtual bool window_init(); + + virtual bool sound_init(); + virtual void sound_register(); + + virtual bool input_init(); + virtual void input_pause(); + virtual void input_resume(); + virtual bool output_init(); + virtual bool network_init(); + virtual bool midi_init(); + + virtual void exit_subsystems(); + virtual void video_exit(); + virtual void window_exit(); + virtual void sound_exit(); + virtual void input_exit(); + virtual void output_exit(); + virtual void network_exit(); + virtual void midi_exit(); + + virtual void osd_exit(); + + virtual void video_options_add(const char *name, void *type); + virtual void sound_options_add(const char *name, osd_sound_type type); + virtual void debugger_options_add(const char *name, osd_debugger_type type); + +private: + // internal state + running_machine * m_machine; + + void update_option(osd_options &options, const char * key, dynamic_array &values); + +protected: + osd_sound_interface* m_sound; + osd_debugger_interface* m_debugger; +private: + //tagmap_t m_video_options; + dynamic_array m_video_names; + tagmap_t m_sound_options; + dynamic_array m_sound_names; + tagmap_t m_debugger_options; + dynamic_array m_debugger_names; +}; + + +class osd_sound_interface +{ +public: + // construction/destruction + osd_sound_interface(const osd_interface &osd, running_machine &machine); + virtual ~osd_sound_interface(); + + virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame) = 0; + virtual void set_mastervolume(int attenuation) = 0; +protected: + const osd_interface& m_osd; + running_machine& m_machine; +}; + +// this template function creates a stub which constructs a sound subsystem +template +osd_sound_interface *osd_sound_creator(const osd_interface &osd, running_machine &machine) +{ + return global_alloc(_DeviceClass(osd, machine)); +} + +class osd_debugger_interface +{ +public: + // construction/destruction + osd_debugger_interface(const osd_interface &osd); + virtual ~osd_debugger_interface(); + + virtual void init_debugger(running_machine &machine) = 0; + virtual void wait_for_debugger(device_t &device, bool firststop) = 0; + virtual void debugger_update() = 0; + virtual void debugger_exit() = 0; + +protected: + const osd_interface& m_osd; +}; + +// this template function creates a stub which constructs a debugger +template +osd_debugger_interface *osd_debugger_creator(const osd_interface &osd) +{ + return global_alloc(_DeviceClass(osd)); +} + +#endif /* __OSDOBJ_COMMON_H__ */ diff --git a/src/osd/modules/sound/direct_sound.c b/src/osd/modules/sound/direct_sound.c index 18475bcc67c..39548eacf06 100644 --- a/src/osd/modules/sound/direct_sound.c +++ b/src/osd/modules/sound/direct_sound.c @@ -78,8 +78,8 @@ const osd_sound_type OSD_SOUND_DIRECT_SOUND = &osd_sound_creator(m_osd.machine().options()).audio_latency(); + audio_latency = downcast(m_machine.options()).audio_latency(); #else - audio_latency = downcast(m_osd.machine().options()).audio_latency(); + audio_latency = downcast(m_machine.options()).audio_latency(); #endif stream_buffer_size = stream_format.nSamplesPerSec * stream_format.nBlockAlign * audio_latency / 10; stream_buffer_size = (stream_buffer_size / 1024) * 1024; diff --git a/src/osd/modules/sound/direct_sound.h b/src/osd/modules/sound/direct_sound.h index 52eba856583..2bd155c45d2 100644 --- a/src/osd/modules/sound/direct_sound.h +++ b/src/osd/modules/sound/direct_sound.h @@ -21,12 +21,13 @@ #undef interface #include "osdepend.h" +#include "modules/lib/osdobj_common.h" class sound_direct_sound : public osd_sound_interface { public: // construction/destruction - sound_direct_sound(const osd_interface &osd); + sound_direct_sound(const osd_interface &osd, running_machine &machine); virtual ~sound_direct_sound(); virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); diff --git a/src/osd/modules/sound/none.c b/src/osd/modules/sound/none.c index 6e776f03a78..453038c66ca 100644 --- a/src/osd/modules/sound/none.c +++ b/src/osd/modules/sound/none.c @@ -14,8 +14,8 @@ //------------------------------------------------- // sound_none - constructor //------------------------------------------------- -sound_none::sound_none(const osd_interface &osd) - : osd_sound_interface(osd) +sound_none::sound_none(const osd_interface &osd, running_machine &machine) + : osd_sound_interface(osd, machine) { } diff --git a/src/osd/modules/sound/none.h b/src/osd/modules/sound/none.h index fbe4f14f565..698f1042d70 100644 --- a/src/osd/modules/sound/none.h +++ b/src/osd/modules/sound/none.h @@ -14,12 +14,13 @@ #define __SOUND_NONE_H__ #include "osdepend.h" +#include "modules/lib/osdobj_common.h" class sound_none : public osd_sound_interface { public: // construction/destruction - sound_none(const osd_interface &osd); + sound_none(const osd_interface &osd, running_machine &machine); virtual ~sound_none() { } virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame) { } diff --git a/src/osd/modules/sound/sdl_sound.c b/src/osd/modules/sound/sdl_sound.c index 22f63a67017..13e725dcf3c 100644 --- a/src/osd/modules/sound/sdl_sound.c +++ b/src/osd/modules/sound/sdl_sound.c @@ -80,14 +80,14 @@ const osd_sound_type OSD_SOUND_SDL = &osd_sound_creator; //------------------------------------------------- // sound_sdl - constructor //------------------------------------------------- -sound_sdl::sound_sdl(const osd_interface &osd) - : osd_sound_interface(osd) +sound_sdl::sound_sdl(const osd_interface &osd, running_machine &machine) + : osd_sound_interface(osd, machine) { if (LOG_SOUND) sound_log = fopen(SDLMAME_SOUND_LOG, "w"); // skip if sound disabled - if (osd.machine().sample_rate() != 0) + if (m_machine.sample_rate() != 0) { if (initialized_audio) { @@ -95,7 +95,7 @@ sound_sdl::sound_sdl(const osd_interface &osd) } // attempt to initialize SDL - if (sdl_init(osd.machine())) + if (sdl_init(m_machine)) return; // set the startup volume @@ -112,11 +112,11 @@ sound_sdl::sound_sdl(const osd_interface &osd) sound_sdl::~sound_sdl() { // if nothing to do, don't do it - if (m_osd.machine().sample_rate() == 0) + if (m_machine.sample_rate() == 0) return; // kill the buffers and dsound - sdl_kill(m_osd.machine()); + sdl_kill(m_machine); sdl_destroy_buffers(); // print out over/underflow stats @@ -267,7 +267,7 @@ static void copy_sample_data(running_machine &machine, const INT16 *data, int by void sound_sdl::update_audio_stream(const INT16 *buffer, int samples_this_frame) { // if nothing to do, don't do it - if (m_osd.machine().sample_rate() != 0 && stream_buffer) + if (m_machine.sample_rate() != 0 && stream_buffer) { int bytes_this_frame = samples_this_frame * sizeof(INT16) * 2; int play_position, write_position, stream_in; @@ -275,7 +275,7 @@ void sound_sdl::update_audio_stream(const INT16 *buffer, int samples_this_frame) play_position = stream_playpos; - write_position = stream_playpos + ((m_osd.machine().sample_rate() / 50) * sizeof(INT16) * 2); + write_position = stream_playpos + ((m_machine.sample_rate() / 50) * sizeof(INT16) * 2); orig_write = write_position; if (!stream_in_initialized) @@ -336,7 +336,7 @@ void sound_sdl::update_audio_stream(const INT16 *buffer, int samples_this_frame) // now we know where to copy; let's do it stream_buffer_in = stream_in; - copy_sample_data(m_osd.machine(), buffer, bytes_this_frame); + copy_sample_data(m_machine, buffer, bytes_this_frame); } } diff --git a/src/osd/modules/sound/sdl_sound.h b/src/osd/modules/sound/sdl_sound.h index 3f3053bd193..241dbcf4a67 100644 --- a/src/osd/modules/sound/sdl_sound.h +++ b/src/osd/modules/sound/sdl_sound.h @@ -14,12 +14,13 @@ #define __SOUND_SDL_H__ #include "osdepend.h" +#include "modules/lib/osdobj_common.h" class sound_sdl : public osd_sound_interface { public: // construction/destruction - sound_sdl(const osd_interface &osd); + sound_sdl(const osd_interface &osd, running_machine &machine); virtual ~sound_sdl(); virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); diff --git a/src/osd/osdepend.c b/src/osd/osdepend.c index 9083999337b..8c8139b79a5 100644 --- a/src/osd/osdepend.c +++ b/src/osd/osdepend.c @@ -1,568 +1,69 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles -/*************************************************************************** - - osdepend.c - - OS-dependent code interface. - -*******************************************************************c********/ - - -#include "emu.h" #include "osdepend.h" -#include "modules/sound/none.h" -#include "modules/debugger/none.h" -#include "modules/debugger/debugint.h" - -extern bool g_print_verbose; 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" }, + // 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 x[@] 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 x[@] 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 x[@] 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 x[@] 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 x[@] 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 } + { 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 x[@] 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 x[@] 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 x[@] 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 x[@] 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 x[@] 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::osd_options() -{ -} - - -void osd_options::add_osd_options() -{ - add_entries(s_option_entries); -} - -//------------------------------------------------- -// osd_interface - constructor -//------------------------------------------------- - -osd_interface::osd_interface() - : m_machine(NULL), - m_sound(NULL), - m_debugger(NULL) - -{ -} - -void osd_interface::update_option(osd_options &options, const char * key, dynamic_array &values) -{ - astring current_value(options.description(key)); - astring new_option_value(""); - for (int index = 0; index < values.count(); index++) - { - astring t(values[index]); - if (new_option_value.len() > 0) - { - if( index != (values.count()-1)) - new_option_value.cat(", "); - else - new_option_value.cat(" or "); - } - new_option_value.cat(t); - } - // TODO: core_strdup() is leaked - options.set_description(key, core_strdup(current_value.cat(new_option_value).cstr())); -} - -void osd_interface::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 -//------------------------------------------------- - -osd_interface::~osd_interface() -{ - for(int i= 0; i < m_video_names.count(); ++i) - osd_free(const_cast(m_video_names[i])); - //m_video_options,reset(); - - for(int i= 0; i < m_sound_names.count(); ++i) - osd_free(const_cast(m_sound_names[i])); - m_sound_options.reset(); - - for(int i= 0; i < m_debugger_names.count(); ++i) - osd_free(const_cast(m_debugger_names[i])); - m_debugger_options.reset(); -} - - -//------------------------------------------------- -// init - initialize the OSD system. -//------------------------------------------------- - -void osd_interface::init(running_machine &machine) -{ - // - // This function is responsible for initializing the OSD-specific - // video and input functionality, and registering that functionality - // with the MAME core. - // - // In terms of video, this function is expected to create one or more - // render_targets that will be used by the MAME core to provide graphics - // data to the system. Although it is possible to do this later, the - // assumption in the MAME core is that the user interface will be - // visible starting at init() time, so you will have some work to - // do to avoid these assumptions. - // - // In terms of input, this function is expected to enumerate all input - // devices available and describe them to the MAME core by adding - // input devices and their attached items (buttons/axes) via the input - // system. - // - // Beyond these core responsibilities, init() should also initialize - // any other OSD systems that require information about the current - // running_machine. - // - // This callback is also the last opportunity to adjust the options - // before they are consumed by the rest of the core. - // - // Future work/changes: - // - // Audio initialization may eventually move into here as well, - // instead of relying on independent callbacks from each system. - // - - m_machine = &machine; - - osd_options &options = downcast(machine.options()); - // extract the verbose printing option - if (options.verbose()) - g_print_verbose = true; - - // ensure we get called on the way out - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_interface::osd_exit), this)); -} - - -//------------------------------------------------- -// update - periodic system update -//------------------------------------------------- - -void osd_interface::update(bool skip_redraw) -{ - // - // This method is called periodically to flush video updates to the - // screen, and also to allow the OSD a chance to update other systems - // on a regular basis. In general this will be called at the frame - // rate of the system being run; however, it may be called at more - // irregular intervals in some circumstances (e.g., multi-screen games - // or games with asynchronous updates). - // -} - - -//------------------------------------------------- -// init_debugger - perform debugger-specific -// initialization -//------------------------------------------------- - -void osd_interface::init_debugger() -{ - // - // Unlike init() above, this method is only called if the 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()); - if (debugger==NULL) - { - osd_printf_warning("debugger_init: option %s not found switching to auto\n",machine().options().debugger()); - debugger = m_debugger_options.find("auto"); - } - m_debugger = (*debugger)(*this); - - m_debugger->init_debugger(); -} - - -//------------------------------------------------- -// wait_for_debugger - wait for a debugger -// command to be processed -//------------------------------------------------- - -void osd_interface::wait_for_debugger(device_t &device, bool firststop) -{ - // - // When implementing an OSD-driver debugger, this method should be - // overridden to wait for input, process it, and return. It will be - // called repeatedly until a command is issued that resumes - // execution. - // - m_debugger->wait_for_debugger(device, firststop); -} - -void osd_interface::debugger_update() -{ - if (m_debugger) m_debugger->debugger_update(); -} - -void osd_interface::debugger_exit() -{ - if (m_debugger) - { - m_debugger->debugger_exit(); - global_free(m_debugger); - m_debugger = NULL; - } -} - -//------------------------------------------------- -// update_audio_stream - update the stereo audio -// stream -//------------------------------------------------- - -void osd_interface::update_audio_stream(const INT16 *buffer, int samples_this_frame) -{ - // - // This method is called whenever the system has new audio data to stream. - // 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); -} - - -//------------------------------------------------- -// set_mastervolume - set the system volume -//------------------------------------------------- - -void osd_interface::set_mastervolume(int attenuation) -{ - // - // Attenuation is the attenuation in dB (a negative number). - // To convert from dB to a linear volume scale do the following: - // volume = MAX_VOLUME; - // while (attenuation++ < 0) - // volume /= 1.122018454; // = (10 ^ (1/20)) = 1dB - // - m_sound->set_mastervolume(attenuation); -} - - -//------------------------------------------------- -// customize_input_type_list - provide OSD -// additions/modifications to the input list -//------------------------------------------------- - -void osd_interface::customize_input_type_list(simple_list &typelist) -{ - // - // inptport.c defines some general purpose defaults for key and joystick bindings. - // They may be further adjusted by the OS dependent code to better match the - // available keyboard, e.g. one could map pause to the Pause key instead of P, or - // snapshot to PrtScr instead of F12. Of course the user can further change the - // settings to anything he/she likes. - // - // This function is called on startup, before reading the configuration from disk. - // Scan the list, and change the keys/joysticks you want. - // -} - - -//------------------------------------------------- -// font_open - attempt to "open" a handle to the -// font with the given name -//------------------------------------------------- - -osd_font osd_interface::font_open(const char *name, int &height) -{ - return NULL; -} - - -//------------------------------------------------- -// font_close - release resources associated with -// a given OSD font -//------------------------------------------------- - -void osd_interface::font_close(osd_font font) -{ -} - - -//------------------------------------------------- -// font_get_bitmap - allocate and populate a -// BITMAP_FORMAT_ARGB32 bitmap containing the -// pixel values rgb_t(0xff,0xff,0xff,0xff) -// or rgb_t(0x00,0xff,0xff,0xff) for each -// pixel of a black & white font -//------------------------------------------------- - -bool osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) -{ - return false; -} - -//------------------------------------------------- -// get_slider_list - allocate and populate a -// list of OS-dependent slider values. -//------------------------------------------------- -void *osd_interface::get_slider_list() -{ - return NULL; -} - -void osd_interface::init_subsystems() -{ - if (!video_init()) - { - video_exit(); - osd_printf_error("video_init: Initialization failed!\n\n\n"); - fflush(stderr); - fflush(stdout); - exit(-1); - } - - sound_init(); - input_init(); - // we need pause callbacks - machine().add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(osd_interface::input_pause), this)); - machine().add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(osd_interface::input_resume), this)); - - output_init(); -#ifdef USE_NETWORK - network_init(); -#endif - midi_init(); -} - -bool osd_interface::video_init() -{ - return true; -} - -bool osd_interface::window_init() -{ - return true; -} - -bool osd_interface::sound_init() -{ - osd_sound_type sound = m_sound_options.find(machine().options().sound()); - if (sound==NULL) - { - osd_printf_warning("sound_init: option %s not found switching to auto\n",machine().options().sound()); - sound = m_sound_options.find("auto"); - } - m_sound = (*sound)(*this); - return true; -} - -bool osd_interface::no_sound() -{ - return (strcmp(machine().options().sound(),"none")==0) ? true : false; -} - -void osd_interface::video_register() -{ -} - -void osd_interface::sound_register() -{ -} - -void osd_interface::debugger_register() -{ -} - -bool osd_interface::input_init() -{ - return true; -} - -void osd_interface::input_pause() -{ -} - -void osd_interface::input_resume() -{ -} - -bool osd_interface::output_init() -{ - return true; -} - -bool osd_interface::network_init() -{ - return true; -} - -void osd_interface::exit_subsystems() -{ - video_exit(); - sound_exit(); - input_exit(); - output_exit(); - #ifdef USE_NETWORK - network_exit(); - #endif - midi_exit(); - debugger_exit(); -} - -void osd_interface::video_exit() -{ -} - -void osd_interface::window_exit() -{ -} - -void osd_interface::sound_exit() -{ - global_free(m_sound); -} - -void osd_interface::input_exit() -{ -} - -void osd_interface::output_exit() -{ -} - -void osd_interface::network_exit() -{ -} - -void osd_interface::osd_exit() -{ - exit_subsystems(); -} - -void osd_interface::video_options_add(const char *name, void *type) -{ - //m_video_options.add(name, type, false); - m_video_names.append(core_strdup(name)); -} - -void osd_interface::sound_options_add(const char *name, osd_sound_type type) -{ - m_sound_options.add(name, type, false); - m_sound_names.append(core_strdup(name)); -} - -void osd_interface::debugger_options_add(const char *name, osd_debugger_type type) -{ - m_debugger_options.add(name, type, false); - m_debugger_names.append(core_strdup(name)); -} -//------------------------------------------------- -// osd_sound_interface - constructor -//------------------------------------------------- - -osd_sound_interface::osd_sound_interface(const osd_interface &osd) - : m_osd(osd) -{ -} - -//------------------------------------------------- -// osd_sound_interface - destructor -//------------------------------------------------- - -osd_sound_interface::~osd_sound_interface() -{ -} - -//------------------------------------------------- -// osd_debugger_interface - constructor -//------------------------------------------------- - -osd_debugger_interface::osd_debugger_interface(const osd_interface &osd) - : m_osd(osd) -{ -} - -//------------------------------------------------- -// osd_debugger_interface - destructor -//------------------------------------------------- - -osd_debugger_interface::~osd_debugger_interface() -{ -} diff --git a/src/osd/osdepend.h b/src/osd/osdepend.h index 104039edf3d..26d8506da49 100644 --- a/src/osd/osdepend.h +++ b/src/osd/osdepend.h @@ -16,12 +16,19 @@ #include "emucore.h" #include "osdcore.h" #include "unicode.h" -#include "options.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" @@ -58,213 +65,109 @@ // 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(); - - // 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(); + // 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[]; + static const options_entry s_option_entries[]; }; -// forward references -class input_type_entry; -class device_t; -class osd_interface; -class osd_sound_interface; -class osd_debugger_interface; - +// FIXME: We can do better than this typedef void *osd_font; -// a osd_sound_type is simply a pointer to its alloc function -typedef osd_sound_interface *(*osd_sound_type)(const osd_interface &osd); - -// a osd_sound_type is simply a pointer to its alloc function -typedef osd_debugger_interface *(*osd_debugger_type)(const osd_interface &osd); - - // ======================> osd_interface // description of the currently-running machine class osd_interface { public: - // construction/destruction - osd_interface(); - virtual ~osd_interface(); - - void register_options(osd_options &options); - - // getters - running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } // general overridables - virtual void init(running_machine &machine); - virtual void update(bool skip_redraw); + virtual void init(running_machine &machine) = 0; + virtual void update(bool skip_redraw) = 0; // debugger overridables - void init_debugger(); - void wait_for_debugger(device_t &device, bool firststop); - void debugger_update(); - void debugger_exit(); - virtual void debugger_register(); + virtual void init_debugger() = 0; + virtual void wait_for_debugger(device_t &device, bool firststop) = 0; // audio overridables - void update_audio_stream(const INT16 *buffer, int samples_this_frame); - void set_mastervolume(int attenuation); + virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame) = 0; + virtual void set_mastervolume(int attenuation) = 0; + virtual bool no_sound() = 0; + // input overridables - virtual void customize_input_type_list(simple_list &typelist); + virtual void customize_input_type_list(simple_list &typelist) = 0; // font overridables - virtual osd_font font_open(const char *name, int &height); - virtual void font_close(osd_font font); - virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); + virtual osd_font font_open(const char *name, int &height) = 0; + virtual void font_close(osd_font font) = 0; + virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) = 0; // video overridables - virtual void *get_slider_list(); + virtual void *get_slider_list() = 0; // FIXME: returns slider_state * // midi overridables - // FIXME: this should return a list of devices, not list them on stdout - virtual void list_midi_devices(void); - - // FIXME: everything below seems to be osd specific and not part of - // this INTERFACE but part of the osd IMPLEMENTATION - - void init_subsystems(); - - virtual bool video_init(); - virtual void video_register(); - virtual bool window_init(); - - bool sound_init(); - virtual void sound_register(); - bool no_sound(); - - virtual bool input_init(); - virtual void input_pause(); - virtual void input_resume(); - virtual bool output_init(); - virtual bool network_init(); - virtual bool midi_init(); - - void exit_subsystems(); - virtual void video_exit(); - virtual void window_exit(); - void sound_exit(); - virtual void input_exit(); - virtual void output_exit(); - virtual void network_exit(); - virtual void midi_exit(); + // FIXME: this should return a list of devices, not list them on stdout, even better + // move this to OSD_OPTIONS + virtual void list_midi_devices(void) = 0; - virtual void osd_exit(); + virtual void list_network_adapters() = 0; - void video_options_add(const char *name, void *type); - void sound_options_add(const char *name, osd_sound_type type); - void debugger_options_add(const char *name, osd_debugger_type type); - -private: - // internal state - running_machine * m_machine; - - void update_option(osd_options &options, const char * key, dynamic_array &values); - -protected: - osd_sound_interface* m_sound; - osd_debugger_interface* m_debugger; -private: - //tagmap_t m_video_options; - dynamic_array m_video_names; - tagmap_t m_sound_options; - dynamic_array m_sound_names; - tagmap_t m_debugger_options; - dynamic_array m_debugger_names; -}; - -class osd_sound_interface -{ -public: - // construction/destruction - osd_sound_interface(const osd_interface &osd); - virtual ~osd_sound_interface(); - - virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame) = 0; - virtual void set_mastervolume(int attenuation) = 0; -protected: - const osd_interface& m_osd; }; -// this template function creates a stub which constructs a sound subsystem -template -osd_sound_interface *osd_sound_creator(const osd_interface &osd) -{ - return global_alloc(_DeviceClass(osd)); -} - -class osd_debugger_interface -{ -public: - // construction/destruction - osd_debugger_interface(const osd_interface &osd); - virtual ~osd_debugger_interface(); - - virtual void init_debugger() = 0; - virtual void wait_for_debugger(device_t &device, bool firststop) = 0; - virtual void debugger_update() = 0; - virtual void debugger_exit() = 0; - -protected: - const osd_interface& m_osd; -}; - -// this template function creates a stub which constructs a debugger -template -osd_debugger_interface *osd_debugger_creator(const osd_interface &osd) -{ - return global_alloc(_DeviceClass(osd)); -} - #endif /* __OSDEPEND_H__ */ diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index d64841f1905..58d156e8359 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -5,6 +5,7 @@ #include "watchdog.h" #include "clifront.h" +#include "modules/lib/osdobj_common.h" //============================================================ // System dependent defines @@ -176,7 +177,7 @@ private: }; -class sdl_osd_interface : public osd_interface +class sdl_osd_interface : public osd_common_t { public: // construction/destruction @@ -208,6 +209,7 @@ public: #ifdef USE_NETWORK virtual bool network_init(); #endif + //virtual bool midi_init(); virtual void video_exit(); virtual void window_exit(); @@ -216,6 +218,7 @@ public: #ifdef USE_NETWORK virtual void network_exit(); #endif + //virtual void midi_exit(); private: virtual void osd_exit(); diff --git a/src/osd/sdl/output.c b/src/osd/sdl/output.c index 2d3702362d3..10151c6c6cb 100644 --- a/src/osd/sdl/output.c +++ b/src/osd/sdl/output.c @@ -86,7 +86,7 @@ bool sdl_osd_interface::output_init() output = fdopen(fildes, "w"); osd_printf_verbose("output: opened output notifier file %s\n", SDLMAME_OUTPUT); - fprintf(output, "MAME " PID_FMT " START %s\n", osd_getpid(), machine().system().name); + fprintf(output, "MAME " PID_FMT " START %s\n", osd_getpid(), this->machine().system().name); fflush(output); } diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak index c389dbb0e7a..07191629cad 100644 --- a/src/osd/sdl/sdl.mak +++ b/src/osd/sdl/sdl.mak @@ -432,6 +432,7 @@ OSDOBJS = \ $(SDLOBJ)/window.o \ $(SDLOBJ)/output.o \ $(SDLOBJ)/watchdog.o \ + $(OSDOBJ)/modules/lib/osdobj_common.o \ ifdef NO_USE_MIDI OSDOBJS += $(OSDOBJ)/modules/midi/none.o diff --git a/src/osd/sdl/sdlmain.c b/src/osd/sdl/sdlmain.c index 3a29515b743..af30e736fa2 100644 --- a/src/osd/sdl/sdlmain.c +++ b/src/osd/sdl/sdlmain.c @@ -401,7 +401,7 @@ sdl_osd_interface::~sdl_osd_interface() void sdl_osd_interface::osd_exit() { - osd_interface::osd_exit(); + osd_common_t::osd_exit(); if (!SDLMAME_INIT_IN_WORKER_THREAD) { @@ -585,7 +585,7 @@ void sdl_osd_interface::debugger_register() void sdl_osd_interface::init(running_machine &machine) { // call our parent - osd_interface::init(machine); + osd_common_t::init(machine); sdl_options &options = downcast(machine.options()); const char *stemp; @@ -681,7 +681,7 @@ void sdl_osd_interface::init(running_machine &machine) exit(-1); } - osd_interface::init_subsystems(); + osd_common_t::init_subsystems(); if (options.oslog()) machine.add_logerror_callback(output_oslog); @@ -1439,27 +1439,4 @@ bool sdl_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitma #endif #endif -//------------------------------------------------- -// FIXME: Doesn't belong here but there's no better -// place currently. -//------------------------------------------------- -bool osd_interface::midi_init() -{ - // this should be done on the OS_level - return osd_midi_init(); -} - -//------------------------------------------------- -// list_midi_devices - list available midi devices -//------------------------------------------------- - -void osd_interface::list_midi_devices(void) -{ - osd_list_midi_devices(); -} - -void osd_interface::midi_exit() -{ - osd_midi_exit(); -} diff --git a/src/osd/windows/windows.mak b/src/osd/windows/windows.mak index d36bdf59506..3ce30b9d3ab 100644 --- a/src/osd/windows/windows.mak +++ b/src/osd/windows/windows.mak @@ -378,6 +378,7 @@ OSDOBJS = \ $(WINOBJ)/winmenu.o \ $(WINOBJ)/winmain.o \ $(OSDOBJ)/modules/midi/portmidi.o \ + $(OSDOBJ)/modules/lib/osdobj_common.o \ ifdef USE_SDL OSDOBJS += \ diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index ecfa89c6e51..534e88cd2f8 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -572,7 +572,7 @@ void windows_osd_interface::debugger_register() void windows_osd_interface::init(running_machine &machine) { // call our parent - osd_interface::init(machine); + osd_common_t::init(machine); const char *stemp; windows_options &options = downcast(machine.options()); @@ -619,7 +619,7 @@ void windows_osd_interface::init(running_machine &machine) } // initialize the subsystems - osd_interface::init_subsystems(); + osd_common_t::init_subsystems(); // notify listeners of screen configuration astring tempstring; @@ -680,7 +680,7 @@ void windows_osd_interface::osd_exit() // cleanup sockets win_cleanup_sockets(); - osd_interface::osd_exit(); + osd_common_t::osd_exit(); // take down the watchdog thread if it exists if (watchdog_thread != NULL) @@ -1824,28 +1824,3 @@ void sampling_profiler::thread_run() Sleep(1); } } - -//------------------------------------------------- -// FIXME: Doesn't belong here but there's no better -// place currently. -//------------------------------------------------- - -bool osd_interface::midi_init() -{ - // this should be done on the OS_level - return osd_midi_init(); -} - -//------------------------------------------------- -// list_midi_devices - list available midi devices -//------------------------------------------------- - -void osd_interface::list_midi_devices(void) -{ - osd_list_midi_devices(); -} - -void osd_interface::midi_exit() -{ - osd_midi_exit(); -} diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index 34748113fe9..b824cfd7c7f 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -8,6 +8,7 @@ #include "clifront.h" #include "osdepend.h" +#include "modules/lib/osdobj_common.h" //============================================================ @@ -234,7 +235,7 @@ private: // TYPE DEFINITIONS //============================================================ -class windows_osd_interface : public osd_interface +class windows_osd_interface : public osd_common_t { public: // construction/destruction -- cgit v1.2.3