From 69faaf3aeb0ed3f8a95743053a3467f0f5a747f5 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 8 May 2014 07:39:04 +0000 Subject: [PATCH] -Reorganized OSD, handling more sound output systems and debuggers, defaults left same as before [Miodrag Milanovic] -Created osd_options as base option class for non-system specific options --- .gitattributes | 51 +- src/emu/debug/debugcpu.c | 3 - src/emu/debugger.c | 4 - src/emu/emu.mak | 12 +- src/emu/emuopts.c | 6 +- src/emu/emuopts.h | 12 +- src/emu/machine.c | 2 +- src/emu/sound.c | 2 +- src/emu/video.c | 4 - src/lib/util/options.c | 39 + src/lib/util/options.h | 3 + src/osd/modules/debugger/debugint.c | 1456 +++++++++++++++++ src/osd/modules/debugger/debugint.h | 34 + src/osd/{sdl => modules/debugger}/debugosx.h | 15 + src/osd/{sdl => modules/debugger}/debugosx.m | 27 +- src/osd/{sdl => modules/debugger}/debugqt.c | 92 +- src/osd/modules/debugger/debugqt.h | 34 + .../{windows => modules/debugger}/debugwin.c | 37 +- src/osd/modules/debugger/debugwin.h | 32 + src/osd/modules/debugger/none.c | 36 + src/osd/modules/debugger/none.h | 33 + .../debugger/qt}/debugqtbreakpointswindow.c | 0 .../debugger/qt}/debugqtbreakpointswindow.h | 0 .../debugger/qt}/debugqtdasmwindow.c | 0 .../debugger/qt}/debugqtdasmwindow.h | 0 .../debugger/qt}/debugqtlogwindow.c | 0 .../debugger/qt}/debugqtlogwindow.h | 0 .../debugger/qt}/debugqtmainwindow.c | 8 + .../debugger/qt}/debugqtmainwindow.h | 4 +- .../debugger/qt}/debugqtmemorywindow.c | 0 .../debugger/qt}/debugqtmemorywindow.h | 0 .../debugger/qt}/debugqtview.c | 0 .../debugger/qt}/debugqtview.h | 0 .../debugger/qt}/debugqtwindow.c | 0 .../debugger/qt}/debugqtwindow.h | 0 .../sound.c => modules/sound/direct_sound.c} | 73 +- src/osd/modules/sound/direct_sound.h | 64 + src/osd/modules/sound/none.c | 23 + src/osd/modules/sound/none.h | 31 + .../sound.c => modules/sound/sdl_sound.c} | 52 +- src/osd/modules/sound/sdl_sound.h | 31 + src/osd/osdepend.c | 241 ++- src/osd/osdepend.h | 189 ++- src/osd/osdmini/minimain.c | 1 + src/osd/sdl/debugwin.c | 38 - src/osd/sdl/osdsdl.h | 63 +- src/osd/sdl/sdl.mak | 44 +- src/osd/sdl/sdlmain.c | 120 +- src/osd/windows/windows.mak | 71 +- src/osd/windows/winmain.c | 105 +- src/osd/windows/winmain.h | 68 +- 51 files changed, 2613 insertions(+), 547 deletions(-) create mode 100644 src/osd/modules/debugger/debugint.c create mode 100644 src/osd/modules/debugger/debugint.h rename src/osd/{sdl => modules/debugger}/debugosx.h (95%) rename src/osd/{sdl => modules/debugger}/debugosx.m (99%) rename src/osd/{sdl => modules/debugger}/debugqt.c (85%) create mode 100644 src/osd/modules/debugger/debugqt.h rename src/osd/{windows => modules/debugger}/debugwin.c (98%) create mode 100644 src/osd/modules/debugger/debugwin.h create mode 100644 src/osd/modules/debugger/none.c create mode 100644 src/osd/modules/debugger/none.h rename src/osd/{sdl => modules/debugger/qt}/debugqtbreakpointswindow.c (100%) rename src/osd/{sdl => modules/debugger/qt}/debugqtbreakpointswindow.h (100%) rename src/osd/{sdl => modules/debugger/qt}/debugqtdasmwindow.c (100%) rename src/osd/{sdl => modules/debugger/qt}/debugqtdasmwindow.h (100%) rename src/osd/{sdl => modules/debugger/qt}/debugqtlogwindow.c (100%) rename src/osd/{sdl => modules/debugger/qt}/debugqtlogwindow.h (100%) rename src/osd/{sdl => modules/debugger/qt}/debugqtmainwindow.c (99%) rename src/osd/{sdl => modules/debugger/qt}/debugqtmainwindow.h (98%) rename src/osd/{sdl => modules/debugger/qt}/debugqtmemorywindow.c (100%) rename src/osd/{sdl => modules/debugger/qt}/debugqtmemorywindow.h (100%) rename src/osd/{sdl => modules/debugger/qt}/debugqtview.c (100%) rename src/osd/{sdl => modules/debugger/qt}/debugqtview.h (100%) rename src/osd/{sdl => modules/debugger/qt}/debugqtwindow.c (100%) rename src/osd/{sdl => modules/debugger/qt}/debugqtwindow.h (100%) rename src/osd/{windows/sound.c => modules/sound/direct_sound.c} (84%) create mode 100644 src/osd/modules/sound/direct_sound.h create mode 100644 src/osd/modules/sound/none.c create mode 100644 src/osd/modules/sound/none.h rename src/osd/{sdl/sound.c => modules/sound/sdl_sound.c} (92%) create mode 100644 src/osd/modules/sound/sdl_sound.h delete mode 100644 src/osd/sdl/debugwin.c diff --git a/.gitattributes b/.gitattributes index 24b7e160233..f1be499f36c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8968,6 +8968,36 @@ src/mess/video/zx8301.h svneol=native#text/plain src/osd/eigccppc.h svneol=native#text/plain src/osd/eigccx86.h svneol=native#text/plain src/osd/eminline.h svneol=native#text/plain +src/osd/modules/debugger/debugint.c svneol=native#text/plain +src/osd/modules/debugger/debugint.h svneol=native#text/plain +src/osd/modules/debugger/debugosx.h svneol=native#text/plain +src/osd/modules/debugger/debugosx.m svneol=native#text/plain +src/osd/modules/debugger/debugqt.c svneol=native#text/plain +src/osd/modules/debugger/debugqt.h svneol=native#text/plain +src/osd/modules/debugger/debugwin.c svneol=native#text/plain +src/osd/modules/debugger/debugwin.h svneol=native#text/plain +src/osd/modules/debugger/none.c svneol=native#text/plain +src/osd/modules/debugger/none.h svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtbreakpointswindow.c svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtbreakpointswindow.h svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtdasmwindow.c svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtdasmwindow.h svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtlogwindow.c svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtlogwindow.h svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtmainwindow.c svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtmainwindow.h svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtmemorywindow.c svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtmemorywindow.h svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtview.c svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtview.h svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtwindow.c svneol=native#text/plain +src/osd/modules/debugger/qt/debugqtwindow.h svneol=native#text/plain +src/osd/modules/sound/direct_sound.c svneol=native#text/plain +src/osd/modules/sound/direct_sound.h svneol=native#text/plain +src/osd/modules/sound/none.c svneol=native#text/plain +src/osd/modules/sound/none.h svneol=native#text/plain +src/osd/modules/sound/sdl_sound.c svneol=native#text/plain +src/osd/modules/sound/sdl_sound.h svneol=native#text/plain src/osd/osdcomm.h svneol=native#text/plain src/osd/osdcore.c svneol=native#text/plain src/osd/osdcore.h svneol=native#text/plain @@ -8990,24 +9020,6 @@ src/osd/sdl/SDLMain_tmpl.h svneol=native#text/plain src/osd/sdl/SDLMain_tmpl.m svneol=native#text/plain src/osd/sdl/blit13.h svneol=native#text/plain src/osd/sdl/build.mak svneol=native#text/plain -src/osd/sdl/debugosx.h svneol=native#text/plain -src/osd/sdl/debugosx.m svneol=native#text/plain -src/osd/sdl/debugqt.c svneol=native#text/plain -src/osd/sdl/debugqtbreakpointswindow.c svneol=native#text/plain -src/osd/sdl/debugqtbreakpointswindow.h svneol=native#text/plain -src/osd/sdl/debugqtdasmwindow.c svneol=native#text/plain -src/osd/sdl/debugqtdasmwindow.h svneol=native#text/plain -src/osd/sdl/debugqtlogwindow.c svneol=native#text/plain -src/osd/sdl/debugqtlogwindow.h svneol=native#text/plain -src/osd/sdl/debugqtmainwindow.c svneol=native#text/plain -src/osd/sdl/debugqtmainwindow.h svneol=native#text/plain -src/osd/sdl/debugqtmemorywindow.c svneol=native#text/plain -src/osd/sdl/debugqtmemorywindow.h svneol=native#text/plain -src/osd/sdl/debugqtview.c svneol=native#text/plain -src/osd/sdl/debugqtview.h svneol=native#text/plain -src/osd/sdl/debugqtwindow.c svneol=native#text/plain -src/osd/sdl/debugqtwindow.h svneol=native#text/plain -src/osd/sdl/debugwin.c svneol=native#text/plain src/osd/sdl/draw13.c svneol=native#text/plain src/osd/sdl/drawogl.c svneol=native#text/plain src/osd/sdl/drawsdl.c svneol=native#text/plain @@ -9092,7 +9104,6 @@ src/osd/sdl/shader/glsl_plain_rgb32_dir.fsh svneol=native#text/plain src/osd/sdl/shader/glsl_plain_rgb32_dir.fsh.c svneol=native#text/plain src/osd/sdl/shader/glsl_plain_rgb32_lut.fsh svneol=native#text/plain src/osd/sdl/shader/glsl_plain_rgb32_lut.fsh.c svneol=native#text/plain -src/osd/sdl/sound.c svneol=native#text/plain src/osd/sdl/strconv.c svneol=native#text/plain src/osd/sdl/strconv.h svneol=native#text/plain src/osd/sdl/taputil.sh svneol=LF#text/plain eol=lf @@ -9108,7 +9119,6 @@ src/osd/windows/d3dcomm.h svneol=native#text/plain src/osd/windows/d3dhlsl.c svneol=native#text/plain src/osd/windows/d3dhlsl.h svneol=native#text/plain src/osd/windows/d3dintf.h svneol=native#text/plain -src/osd/windows/debugwin.c svneol=native#text/plain src/osd/windows/drawd3d.c svneol=native#text/plain src/osd/windows/drawd3d.h svneol=native#text/plain src/osd/windows/drawdd.c svneol=native#text/plain @@ -9129,7 +9139,6 @@ src/osd/windows/netdev_pcap.h svneol=native#text/plain src/osd/windows/osinline.h svneol=native#text/plain src/osd/windows/output.c svneol=native#text/plain src/osd/windows/output.h svneol=native#text/plain -src/osd/windows/sound.c svneol=native#text/plain src/osd/windows/strconv.c svneol=native#text/plain src/osd/windows/strconv.h svneol=native#text/plain src/osd/windows/vconv.c svneol=native#text/plain diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index 9ba61431f5f..559951371d7 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -17,7 +17,6 @@ #include "express.h" #include "debugvw.h" #include "debugger.h" -#include "debugint/debugint.h" #include "uiinput.h" #include "xmlfile.h" #include @@ -1936,8 +1935,6 @@ void device_debug::instruction_hook(offs_t curpc) global->memory_modified = false; if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) machine.osd().wait_for_debugger(m_device, firststop); - else if (machine.debug_flags & DEBUG_FLAG_ENABLED) - debugint_wait_for_debugger(m_device, firststop); firststop = false; // if something modified memory, update the screen diff --git a/src/emu/debugger.c b/src/emu/debugger.c index 4810fcba23b..07656f6178e 100644 --- a/src/emu/debugger.c +++ b/src/emu/debugger.c @@ -17,7 +17,6 @@ #include "debug/debugcon.h" #include "debug/express.h" #include "debug/debugvw.h" -#include "debugint/debugint.h" #include @@ -72,9 +71,6 @@ void debugger_init(running_machine &machine) debug_command_init(machine); debug_console_init(machine); - /* always initialize the internal render debugger */ - debugint_init(machine); - /* allocate a new entry for our global list */ machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debugger_exit), &machine)); entry = global_alloc(machine_entry); diff --git a/src/emu/emu.mak b/src/emu/emu.mak index 32aa695a3bd..3444b0d0877 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -25,7 +25,6 @@ OBJDIRS += \ $(EMUOBJ)/cpu \ $(EMUOBJ)/sound \ $(EMUOBJ)/debug \ - $(EMUOBJ)/debugint \ $(EMUOBJ)/audio \ $(EMUOBJ)/bus \ $(EMUOBJ)/drivers \ @@ -39,7 +38,10 @@ OSDSRC = $(SRC)/osd OSDOBJ = $(OBJ)/osd OBJDIRS += \ - $(OSDOBJ) + $(OSDOBJ) \ + $(OSDOBJ)/modules \ + $(OSDOBJ)/modules/sound \ + $(OSDOBJ)/modules/debugger \ #------------------------------------------------- @@ -141,12 +143,14 @@ EMUOBJS = \ $(EMUOBJ)/debug/dvtext.o \ $(EMUOBJ)/debug/express.o \ $(EMUOBJ)/debug/textbuf.o \ - $(EMUOBJ)/debugint/debugint.o \ $(EMUOBJ)/profiler.o \ $(EMUOBJ)/webengine.o \ $(OSDOBJ)/osdcore.o \ $(OSDOBJ)/osdepend.o \ - $(OSDOBJ)/osdnet.o + $(OSDOBJ)/osdnet.o \ + $(OSDOBJ)/modules/sound/none.o \ + $(OSDOBJ)/modules/debugger/none.o \ + $(OSDOBJ)/modules/debugger/debugint.o \ EMUSOUNDOBJS = \ $(EMUOBJ)/sound/filter.o \ diff --git a/src/emu/emuopts.c b/src/emu/emuopts.c index f76cb32d5f8..6d59d276928 100644 --- a/src/emu/emuopts.c +++ b/src/emu/emuopts.c @@ -113,7 +113,6 @@ const options_entry emu_options::s_option_entries[] = // sound options { NULL, NULL, OPTION_HEADER, "CORE SOUND OPTIONS" }, - { OPTION_SOUND, "1", OPTION_BOOLEAN, "enable sound output" }, { OPTION_SAMPLERATE ";sr(1000-1000000)", "48000", OPTION_INTEGER, "set sound output sample rate" }, { OPTION_SAMPLES, "1", OPTION_BOOLEAN, "enable the use of external samples if available" }, { OPTION_VOLUME ";vol", "0", OPTION_INTEGER, "sound volume in decibels (-32 min, 0 max)" }, @@ -150,12 +149,8 @@ const options_entry emu_options::s_option_entries[] = // debugging options { NULL, NULL, OPTION_HEADER, "CORE DEBUGGING OPTIONS" }, - { OPTION_LOG, "0", OPTION_BOOLEAN, "generate an error.log file" }, - { OPTION_VERBOSE ";v", "0", OPTION_BOOLEAN, "display additional diagnostic information" }, { OPTION_UPDATEINPAUSE, "0", OPTION_BOOLEAN, "keep calling video updates while in pause" }, - { OPTION_DEBUG ";d", "0", OPTION_BOOLEAN, "enable/disable debugger" }, { OPTION_DEBUGSCRIPT, NULL, OPTION_STRING, "script for debugger" }, - { OPTION_DEBUG_INTERNAL ";di", "0", OPTION_BOOLEAN, "use the internal debugger for debugging" }, // misc options { NULL, NULL, OPTION_HEADER, "CORE MISC OPTIONS" }, @@ -190,6 +185,7 @@ const options_entry emu_options::s_option_entries[] = emu_options::emu_options() { add_entries(s_option_entries); + add_osd_options(); } diff --git a/src/emu/emuopts.h b/src/emu/emuopts.h index 81eaa0095f0..4b4f05185d2 100644 --- a/src/emu/emuopts.h +++ b/src/emu/emuopts.h @@ -154,11 +154,7 @@ enum #define OPTION_MOUSE_DEVICE "mouse_device" // core debugging options -#define OPTION_LOG "log" -#define OPTION_VERBOSE "verbose" #define OPTION_UPDATEINPAUSE "update_in_pause" -#define OPTION_DEBUG "debug" -#define OPTION_DEBUG_INTERNAL "debug_internal" #define OPTION_DEBUGSCRIPT "debugscript" // core misc options @@ -189,7 +185,7 @@ enum struct game_driver; -class emu_options : public core_options +class emu_options : public osd_options { static const UINT32 OPTION_FLAG_DEVICE = 0x80000000; @@ -285,7 +281,7 @@ public: float flicker() const { return float_value(OPTION_FLICKER); } // core sound options - bool sound() const { return bool_value(OPTION_SOUND); } + const char *sound() const { return value(OPTION_SOUND); } int sample_rate() const { return int_value(OPTION_SAMPLERATE); } bool samples() const { return bool_value(OPTION_SAMPLES); } int volume() const { return int_value(OPTION_VOLUME); } @@ -317,10 +313,6 @@ public: int coin_impulse() const { return int_value(OPTION_COIN_IMPULSE); } // core debugging options - bool verbose() const { return bool_value(OPTION_VERBOSE); } - bool log() const { return bool_value(OPTION_LOG); } - bool debug() const { return bool_value(OPTION_DEBUG); } - bool debug_internal() const { return bool_value(OPTION_DEBUG_INTERNAL); } const char *debug_script() const { return value(OPTION_DEBUGSCRIPT); } bool update_in_pause() const { return bool_value(OPTION_UPDATEINPAUSE); } diff --git a/src/emu/machine.c b/src/emu/machine.c index 1a16abded52..0397ccace13 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -159,7 +159,7 @@ running_machine::running_machine(const machine_config &_config, osd_interface &o // fetch core options if (options().debug()) - debug_flags = (DEBUG_FLAG_ENABLED | DEBUG_FLAG_CALL_HOOK) | (options().debug_internal() ? 0 : DEBUG_FLAG_OSD_ENABLED); + debug_flags = (DEBUG_FLAG_ENABLED | DEBUG_FLAG_CALL_HOOK) | (DEBUG_FLAG_OSD_ENABLED); } diff --git a/src/emu/sound.c b/src/emu/sound.c index 7906a6e3464..1ea9b1b4a21 100644 --- a/src/emu/sound.c +++ b/src/emu/sound.c @@ -796,7 +796,7 @@ sound_manager::sound_manager(running_machine &machine) m_rightmix(machine.sample_rate()), m_muted(0), m_attenuation(0), - m_nosound_mode(!machine.options().sound()), + m_nosound_mode(machine.osd().no_sound()), m_wavfile(NULL), m_update_attoseconds(STREAMS_UPDATE_ATTOTIME.attoseconds), m_last_update(attotime::zero) diff --git a/src/emu/video.c b/src/emu/video.c index 99453ab0d5a..eabdac65732 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -12,7 +12,6 @@ #include "emuopts.h" #include "png.h" #include "debugger.h" -#include "debugint/debugint.h" #include "ui/ui.h" #include "aviio.h" #include "crsshair.h" @@ -214,9 +213,6 @@ void video_manager::frame_update(bool debug) // draw the user interface machine().ui().update_and_render(&machine().render().ui_container()); - // update the internal render debugger - debugint_update_during_game(machine()); - // if we're throttling, synchronize before rendering attotime current_time = machine().time(); if (!debug && !skipped_it && effective_throttle()) diff --git a/src/lib/util/options.c b/src/lib/util/options.c index 7aa08ad0500..96315678471 100644 --- a/src/lib/util/options.c +++ b/src/lib/util/options.c @@ -124,6 +124,17 @@ void core_options::entry::set_default_value(const char *defvalue) } +//------------------------------------------------- +// set_description - set the description of +// an option +//------------------------------------------------- + +void core_options::entry::set_description(const char *description) +{ + m_description = description; +} + + void core_options::entry::set_flag(UINT32 mask, UINT32 flag) { m_flags = ( m_flags & mask ) | flag; @@ -298,6 +309,23 @@ void core_options::set_default_value(const char *name, const char *defvalue) } +//------------------------------------------------- +// set_description - change the description +// of an option +//------------------------------------------------- + +void core_options::set_description(const char *name, const char *description) +{ + // find the entry and bail if we can't + entry *curentry = m_entrymap.find(name); + if (curentry == NULL) + return; + + // update the data and default data + curentry->set_description(description); +} + + //------------------------------------------------- // parse_command_line - parse a series of // command line arguments @@ -542,6 +570,17 @@ const char *core_options::value(const char *name) const } +//------------------------------------------------- +// description - return description of option +//------------------------------------------------- + +const char *core_options::description(const char *name) const +{ + entry *curentry = m_entrymap.find(name); + return (curentry != NULL) ? curentry->description() : ""; +} + + //------------------------------------------------- // priority - return the priority of option //------------------------------------------------- diff --git a/src/lib/util/options.h b/src/lib/util/options.h index 573822b73b6..97e062b028b 100644 --- a/src/lib/util/options.h +++ b/src/lib/util/options.h @@ -94,6 +94,7 @@ public: // setters void set_value(const char *newvalue, int priority); void set_default_value(const char *defvalue); + void set_description(const char *description); void set_flag(UINT32 mask, UINT32 flag); void revert(int priority); @@ -134,6 +135,7 @@ public: void add_entry(const options_entry &data, bool override_existing = false) { add_entry(data.name, data.description, data.flags, data.defvalue, override_existing); } void add_entries(const options_entry *entrylist, bool override_existing = false); void set_default_value(const char *name, const char *defvalue); + void set_description(const char *name, const char *description); void remove_entry(entry &delentry); // parsing/input @@ -149,6 +151,7 @@ public: // reading const char *value(const char *option) const; + const char *description(const char *option) const; int priority(const char *option) const; bool bool_value(const char *name) const { return (atoi(value(name)) != 0); } int int_value(const char *name) const { return atoi(value(name)); } diff --git a/src/osd/modules/debugger/debugint.c b/src/osd/modules/debugger/debugint.c new file mode 100644 index 00000000000..b8aa611b510 --- /dev/null +++ b/src/osd/modules/debugger/debugint.c @@ -0,0 +1,1456 @@ +/********************************************************************* + + debugint.c + + Internal debugger frontend using render interface. + + Copyright Nicola Salmoria and the MAME Team. + Visit http://mamedev.org for licensing and usage restrictions. + +*********************************************************************/ + +#include "emu.h" +#include "debugint.h" +#include "ui/ui.h" +#include "rendfont.h" +#include "uiinput.h" + +#include "debug/debugvw.h" +#include "debug/dvdisasm.h" +#include "debug/dvmemory.h" +#include "debug/dvstate.h" +#include "debug/debugcon.h" +#include "debug/debugcpu.h" + + +/*************************************************************************** + CONSTANTS +***************************************************************************/ + +const osd_debugger_type OSD_DEBUGGER_INTERNAL = &osd_debugger_creator; + +#define BORDER_YTHICKNESS 1 +#define BORDER_XTHICKNESS 1 +#define HSB_HEIGHT 20 +#define VSB_WIDTH 20 +#define TITLE_HEIGHT 20 + +enum +{ + RECT_DVIEW, + RECT_DVIEW_CLIENT, + RECT_DVIEW_TITLE, + RECT_DVIEW_HSB, + RECT_DVIEW_VSB, + RECT_DVIEW_SIZE, +}; + +enum +{ + VIEW_STATE_BUTTON = 0x01, + VIEW_STATE_MOVING = 0x02, + VIEW_STATE_SIZING = 0x04, + VIEW_STATE_NEEDS_UPDATE = 0x08, + VIEW_STATE_FOLLOW_CPU = 0x10, +}; + +/*************************************************************************** + MACROS +***************************************************************************/ + +//#define NX(_dv, _x) ((float) (_x)/(float)(_dv)->bounds.width()) +//#define NY(_dv, _y) ((float) (_y)/(float)(_dv)->bounds.height()) +#define NX(_dv, _x) ((float) (_x)/(float) (dv)->rt_width) +#define NY(_dv, _y) ((float) (_y)/(float) (dv)->rt_height) + + +#define LIST_ADD_FRONT(_list, _elem, _type) \ + do { \ + (_elem)->next = _list; \ + _list = _elem; \ + } while (0) + +#define LIST_GET_PREVIOUS(_list, _elem, _prev) \ + do { \ + _prev = NULL; \ + if (_list != _elem) \ + for (_prev = _list; _prev != NULL; _prev = _prev->next) \ + if ((_prev)->next == _elem) \ + break; \ + } while (0) + +#define LIST_GET_LAST(_list, _last) \ + do { \ + for (_last = _list; _last != NULL; _last = _last->next) \ + if ((_last)->next == NULL) \ + break; \ + } while (0) + +#define LIST_REMOVE(_list, _elem, _type) \ + do { \ + _type *_hlp; \ + LIST_GET_PREVIOUS(_list, _elem, _hlp); \ + if (_hlp != NULL) \ + (_hlp)->next = (_elem)->next; \ + else \ + _list = (_elem)->next; \ + } while (0) + +#define LIST_ADD_BACK(_list, _elem, _type) \ + do { \ + _type *_hlp; \ + LIST_GET_LAST(_list, _hlp); \ + if (_hlp != NULL) \ + (_hlp)->next = _elem; \ + else \ + _list = _elem; \ + } while (0) + +/*************************************************************************** + TYPE DEFINITIONS +***************************************************************************/ + +struct adjustment +{ + int visible; + int lower; + int upper; + int value; + int step_increment; + int page_increment; + int page_size; +}; + +class DView; + +class DView_edit +{ + DISABLE_COPYING(DView_edit); + +public: + DView_edit() + { } + ~DView_edit() + { } + int active; + render_container * container; + astring str; +}; + +/*************************************************************************** + FUNCTION PROTOTYPES +***************************************************************************/ + +static void dview_update(debug_view &dw, void *osdprivate); +static int map_point(DView *dv, INT32 target_x, INT32 target_y, INT32 *mapped_x, INT32 *mapped_y); + +class DView +{ + DISABLE_COPYING(DView); + +public: + DView(render_target *target, running_machine &machine, debug_view_type type, int flags) + : next(NULL), + type(0), + state(0), + ofs_x(0), + ofs_y(0) + { + this->target = target; + //dv->container = render_target_get_component_container(target, name, &pos); + this->container = target->debug_alloc(); + this->view = machine.debug_view().alloc_view(type, dview_update, this); + this->type = type; + this->m_machine = &machine; + this->state = flags | VIEW_STATE_NEEDS_UPDATE; + + // initial size + this->bounds.set(0, 300, 0, 300); + + /* specials */ + switch (type) + { + case DVT_DISASSEMBLY: + /* set up disasm view */ + downcast(this->view)->set_expression("curpc"); + //debug_view_ property_UINT32(dv->view, DVP_DASM_TRACK_LIVE, 1); + break; + default: + break; + } + } + ~DView() + { + this->target->debug_free(*this->container); + machine().debug_view().free_view(*this->view); + } + + running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } + + DView * next; + + int type; + debug_view * view; + render_container * container; + render_target * target; + running_machine * m_machine; + int state; + // drawing + rectangle bounds; + int ofs_x; + int ofs_y; + astring title; + int last_x; + int last_y; + // Scrollbars + adjustment hsb; + adjustment vsb; + // render target tracking + INT32 rt_width; + INT32 rt_height; + //optional + DView_edit editor; +}; + + +/*************************************************************************** + INLINE FUNCTIONS +***************************************************************************/ + +INLINE int dview_is_state(DView *dv, int state) +{ + return ((dv->state & state) ? TRUE : FALSE); +} + +INLINE int dview_is_state_all(DView *dv, int state) +{ + return ((dv->state & state) == state ? TRUE : FALSE); +} + +INLINE void dview_set_state(DView *dv, int state, int onoff) +{ + if (onoff) + dv->state |= state; + else + dv->state &= ~state; +} + +/*************************************************************************** + LOCAL VARIABLES +***************************************************************************/ + +static render_font * debug_font; +static int debug_font_width; +static int debug_font_height; +static float debug_font_aspect; +static DView * list; +static DView * focus_view; + +static ui_menu * menu; +static DView_edit * cur_editor; + +static void set_focus_view(DView *dv) +{ + if (focus_view != NULL) + dview_set_state(focus_view, VIEW_STATE_NEEDS_UPDATE, TRUE); + + if (dv != NULL) + dview_set_state(dv, VIEW_STATE_NEEDS_UPDATE, TRUE); + + if (focus_view != dv) + { + focus_view = dv; + LIST_REMOVE(list, dv, DView); + LIST_ADD_FRONT(list, dv, DView); + dv->target->debug_top(*dv->container); + } +} + +static DView *dview_alloc(render_target *target, running_machine &machine, debug_view_type type, int flags) +{ + DView *dv; + + dv = auto_alloc(machine, DView(target, machine, type, flags)); + + /* add to list */ + + LIST_ADD_BACK(list, dv, DView); + + return dv; +} + +static void dview_free(DView *dv) +{ + LIST_REMOVE(list, dv, DView); + auto_free(dv->machine(), dv); +} + +static void dview_get_rect(DView *dv, int type, rectangle &rect) +{ + rect = dv->bounds; + switch (type) + { + case RECT_DVIEW: + break; + case RECT_DVIEW_CLIENT: + rect.min_x += BORDER_XTHICKNESS; + rect.max_x -= (BORDER_XTHICKNESS + dv->vsb.visible * VSB_WIDTH); + rect.min_y += 2 * BORDER_YTHICKNESS + TITLE_HEIGHT; + rect.max_y -= (BORDER_YTHICKNESS + dv->hsb.visible * HSB_HEIGHT); + break; + case RECT_DVIEW_HSB: + rect.min_x += 0; + rect.max_x -= /* dv->vsb.visible * */ VSB_WIDTH; + rect.min_y = dv->bounds.max_y - HSB_HEIGHT; + rect.max_y -= 0; + break; + case RECT_DVIEW_VSB: + rect.min_x = dv->bounds.max_x - VSB_WIDTH; + rect.max_x -= 0; + rect.min_y += TITLE_HEIGHT; + rect.max_y -= /* dv->hsb.visible * */ HSB_HEIGHT; + break; + case RECT_DVIEW_SIZE: + rect.min_x = dv->bounds.max_x - VSB_WIDTH; + rect.max_x -= 0; + rect.min_y = dv->bounds.max_y - HSB_HEIGHT; + rect.max_y -= 0; + break; + case RECT_DVIEW_TITLE: + rect.min_x += 0; + rect.max_x -= 0; + rect.min_y += 0; + rect.max_y = rect.min_y + TITLE_HEIGHT - 1; + break; + default: + assert_always(FALSE, "unknown rectangle type"); + } +} + + +static void dview_clear(DView *dv) +{ + dv->container->empty(); +} + +static void dview_draw_outlined_box(DView *dv, int rtype, int x, int y, int w, int h, rgb_t bg) +{ + rectangle r; + + dview_get_rect(dv, rtype, r); + dv->container->manager().machine().ui().draw_outlined_box(dv->container, NX(dv, x + r.min_x), NY(dv, y + r.min_y), + NX(dv, x + r.min_x + w), NY(dv, y + r.min_y + h), bg); +} + +static void dview_draw_box(DView *dv, int rtype, int x, int y, int w, int h, rgb_t col) +{ + rectangle r; + + dview_get_rect(dv, rtype, r); + dv->container->add_rect(NX(dv, x + r.min_x), NY(dv, y + r.min_y), + NX(dv, x + r.min_x + w), NY(dv, y + r.min_y + h), col, + PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); +} + +static void dview_draw_char(DView *dv, int rtype, int x, int y, int h, rgb_t col, UINT16 ch) +{ + rectangle r; + + dview_get_rect(dv, rtype, r); + dv->container->add_char( + NX(dv, x + r.min_x), + NY(dv, y + r.min_y), + NY(dv, h), + debug_font_aspect, + //(float) dv->bounds.height() / (float) dv->bounds->width(), //render_get_ui_aspect(), + col, + *debug_font, + ch); +} + +static int dview_xy_in_rect(DView *dv, int type, int x, int y) +{ + rectangle r; + + dview_get_rect(dv, type, r); + if (r.contains(x, y)) + return TRUE; + return FALSE; +} + +static void dview_draw_hsb(DView *dv) +{ + int vt; + int ts; + //int sz = SLIDER_SIZE; + int sz; + rectangle r; + adjustment *sb = &dv->hsb; + + dview_get_rect(dv, RECT_DVIEW_HSB, r); + + dview_draw_outlined_box(dv, RECT_DVIEW_HSB, 0, 0, VSB_WIDTH,HSB_HEIGHT, rgb_t(0xff, 0xff, 0x00, 0x00)); + dview_draw_outlined_box(dv, RECT_DVIEW_HSB, r.width() - VSB_WIDTH, 0, VSB_WIDTH, HSB_HEIGHT, rgb_t(0xff, 0xff, 0x00, 0x00)); + + ts = (r.width()) - 2 * VSB_WIDTH; + + sz = (ts * (sb->page_size)) / (sb->upper - sb->lower); + ts = ts - sz; + + vt = (ts * (sb->value - sb->lower)) / (sb->upper - sb->lower - sb->page_size) + sz / 2 + r.min_x + VSB_WIDTH; + + dview_draw_outlined_box(dv, RECT_DVIEW_HSB, vt - sz / 2, 0, sz, HSB_HEIGHT, rgb_t(0xff, 0xff, 0x00, 0x00)); +} + +static void dview_draw_vsb(DView *dv) +{ + int vt; + int ts; + //int sz = SLIDER_SIZE; + int sz; + rectangle r; + adjustment *sb = &dv->vsb; + + dview_get_rect(dv, RECT_DVIEW_VSB, r); + + dview_draw_outlined_box(dv, RECT_DVIEW_VSB, 0, r.height() - HSB_HEIGHT, VSB_WIDTH, HSB_HEIGHT, rgb_t(0xff, 0xff, 0x00, 0x00)); + dview_draw_outlined_box(dv, RECT_DVIEW_VSB, 0, 0, VSB_WIDTH, HSB_HEIGHT, rgb_t(0xff, 0xff, 0x00, 0x00)); + + ts = r.height() - 2 * HSB_HEIGHT; + + sz = (ts * (sb->page_size)) / (sb->upper - sb->lower); + ts = ts - sz; + + vt = (ts * (sb->value - sb->lower)) / (sb->upper - sb->lower - sb->page_size) + sz / 2 + HSB_HEIGHT; + + dview_draw_outlined_box(dv, RECT_DVIEW_VSB, 0, vt - sz / 2, VSB_WIDTH, sz, rgb_t(0xff, 0xff, 0x00, 0x00)); +} + +static void dview_draw_size(DView *dv) +{ + rectangle r; + + dview_get_rect(dv, RECT_DVIEW_SIZE, r); + + dview_draw_outlined_box(dv, RECT_DVIEW_SIZE, 0, 0, + r.width(),r.height(), rgb_t(0xff, 0xff, 0xff, 0x00)); +} + +static void dview_set_title(DView *dv, astring title) +{ + if (dv->title.cmp(title) != 0) + { + dv->title = title; + dview_set_state(dv, VIEW_STATE_NEEDS_UPDATE, TRUE); + } +} + +static void dview_draw_title(DView *dv) +{ + int i; + rgb_t col = rgb_t(0xff,0x00,0x00,0xff); + rectangle r; + + dview_get_rect(dv, RECT_DVIEW_TITLE, r); + + if (dv == focus_view) + col = rgb_t(0xff,0x00,0x7f,0x00); + + dview_draw_outlined_box(dv, RECT_DVIEW_TITLE, 0, 0, dv->bounds.width(), TITLE_HEIGHT, col); + + if (!dv->title) + return; + + for (i=0; ititle); i++) + { + dview_draw_char(dv, RECT_DVIEW_TITLE, i * debug_font_width + BORDER_XTHICKNESS, + BORDER_YTHICKNESS, debug_font_height, //r.max_y - 2 * BORDER_YTHICKNESS, + rgb_t(0xff,0xff,0xff,0xff), (UINT16) dv->title[i] ); + } +} + +static int dview_on_mouse(DView *dv, int mx, int my, bool button) +{ + int clicked = (button && !dview_is_state(dv, VIEW_STATE_BUTTON)); + int handled = TRUE; + int x,y; + + if (button && dview_is_state_all(dv, VIEW_STATE_BUTTON | VIEW_STATE_MOVING)) + { + int dx = mx - dv->last_x; + int dy = my - dv->last_y; + + dv->ofs_x += dx; + dv->ofs_y += dy; + dv->last_x = mx; + dv->last_y = my; + dview_set_state(dv, VIEW_STATE_NEEDS_UPDATE, TRUE); + return TRUE; + } + else if (button && dview_is_state_all(dv, VIEW_STATE_BUTTON | VIEW_STATE_SIZING)) + { + int dx = mx - dv->last_x; + int dy = my - dv->last_y; + + dv->bounds.max_x += dx; + dv->bounds.max_y += dy; + dv->last_x = mx; + dv->last_y = my; + dview_set_state(dv, VIEW_STATE_NEEDS_UPDATE, TRUE); + return TRUE; + } + else + dview_set_state(dv, VIEW_STATE_MOVING | VIEW_STATE_SIZING, FALSE); + + if (!map_point(dv, mx, my, &x, &y)) + return FALSE; + + if (dview_xy_in_rect(dv, RECT_DVIEW_TITLE, x, y)) + { + /* on title, do nothing */ + if (clicked) { + dv->last_x = mx; + dv->last_y = my; + set_focus_view(dv); + dview_set_state(dv, VIEW_STATE_MOVING, TRUE); + } + } + else if (dview_xy_in_rect(dv, RECT_DVIEW_HSB, x, y)) + { + /* on horizontal scrollbar */ + debug_view_xy pos; + adjustment *sb = &dv->hsb; + + if (clicked) + { + rectangle r; + int xt; + + dview_get_rect(dv, RECT_DVIEW_HSB, r); + x -= r.min_x; + + xt = (x - VSB_WIDTH) * (sb->upper - sb->lower) / (r.width() - 2 * dv->vsb.visible * VSB_WIDTH) + sb->lower; + if (x < VSB_WIDTH) + sb->value -= sb->step_increment; + else if (x > r.width() - VSB_WIDTH) + sb->value += sb->step_increment; + else if (xt < sb->value) + sb->value -= sb->page_increment; + else if (xt > sb->value) + sb->value += sb->page_increment; + + if (sb->value < sb->lower) + sb->value = sb->lower; + if (sb->value > sb->upper) + sb->value = sb->upper; + } + + pos = dv->view->visible_position(); + + if (sb->value != pos.x) + { + pos.x = sb->value; + dv->view->set_visible_position(pos); + dview_set_state(dv, VIEW_STATE_NEEDS_UPDATE, TRUE); + } + } + else if (dview_xy_in_rect(dv, RECT_DVIEW_VSB, x, y) ) + { + /* on vertical scrollbar */ + debug_view_xy pos; + adjustment *sb = &dv->vsb; + + if (clicked) + { + rectangle r; + int yt; + + dview_get_rect(dv, RECT_DVIEW_VSB, r); + y -= r.min_y; + yt = (y - HSB_HEIGHT) * (sb->upper - sb->lower) / (r.height() - 2 * HSB_HEIGHT) + sb->lower; + + if (y < HSB_HEIGHT) + sb->value -= sb->step_increment; + else if (y > r.height() - HSB_HEIGHT) + sb->value += sb->step_increment; + else if (yt < sb->value) + sb->value -= sb->page_increment; + else if (yt > sb->value) + sb->value += sb->page_increment; + + if (sb->value < sb->lower) + sb->value = sb->lower; + if (sb->value > sb->upper) + sb->value = sb->upper; + } + + pos = dv->view->visible_position(); + + if (sb->value != pos.y) + { + pos.y = sb->value; + dv->view->set_visible_position(pos); + dview_set_state(dv, VIEW_STATE_NEEDS_UPDATE, TRUE); + } + } + else if (dview_xy_in_rect(dv, RECT_DVIEW_SIZE, x, y)) + { + /* on sizing area */ + if (clicked) + { + dv->last_x = mx; + dv->last_y = my; + set_focus_view(dv); + dview_set_state(dv, VIEW_STATE_SIZING, TRUE); + } + } + else if (dview_xy_in_rect(dv, RECT_DVIEW_CLIENT, x, y)) + { + y -= TITLE_HEIGHT; + if (dv->view->cursor_supported() && clicked && y >= 0) + { + debug_view_xy topleft = dv->view->visible_position(); + debug_view_xy newpos; + newpos.x = topleft.x + x / debug_font_width; + newpos.y = topleft.y + y / debug_font_height; + dv->view->set_cursor_position(newpos); + dv->view->set_cursor_visible(true); + } + if (clicked) + set_focus_view(dv); + } + else + { + handled = FALSE; + } + dview_set_state(dv, VIEW_STATE_BUTTON, button); + return handled; + +} + +INLINE void map_attr_to_fg_bg(unsigned char attr, rgb_t *fg, rgb_t *bg) +{ + *bg = rgb_t(0xff,0xff,0xff,0xff); + *fg = rgb_t(0xff,0x00,0x00,0x00); + + if(attr & DCA_ANCILLARY) + *bg = rgb_t(0xff,0xe0,0xe0,0xe0); + if(attr & DCA_SELECTED) { + *bg = rgb_t(0xff,0xff,0x80,0x80); + } + if(attr & DCA_CURRENT) { + *bg = rgb_t(0xff,0xff,0xff,0x00); + } + if(attr & DCA_CHANGED) { + *fg = rgb_t(0xff,0xff,0x00,0x00); + } + if(attr & DCA_INVALID) { + *fg = rgb_t(0xff,0x00,0x00,0xff); + } + if(attr & DCA_DISABLED) { + *fg = rgb_t(fg->a(), (fg->r() + bg->r()) >> 1, (fg->g() + bg->g()) >> 1, (fg->b() + bg->b()) >> 1); + } + if(attr & DCA_COMMENT) { + *fg = rgb_t(0xff,0x00,0x80,0x00); + } +} + +static void dview_draw(DView *dv) +{ + const debug_view_char *viewdata; + debug_view_xy vsize; + UINT32 i, j, xx, yy; + rgb_t bg_base, bg, fg; + rectangle r; + + vsize = dv->view->visible_size(); + + bg_base = rgb_t(0xff,0xff,0xff,0xff); + + /* always start clean */ + dview_clear(dv); + + dview_draw_title(dv); + + dview_get_rect(dv, RECT_DVIEW_CLIENT, r); + + dview_draw_outlined_box(dv, RECT_DVIEW_CLIENT, 0, 0, + r.width() /*- (dv->vs ? VSB_WIDTH : 0)*/, + r.height() /*- (dv->hsb.visible ? HSB_HEIGHT : 0)*/, bg_base); + + /* background first */ + viewdata = dv->view->viewdata(); + + yy = BORDER_YTHICKNESS; + for(j=0; jattrib, &fg, &bg); + + if (bg != bg_base) + dview_draw_box(dv, RECT_DVIEW_CLIENT, xx, yy, + debug_font_width, debug_font_height, bg); + xx += debug_font_width; + viewdata++; + } + yy += debug_font_height; + } + + /* now the text */ + viewdata = dv->view->viewdata(); + + yy = BORDER_YTHICKNESS; + for(j=0; jbyte; + + if (v != ' ') + { + if(v < 128) { + s = v; + } else { + s = 0xc0 | (v>>6); + s |= (0x80 | (v & 0x3f)); + } + map_attr_to_fg_bg(viewdata->attrib, &fg, &bg); + + dview_draw_char(dv, RECT_DVIEW_CLIENT, xx, yy, debug_font_height, fg, s); + } + xx += debug_font_width; + viewdata++; + } + yy += debug_font_height; + } + + if(dv->hsb.visible) + dview_draw_hsb(dv); + if(dv->vsb.visible) + dview_draw_vsb(dv); + dview_draw_size(dv); +} + + +static void dview_size_allocate(DView *dv) +{ + debug_view_xy size, pos, col, vsize; + render_container::user_settings rcus; + rectangle r; + + dv->container->get_user_settings(rcus); + rcus.m_xoffset = (float) dv->ofs_x / (float) dv->rt_width; + rcus.m_yoffset = (float) dv->ofs_y / (float) dv->rt_height; + rcus.m_xscale = 1.0; //(float) dv->bounds.width() / (float) dv->rt_width; + rcus.m_yscale = 1.0; //(float) dv->bounds.height() / (float) dv->rt_height; + dv->container->set_user_settings(rcus); + //printf("%d %d %d %d\n", wpos.min_x, wpos.max_x, wpos.min_y, wpos.max_y); + + pos = dv->view->visible_position(); + size = dv->view->total_size(); + + dv->hsb.visible = 0; + dv->vsb.visible = 0; + dview_get_rect(dv, RECT_DVIEW_CLIENT, r); + + dv->hsb.visible = (size.x * debug_font_width > r.width() ? 1 : 0); + dv->vsb.visible = (size.y * debug_font_height > r.height() ? 1 : 0); + dview_get_rect(dv, RECT_DVIEW_CLIENT, r); + + dv->hsb.visible = (size.x * debug_font_width > r.width() ? 1 : 0); + dv->vsb.visible = (size.y * debug_font_height > r.height() ? 1 : 0); + dview_get_rect(dv, RECT_DVIEW_CLIENT, r); + + col.y = (r.height() - 2 * BORDER_YTHICKNESS /*+ debug_font_height - 1*/) / debug_font_height; + col.x = (r.width() - 2 * BORDER_XTHICKNESS /*+ debug_font_width - 1*/) / debug_font_width; + + vsize.y = size.y - pos.y; + vsize.x = size.x - pos.x; + if(vsize.y > col.y) + vsize.y = col.y; + else if(vsize.y < col.y) { + pos.y = size.y-col.y; + if(pos.y < 0) + pos.y = 0; + vsize.y = size.y-pos.y; + } + if(vsize.x > col.x) + vsize.x = col.x; + else if(vsize.x < col.x) { + pos.x = size.x-col.x; + if(pos.x < 0) + pos.x = 0; + vsize.x = size.x-pos.x; + } + + dv->view->set_visible_position(pos); + dv->view->set_visible_size(vsize); + + if(dv->hsb.visible) { + int span = (r.width() - 2 * BORDER_XTHICKNESS) / debug_font_width; + + if(pos.x + span > size.x) + pos.x = size.x - span; + if(pos.x < 0) + pos.x = 0; + dv->hsb.lower = 0; + dv->hsb.upper = size.x; + dv->hsb.value = pos.x; + dv->hsb.step_increment = 1; + dv->hsb.page_increment = span; + dv->hsb.page_size = span; + + dv->view->set_visible_position(pos); + } + + if(dv->vsb.visible) { + int span = (r.height() - 2 * BORDER_YTHICKNESS) / debug_font_height; + + if(pos.y + span > size.y) + pos.y = size.y - span; + if(pos.y < 0) + pos.y = 0; + dv->vsb.lower = 0; + dv->vsb.upper = size.y; + dv->vsb.value = pos.y; + dv->vsb.step_increment = 1; + dv->vsb.page_increment = span; + dv->vsb.page_size = span; + + dv->view->set_visible_position(pos); + } +} + +static void dview_update(debug_view &dw, void *osdprivate) +{ + DView *dv = (DView *) osdprivate; + + dview_set_state(dv, VIEW_STATE_NEEDS_UPDATE, TRUE); + +#if 0 + debug_view_xy size = dw.total_size(); + + if((dv->tr != size.y) || (dv->tc != size.x)) + gtk_widget_queue_resize(GTK_WIDGET(dv)); + else + gtk_widget_queue_draw(GTK_WIDGET(dv)); +#endif +} + +void debugger_internal::debugger_exit() +{ + for (DView *ndv = list; ndv != NULL; ) + { + DView *temp = ndv; + ndv = ndv->next; + dview_free(temp); + } + if (debug_font != NULL) + { + m_osd.machine().render().font_free(debug_font); + debug_font = NULL; + } + +} + +void debugger_internal::init_debugger() +{ + unicode_char ch; + int chw; + debug_font = m_osd.machine().render().font_alloc("ui.bdf"); //ui_get_font(machine); + debug_font_width = 0; + debug_font_height = 15; + + menu = NULL; + cur_editor = NULL; + list = NULL; + focus_view = NULL; + + debug_font_aspect = m_osd.machine().render().ui_aspect(); + + for (ch=0;ch<=127;ch++) + { + chw = debug_font->char_width(debug_font_height, debug_font_aspect, ch); + if (chw>debug_font_width) + debug_font_width = chw; + } + debug_font_width++; + /* FIXME: above does not really work */ + debug_font_width = 10; +} + +#if 0 +static void set_view_by_name(render_target *target, const char *name) +{ + int i = 0; + const char *s; + + for (i = 0; ; i++ ) + { + s = target->view_name(i); + if (s == NULL) + return; + //printf("%d %s\n", i, s); + if (strcmp(name, s) == 0) + { + target->set_view(i); + //printf("%d\n", target->view() ); + return; + } + } +} +#endif + +/*------------------------------------------------- + Menu Callbacks + -------------------------------------------------*/ + +static void process_string(DView *dv, const char *str) +{ + switch (dv->type) + { + case DVT_DISASSEMBLY: + downcast(dv->view)->set_expression(str); + break; + case DVT_CONSOLE: + if(!dv->editor.str[(int)0]) + debug_cpu_get_visible_cpu(dv->machine())->debug()->single_step(); + else + debug_console_execute_command(dv->machine(), str, 1); + break; + case DVT_MEMORY: + downcast(dv->view)->set_expression(str); + break; + } +} + +static void on_memory_window_activate(DView *dv, const ui_menu_event *event) +{ +} + +static void on_disassembly_window_activate(DView *dv, const ui_menu_event *event) +{ + DView *ndv; + render_target *target; + const debug_view_source *source; + + target = &dv->machine().render().ui_target(); + + ndv = dview_alloc(target, dv->machine(), DVT_DISASSEMBLY, 0); + ndv->editor.active = TRUE; + ndv->editor.container = &dv->machine().render().ui_container(); + source = ndv->view->source(); + dview_set_title(ndv, source->name()); + set_focus_view(ndv); + +} + +static void on_disasm_cpu_activate(DView *dv, const ui_menu_event *event) +{ + const debug_view_source *current = dv->view->source(); + + if (event->iptkey == IPT_UI_RIGHT) + { + current = current->next(); + if (current == NULL) + current = dv->view->first_source(); + dv->view->set_source(*current); + dview_set_state(dv, VIEW_STATE_NEEDS_UPDATE, TRUE); + dview_set_title(dv, current->name()); + } +} + +static void on_log_window_activate(DView *dv, const ui_menu_event *event) +{ + DView *ndv; + render_target *target; + + target = &dv->machine().render().ui_target(); + ndv = dview_alloc(target, dv->machine(), DVT_LOG, 0); + dview_set_title(ndv, "Log"); + set_focus_view(ndv); +} + +static void on_close_activate(DView *dv, const ui_menu_event *event) +{ + if (focus_view == dv) + set_focus_view(dv->next); + dview_free(dv); +} + +static void on_run_activate(DView *dv, const ui_menu_event *event) +{ + debug_cpu_get_visible_cpu(dv->machine())->debug()->go(); +} + +#if 0 +void on_run_h_activate(DView *dv, const ui_menu_event *event) +{ + debugwin_show(0); + debug_cpu_get_visible_cpu(dv->machine())->debug()->go(); +} +#endif + +static void on_run_cpu_activate(DView *dv, const ui_menu_event *event) +{ + debug_cpu_get_visible_cpu(dv->machine())->debug()->go_next_device(); +} + +static void on_run_irq_activate(DView *dv, const ui_menu_event *event) +{ + debug_cpu_get_visible_cpu(dv->machine())->debug()->go_interrupt(); +} + +static void on_run_vbl_activate(DView *dv, const ui_menu_event *event) +{ + debug_cpu_get_visible_cpu(dv->machine())->debug()->go_vblank(); +} + +static void on_step_into_activate(DView *dv, const ui_menu_event *event) +{ + debug_cpu_get_visible_cpu(dv->machine())->debug()->single_step(); +} + +static void on_step_over_activate(DView *dv, const ui_menu_event *event) +{ + debug_cpu_get_visible_cpu(dv->machine())->debug()->single_step_over(); +} + +#ifdef UNUSED_CODE +static void on_step_out_activate(DView *dv, const ui_menu_event *event) +{ + debug_cpu_get_visible_cpu(dv->machine())->debug()->single_step_out(); +} +#endif + +static void on_hard_reset_activate(DView *dv, const ui_menu_event *event) +{ + dv->machine().schedule_hard_reset(); +} + +static void on_soft_reset_activate(DView *dv, const ui_menu_event *event) +{ + dv->machine().schedule_soft_reset(); + debug_cpu_get_visible_cpu(dv->machine())->debug()->go(); +} + +static void on_exit_activate(DView *dv, const ui_menu_event *event) +{ + dv->machine().schedule_exit(); +} + +static void on_view_opcodes_activate(DView *dv, const ui_menu_event *event) +{ + debug_view_disasm *dasmview = downcast(focus_view->view); + disasm_right_column rc = dasmview->right_column(); + disasm_right_column new_rc = DASM_RIGHTCOL_NONE; + + if (event->iptkey == IPT_UI_RIGHT) + { + switch (rc) + { + case DASM_RIGHTCOL_RAW: new_rc = DASM_RIGHTCOL_ENCRYPTED; break; + case DASM_RIGHTCOL_ENCRYPTED: new_rc = DASM_RIGHTCOL_COMMENTS; break; + case DASM_RIGHTCOL_COMMENTS: new_rc = DASM_RIGHTCOL_RAW; break; + default: break; + } + dasmview->set_right_column(new_rc); + dview_set_state(dv, VIEW_STATE_NEEDS_UPDATE, TRUE); + } +} + +static void on_run_to_cursor_activate(DView *dv, const ui_menu_event *event) +{ + char command[64]; + + if (dv->view->cursor_visible() && debug_cpu_get_visible_cpu(dv->machine()) == dv->view->source()->device()) + { + offs_t address = downcast(dv->view)->selected_address(); + sprintf(command, "go %X", address); + debug_console_execute_command(dv->machine(), command, 1); + } +} + +/*------------------------------------------------- + editor + -------------------------------------------------*/ + +static void render_editor(DView_edit *editor) +{ + float width, maxwidth; + float x1, y1, x2, y2; + + editor->container->empty(); + /* get the size of the text */ + editor->container->manager().machine().ui().draw_text_full(editor->container, editor->str, 0.0f, 0.0f, 1.0f, JUSTIFY_CENTER, WRAP_TRUNCATE, + DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &width, NULL); + width += 2 * UI_BOX_LR_BORDER; + maxwidth = MAX(width, 0.5); + + /* compute our bounds */ + x1 = 0.5f - 0.5f * maxwidth; + x2 = x1 + maxwidth; + y1 = 0.25f; + y2 = 0.45f - UI_BOX_TB_BORDER; + + /* draw a box */ + editor->container->manager().machine().ui().draw_outlined_box(editor->container, x1, y1, x2, y2, UI_BACKGROUND_COLOR); + + /* take off the borders */ + x1 += UI_BOX_LR_BORDER; + x2 -= UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; + y2 -= UI_BOX_TB_BORDER; + + /* draw the text within it */ + editor->container->manager().machine().ui().draw_text_full(editor->container, editor->str, x1, y1, x2 - x1, JUSTIFY_CENTER, WRAP_TRUNCATE, + DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, NULL); + +} + +/*------------------------------------------------- + menu_main_populate - populate the main menu + -------------------------------------------------*/ + +class ui_menu_debug : public ui_menu { +public: + ui_menu_debug(running_machine &machine, render_container *container) : ui_menu(machine, container) {} + virtual ~ui_menu_debug() {} + virtual void populate() {} + virtual void handle() {} +}; + +static void CreateMainMenu(running_machine &machine) +{ + const char *subtext = ""; + int rc; + astring title; + + if (menu) + auto_free(machine, menu); + menu = auto_alloc_clear(machine, ui_menu_debug(machine, &machine.render().ui_container())); + + switch (focus_view->type) + { + case DVT_DISASSEMBLY: + title = "Disassembly:"; + break; + case DVT_CONSOLE: + title = "Console:"; + break; + case DVT_LOG: + title = "Log:"; + break; + case DVT_MEMORY: + title = "Memory:"; + break; + case DVT_STATE: + title = "State:"; + break; + } + + menu->item_append(title.cat(focus_view->title), NULL, MENU_FLAG_DISABLE, NULL); + menu->item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + + switch (focus_view->type) + { + case DVT_DISASSEMBLY: + { + rc = downcast(focus_view->view)->right_column(); + switch(rc) + { + case DASM_RIGHTCOL_RAW: subtext = "Raw Opcodes"; break; + case DASM_RIGHTCOL_ENCRYPTED: subtext = "Enc Opcodes"; break; + case DASM_RIGHTCOL_COMMENTS: subtext = "Comments"; break; + } + menu->item_append("View", subtext, MENU_FLAG_RIGHT_ARROW, (void *)on_view_opcodes_activate); + menu->item_append("Run to cursor", NULL, 0, (void *)on_run_to_cursor_activate); + + if (!dview_is_state(focus_view, VIEW_STATE_FOLLOW_CPU)) + { + menu->item_append("CPU", focus_view->view->source()->name(), MENU_FLAG_RIGHT_ARROW, (void *)on_disasm_cpu_activate); + } + menu->item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + break; + } + } + + /* add input menu items */ + + menu->item_append("New Memory Window", NULL, 0, (void *)on_memory_window_activate); + menu->item_append("New Disassembly Window", NULL, 0, (void *)on_disassembly_window_activate); + menu->item_append("New Error Log Window", NULL, 0, (void *)on_log_window_activate); + menu->item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + menu->item_append("Run", NULL, 0, (void *)on_run_activate); + menu->item_append("Run to Next CPU", NULL, 0, (void *)on_run_cpu_activate); + menu->item_append("Run until Next Interrupt on This CPU", NULL, 0, (void *)on_run_irq_activate); + menu->item_append("Run until Next VBLANK", NULL, 0, (void *)on_run_vbl_activate); + menu->item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + menu->item_append("Step Into", NULL, 0, (void *)on_step_into_activate); + menu->item_append("Step Over", NULL, 0, (void *)on_step_over_activate); + menu->item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + menu->item_append("Soft Reset", NULL, 0, (void *)on_soft_reset_activate); + menu->item_append("Hard Reset", NULL, 0, (void *)on_hard_reset_activate); + menu->item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL); + if (!dview_is_state(focus_view, VIEW_STATE_FOLLOW_CPU)) + menu->item_append("Close Window", NULL, 0, (void *)on_close_activate); + menu->item_append("Exit", NULL, 0, (void *)on_exit_activate); +} + +static int map_point(DView *dv, INT32 target_x, INT32 target_y, INT32 *mapped_x, INT32 *mapped_y) +{ + rectangle pos; + + /* default to point not mapped */ + *mapped_x = -1; + *mapped_y = -1; + + pos = dv->bounds; + pos.min_x += dv->ofs_x; + pos.max_x += dv->ofs_x; + pos.min_y += dv->ofs_y; + pos.max_y += dv->ofs_y; + //render_target_get_component_container(target, name, &pos); + + if (target_x >= pos.min_x && target_x <= pos.max_x && target_y >= pos.min_y && target_y <= pos.max_y) + { + *mapped_x = target_x - pos.min_x; + *mapped_y = target_y - pos.min_y; + return TRUE; + } + return FALSE; +} + +static void handle_mouse(running_machine &machine) +{ + render_target * mouse_target; + INT32 x,y; + bool button; + + if (menu != NULL) + return; + + mouse_target = ui_input_find_mouse(machine, &x, &y, &button); + + if (mouse_target == NULL) + return; + //printf("mouse %d %d %d\n", x, y, button); + + for (DView *dv = list; dv != NULL; dv = dv->next) + { + if (mouse_target == dv->target) + { + if (dview_on_mouse(dv, x, y, button)) + break; + } + } +} + + +/*------------------------------------------------- + handle_editor - handle the editor +-------------------------------------------------*/ + +static void handle_editor(running_machine &machine) +{ + if (focus_view->editor.active) + { + ui_event event; + + /* loop while we have interesting events */ + while (ui_input_pop_event(machine, &event)) + { + switch (event.event_type) + { + case UI_EVENT_CHAR: + /* if it's a backspace and we can handle it, do so */ + if ((event.ch == 8 || event.ch == 0x7f) && focus_view->editor.str.len() > 0) + { + /* autoschow */ + cur_editor = &focus_view->editor; + cur_editor->str = cur_editor->str.substr(0, cur_editor->str.len()-1); + } + /* if it's any other key and we're not maxed out, update */ + else if (event.ch >= ' ' && event.ch < 0x7f) + { + char buf[10]; + int ret; + /* autoschow */ + cur_editor = &focus_view->editor; + ret = utf8_from_uchar(buf, 10, event.ch); + buf[ret] = 0; + cur_editor->str = cur_editor->str.cat(buf); + } + break; + default: + break; + } + } + if (cur_editor != NULL) + { + render_editor(cur_editor); + if (ui_input_pressed(machine, IPT_UI_SELECT)) + { + process_string(focus_view, focus_view->editor.str); + focus_view->editor.str = ""; + cur_editor = NULL; + } + if (ui_input_pressed(machine, IPT_UI_CANCEL)) + cur_editor = NULL; + } + } + +} + + +/*------------------------------------------------- + menu_main - handle the main menu +-------------------------------------------------*/ + +static void handle_menus(running_machine &machine) +{ + const ui_menu_event *event; + + machine.render().ui_container().empty(); + ui_input_frame_update(machine); + if (menu != NULL) + { + /* process the menu */ + event = menu->process(0); + if (event != NULL && (event->iptkey == IPT_UI_SELECT || (event->iptkey == IPT_UI_RIGHT))) + { + //auto_free(machine, menu); + //menu = NULL; + ((void (*)(DView *, const ui_menu_event *)) event->itemref)(focus_view, event); + //ui_menu_stack_push(ui_menu_alloc(machine, menu->container, (ui_menu_handler_func)event->itemref, NULL)); + CreateMainMenu(machine); + } + else if (ui_input_pressed(machine, IPT_UI_CONFIGURE)) + { + auto_free(machine, menu); + menu = NULL; + } + } + else + { + /* turn on menus if requested */ + if (ui_input_pressed(machine, IPT_UI_CONFIGURE)) + CreateMainMenu(machine); + /* turn on editor if requested */ + //if (ui_input_pressed(machine, IPT_UI_UP) && focus_view->editor.active) + // cur_editor = &focus_view->editor; + handle_editor(machine); + } +} + +//============================================================ +// followers_set_cpu +//============================================================ + +static void followers_set_cpu(device_t *device) +{ + astring title; + + for (DView *dv = list; dv != NULL; dv = dv->next) + { + if (dview_is_state(dv, VIEW_STATE_FOLLOW_CPU)) + { + const debug_view_source *source = dv->view->source_for_device(device); + switch (dv->type) + { + case DVT_DISASSEMBLY: + case DVT_STATE: + dv->view->set_source(*source); + title.printf("%s", source->name()); + dview_set_title(dv, title); + break; + } + } + } + // and recompute the children + //console_recompute_children(main_console); +} + + +static void dview_update_view(DView *dv) +{ + INT32 old_rt_width = dv->rt_width; + INT32 old_rt_height = dv->rt_height; + + dv->rt_width = dv->target->width(); + dv->rt_height = dv->target->height(); + if (dview_is_state(dv, VIEW_STATE_NEEDS_UPDATE) || dv->rt_width != old_rt_width || dv->rt_height != old_rt_height) + { + dview_size_allocate(dv); + dview_draw(dv); + dview_set_state(dv, VIEW_STATE_NEEDS_UPDATE, FALSE); + } +} + + +static void update_views(void) +{ + DView *dv, *prev; + + LIST_GET_LAST(list, dv); + while (dv != NULL) + { + dview_update_view(dv); + LIST_GET_PREVIOUS(list, dv, prev); + dv = prev; + } +} + + +void debugger_internal::wait_for_debugger(device_t &device, bool firststop) +{ + if (firststop && list == NULL) + { + DView *dv; + render_target *target; + + target = &device.machine().render().ui_target(); + + //set_view_by_name(target, "Debug"); + + dv = dview_alloc(target, device.machine(), DVT_DISASSEMBLY, VIEW_STATE_FOLLOW_CPU); + dv->editor.active = TRUE; + dv->editor.container = &device.machine().render().ui_container(); + dv = dview_alloc(target, device.machine(), DVT_STATE, VIEW_STATE_FOLLOW_CPU); + dv = dview_alloc(target, device.machine(), DVT_CONSOLE, VIEW_STATE_FOLLOW_CPU); + dview_set_title(dv, "Console"); + dv->editor.active = TRUE; + dv->editor.container = &device.machine().render().ui_container(); + set_focus_view(dv); + } + + followers_set_cpu(&device); + + //ui_update_and_render(device.machine(), device.machine().render().ui_container()()); + update_views(); + device.machine().osd().update(false); + handle_menus(device.machine()); + handle_mouse(device.machine()); + //osd_sleep(osd_ticks_per_second()/60); + +} + +void debugger_internal::debugger_update() +{ + if (!debug_cpu_is_stopped(m_osd.machine()) && m_osd.machine().phase() == MACHINE_PHASE_RUNNING) + { + update_views(); + } +} + +//------------------------------------------------- +// debugger_internal - constructor +//------------------------------------------------- +debugger_internal::debugger_internal(const osd_interface &osd) + : osd_debugger_interface(osd) +{ +} \ No newline at end of file diff --git a/src/osd/modules/debugger/debugint.h b/src/osd/modules/debugger/debugint.h new file mode 100644 index 00000000000..32f77924885 --- /dev/null +++ b/src/osd/modules/debugger/debugint.h @@ -0,0 +1,34 @@ +/********************************************************************* + + debugint.c + + Internal debugger frontend using render interface. + + Copyright Nicola Salmoria and the MAME Team. + Visit http://mamedev.org for licensing and usage restrictions. + +*********************************************************************/ + +#pragma once + +#ifndef __DEBUGGER_INTERNAL_H__ +#define __DEBUGGER_INTERNAL_H__ + +#include "osdepend.h" + +class debugger_internal : public osd_debugger_interface +{ +public: + // construction/destruction + debugger_internal(const osd_interface &osd); + virtual ~debugger_internal() { } + + virtual void init_debugger(); + virtual void wait_for_debugger(device_t &device, bool firststop); + virtual void debugger_update(); + virtual void debugger_exit(); +}; + +extern const osd_debugger_type OSD_DEBUGGER_INTERNAL; + +#endif /* __DEBUGGER_INTERNAL_H__ */ diff --git a/src/osd/sdl/debugosx.h b/src/osd/modules/debugger/debugosx.h similarity index 95% rename from src/osd/sdl/debugosx.h rename to src/osd/modules/debugger/debugosx.h index 314cf23cd59..4f8bc6761a2 100644 --- a/src/osd/sdl/debugosx.h +++ b/src/osd/modules/debugger/debugosx.h @@ -364,6 +364,21 @@ typedef float CGFloat; @end +class debugger_osx : public osd_debugger_interface +{ +public: + // construction/destruction + debugger_osx(const osd_interface &osd); + virtual ~debugger_osx() { } + + virtual void init_debugger(); + virtual void wait_for_debugger(device_t &device, bool firststop); + virtual void debugger_update(); + virtual void debugger_exit(); +}; + +extern const osd_debugger_type OSD_DEBUGGER_OSX; + #endif // __OBJC__ #endif // __SDL_DEBUGOSX__ diff --git a/src/osd/sdl/debugosx.m b/src/osd/modules/debugger/debugosx.m similarity index 99% rename from src/osd/sdl/debugosx.m rename to src/osd/modules/debugger/debugosx.m index a96810c94ee..fc0596e7ca1 100644 --- a/src/osd/sdl/debugosx.m +++ b/src/osd/modules/debugger/debugosx.m @@ -64,20 +64,29 @@ static void debugwin_view_update(debug_view &view, void *osdprivate); static void console_create_window(running_machine &machine); +const osd_debugger_type OSD_DEBUGGER_OSX = &osd_debugger_creator; -//============================================================ -// sdl_osd_interface::init_debugger -//============================================================ - -void sdl_osd_interface::init_debugger() +//------------------------------------------------- +// debugger_osx - constructor +//------------------------------------------------- +debugger_osx::debugger_osx(const osd_interface &osd) + : osd_debugger_interface(osd) { } //============================================================ -// sdl_osd_interface::wait_for_debugger +// debugger_osx::init_debugger //============================================================ -void sdl_osd_interface::wait_for_debugger(device_t &device, bool firststop) +void debugger_osx::init_debugger() +{ +} + +//============================================================ +// debugger_osx::wait_for_debugger +//============================================================ + +void debugger_osx::wait_for_debugger(device_t &device, bool firststop) { // create a console window if (main_console == nil) @@ -113,7 +122,7 @@ void sdl_osd_interface::wait_for_debugger(device_t &device, bool firststop) // debugger_update //============================================================ -void sdl_osd_interface::debugger_update() +void debugger_osx::debugger_update() { } @@ -121,7 +130,7 @@ void sdl_osd_interface::debugger_update() // debugger_exit //============================================================ -void sdl_osd_interface::debugger_exit() +void debugger_osx::debugger_exit() { } diff --git a/src/osd/sdl/debugqt.c b/src/osd/modules/debugger/debugqt.c similarity index 85% rename from src/osd/sdl/debugqt.c rename to src/osd/modules/debugger/debugqt.c index a718253d7ec..20eb39538a4 100644 --- a/src/osd/sdl/debugqt.c +++ b/src/osd/modules/debugger/debugqt.c @@ -9,8 +9,6 @@ // //============================================================ -#if !defined(NO_DEBUGGER) - #define NO_MEM_TRACKING #include @@ -19,21 +17,22 @@ #include #include "emu.h" -#if defined(WIN32) && !defined(SDLMAME_WIN32) -#include "winmain.h" -#define xxx_osd_interface windows_osd_interface -#else -#include "osdsdl.h" -#define xxx_osd_interface sdl_osd_interface -#endif #include "config.h" #include "debugger.h" -#include "debugqtlogwindow.h" -#include "debugqtmainwindow.h" -#include "debugqtdasmwindow.h" -#include "debugqtmemorywindow.h" -#include "debugqtbreakpointswindow.h" +#include "qt/debugqtlogwindow.h" +#include "qt/debugqtmainwindow.h" +#include "qt/debugqtdasmwindow.h" +#include "qt/debugqtmemorywindow.h" +#include "qt/debugqtbreakpointswindow.h" +#include "debugqt.h" + + +osd_debugger_interface *qt_osd_debugger_creator(const osd_interface &osd) +{ + return new debugger_qt(osd); +} +const osd_debugger_type OSD_DEBUGGER_QT = &qt_osd_debugger_creator; //============================================================ // "Global" variables to make QT happy @@ -43,8 +42,19 @@ int qtArgc = 0; char** qtArgv = NULL; bool oneShot = true; -MainWindow* mainQtWindow = NULL; +static MainWindow* mainQtWindow = NULL; +//------------------------------------------------- +// debugger_qt - constructor +//------------------------------------------------- +debugger_qt::debugger_qt(const osd_interface &osd) + : osd_debugger_interface(osd) +{ +} + +debugger_qt::~debugger_qt() +{ +} //============================================================ // XML configuration save/load @@ -205,7 +215,7 @@ static void bring_main_window_to_front() bool winwindow_qt_filter(void *message); #endif -void xxx_osd_interface::init_debugger() +void debugger_qt::init_debugger() { if (qApp == NULL) { @@ -228,10 +238,10 @@ void xxx_osd_interface::init_debugger() } // Setup the configuration XML saving and loading - config_register(machine(), + config_register(m_osd.machine(), "debugger", - config_saveload_delegate(FUNC(xml_configuration_load), &machine()), - config_saveload_delegate(FUNC(xml_configuration_save), &machine())); + config_saveload_delegate(FUNC(xml_configuration_load), &m_osd.machine()), + config_saveload_delegate(FUNC(xml_configuration_save), &m_osd.machine())); } @@ -245,7 +255,7 @@ extern int sdl_entered_debugger; void winwindow_update_cursor_state(running_machine &machine); #endif -void xxx_osd_interface::wait_for_debugger(device_t &device, bool firststop) +void debugger_qt::wait_for_debugger(device_t &device, bool firststop) { #if defined(SDLMAME_UNIX) || defined(SDLMAME_WIN32) sdl_entered_debugger = 1; @@ -254,9 +264,9 @@ void xxx_osd_interface::wait_for_debugger(device_t &device, bool firststop) // Dialog initialization if (oneShot) { - mainQtWindow = new MainWindow(&machine()); + mainQtWindow = new MainWindow(&m_osd.machine()); load_and_clear_main_window_config(xmlConfigurations); - setup_additional_startup_windows(machine(), xmlConfigurations); + setup_additional_startup_windows(m_osd.machine(), xmlConfigurations); mainQtWindow->show(); oneShot = false; } @@ -274,7 +284,7 @@ void xxx_osd_interface::wait_for_debugger(device_t &device, bool firststop) mainQtWindow->setProcessor(&device); // Run our own QT event loop - while (debug_cpu_is_stopped(machine())) + while (debug_cpu_is_stopped(m_osd.machine())) { osd_sleep(50000); qApp->processEvents(QEventLoop::AllEvents, 1); @@ -301,7 +311,7 @@ void xxx_osd_interface::wait_for_debugger(device_t &device, bool firststop) } // Exit if the machine has been instructed to do so (scheduled event == exit || hard_reset) - if (machine().scheduled_event_pending()) + if (m_osd.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 @@ -310,7 +320,7 @@ void xxx_osd_interface::wait_for_debugger(device_t &device, bool firststop) break; } #if defined(WIN32) && !defined(SDLMAME_WIN32) - winwindow_update_cursor_state(machine()); // make sure the cursor isn't hidden while in debugger + winwindow_update_cursor_state(m_osd.machine()); // make sure the cursor isn't hidden while in debugger #endif } } @@ -320,40 +330,12 @@ void xxx_osd_interface::wait_for_debugger(device_t &device, bool firststop) // Available for video.* //============================================================ -void xxx_osd_interface::debugger_update() +void debugger_qt::debugger_update() { qApp->processEvents(QEventLoop::AllEvents, 1); } -void xxx_osd_interface::debugger_exit() +void debugger_qt::debugger_exit() { } - -#else - - - -#include "sdlinc.h" - -#include "emu.h" -#include "osdepend.h" -#include "osdsdl.h" - -void sdl_osd_interface::init_debugger() -{ -} - -void sdl_osd_interface::wait_for_debugger(device_t &device, bool firststop) -{ -} - -void sdl_osd_interface::debugger_update() -{ -} - -void sdl_osd_interface::debugger_exit() -{ -} - -#endif diff --git a/src/osd/modules/debugger/debugqt.h b/src/osd/modules/debugger/debugqt.h new file mode 100644 index 00000000000..7c1b15ce730 --- /dev/null +++ b/src/osd/modules/debugger/debugqt.h @@ -0,0 +1,34 @@ +//============================================================ +// +// debugqt.h - SDL/QT debug window handling +// +// Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +// SDLMAME by Olivier Galibert and R. Belmont +// +//============================================================ + +#pragma once + +#ifndef __DEBUGGER_QT_H__ +#define __DEBUGGER_QT_H__ + +#include "osdepend.h" + +class debugger_qt : public osd_debugger_interface +{ +public: + // construction/destruction + debugger_qt(const osd_interface &osd); + virtual ~debugger_qt(); + + virtual void init_debugger(); + virtual void wait_for_debugger(device_t &device, bool firststop); + virtual void debugger_update(); + virtual void debugger_exit(); +}; + +extern const osd_debugger_type OSD_DEBUGGER_QT; + +#endif /* __DEBUGGER_QT_H__ */ diff --git a/src/osd/windows/debugwin.c b/src/osd/modules/debugger/debugwin.c similarity index 98% rename from src/osd/windows/debugwin.c rename to src/osd/modules/debugger/debugwin.c index d8758bd3a49..c7dee8c1a58 100644 --- a/src/osd/windows/debugwin.c +++ b/src/osd/modules/debugger/debugwin.c @@ -32,13 +32,13 @@ // MAMEOS headers #include "winmain.h" #include "window.h" -#include "video.h" -#include "input.h" -#include "config.h" +#include "../../windows/input.h" #include "strconv.h" #include "winutf8.h" +#include "debugwin.h" +const osd_debugger_type OSD_DEBUGGER_WINDOWS = &osd_debugger_creator; //============================================================ // PARAMETERS @@ -238,17 +238,26 @@ static void smart_show_all(BOOL show); static void image_update_menu(debugwin_info *info); + +//------------------------------------------------- +// debugger_windows - constructor +//------------------------------------------------- +debugger_windows::debugger_windows(const osd_interface &osd) + : osd_debugger_interface(osd) +{ +} + //============================================================ // wait_for_debugger //============================================================ -void windows_osd_interface::wait_for_debugger(device_t &device, bool firststop) +void debugger_windows::wait_for_debugger(device_t &device, bool firststop) { MSG message; // create a console window if (main_console == NULL) - console_create_window(machine()); + console_create_window(m_osd.machine()); // update the views in the console to reflect the current CPU if (main_console != NULL) @@ -267,7 +276,7 @@ void windows_osd_interface::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(machine()); + wininput_poll(m_osd.machine()); // get and process messages GetMessage(&message, NULL, 0, 0); @@ -285,7 +294,7 @@ void windows_osd_interface::wait_for_debugger(device_t &device, bool firststop) // process everything else default: - winwindow_dispatch_message(machine(), &message); + winwindow_dispatch_message(m_osd.machine(), &message); break; } @@ -359,7 +368,7 @@ static int debugwin_seq_pressed(running_machine &machine) // debugwin_init_windows //============================================================ -void windows_osd_interface::init_debugger() +void debugger_windows::init_debugger() { static int class_registered; @@ -405,7 +414,7 @@ void windows_osd_interface::init_debugger() if (temp_dc != NULL) { - windows_options &options = downcast(machine().options()); + windows_options &options = downcast(m_osd.machine().options()); int size = options.debugger_font_size(); TCHAR *t_face; @@ -443,7 +452,7 @@ void windows_osd_interface::init_debugger() // debugwin_destroy_windows //============================================================ -void windows_osd_interface::debugger_exit() +void debugger_windows::debugger_exit() { // loop over windows and free them while (window_list != NULL) @@ -462,18 +471,18 @@ void windows_osd_interface::debugger_exit() // debugger_update //============================================================ -void windows_osd_interface::debugger_update() +void debugger_windows::debugger_update() { // if we're running live, do some checks - if (!winwindow_has_focus() && !debug_cpu_is_stopped(machine()) && machine().phase() == MACHINE_PHASE_RUNNING) + if (!winwindow_has_focus() && !debug_cpu_is_stopped(m_osd.machine()) && m_osd.machine().phase() == MACHINE_PHASE_RUNNING) { // see if the interrupt key is pressed and break if it is - if (debugwin_seq_pressed(machine())) + if (debugwin_seq_pressed(m_osd.machine())) { HWND focuswnd = GetFocus(); debugwin_info *info; - debug_cpu_get_visible_cpu(machine())->debug()->halt_on_next_instruction("User-initiated break\n"); + debug_cpu_get_visible_cpu(m_osd.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 new file mode 100644 index 00000000000..55d08f8a1dd --- /dev/null +++ b/src/osd/modules/debugger/debugwin.h @@ -0,0 +1,32 @@ +// license:BSD-3-Clause +// copyright-holders:Aaron Giles +//============================================================ +// +// debugwin.h - Win32 debug window handling +// +//============================================================ + + +#pragma once + +#ifndef __DEBUGGER_WINDOWS_H__ +#define __DEBUGGER_WINDOWS_H__ + +#include "osdepend.h" + +class debugger_windows : public osd_debugger_interface +{ +public: + // construction/destruction + debugger_windows(const osd_interface &osd); + virtual ~debugger_windows() { } + + virtual void init_debugger(); + virtual void wait_for_debugger(device_t &device, bool firststop); + virtual void debugger_update(); + virtual void debugger_exit(); +}; + +extern const osd_debugger_type OSD_DEBUGGER_WINDOWS; + +#endif /* __DEBUGGER_WINDOWS_H__ */ diff --git a/src/osd/modules/debugger/none.c b/src/osd/modules/debugger/none.c new file mode 100644 index 00000000000..255646551fc --- /dev/null +++ b/src/osd/modules/debugger/none.c @@ -0,0 +1,36 @@ +//============================================================ +// +// none.c - stubs for linking when NO_DEBUGGER is defined +// +//============================================================ + +#include "none.h" +#include "debug/debugcpu.h" + +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) +{ +} + +void debugger_none::init_debugger() +{ +} + +void debugger_none::wait_for_debugger(device_t &device, bool firststop) +{ + debug_cpu_get_visible_cpu(m_osd.machine())->debug()->go(); +} + +void debugger_none::debugger_update() +{ +} + +void debugger_none::debugger_exit() +{ +} + diff --git a/src/osd/modules/debugger/none.h b/src/osd/modules/debugger/none.h new file mode 100644 index 00000000000..147c8ea59e6 --- /dev/null +++ b/src/osd/modules/debugger/none.h @@ -0,0 +1,33 @@ +// license:BSD-3-Clause +// copyright-holders:Miodrag Milanovic +/*************************************************************************** + + none.h + + Dummy debugger interface. + +*******************************************************************c********/ + +#pragma once + +#ifndef __DEBUGGER_NONE_H__ +#define __DEBUGGER_NONE_H__ + +#include "osdepend.h" + +class debugger_none : public osd_debugger_interface +{ +public: + // construction/destruction + debugger_none(const osd_interface &osd); + virtual ~debugger_none() { } + + virtual void init_debugger(); + virtual void wait_for_debugger(device_t &device, bool firststop); + virtual void debugger_update(); + virtual void debugger_exit(); +}; + +extern const osd_debugger_type OSD_DEBUGGER_NONE; + +#endif /* __DEBUGGER_NONE_H__ */ diff --git a/src/osd/sdl/debugqtbreakpointswindow.c b/src/osd/modules/debugger/qt/debugqtbreakpointswindow.c similarity index 100% rename from src/osd/sdl/debugqtbreakpointswindow.c rename to src/osd/modules/debugger/qt/debugqtbreakpointswindow.c diff --git a/src/osd/sdl/debugqtbreakpointswindow.h b/src/osd/modules/debugger/qt/debugqtbreakpointswindow.h similarity index 100% rename from src/osd/sdl/debugqtbreakpointswindow.h rename to src/osd/modules/debugger/qt/debugqtbreakpointswindow.h diff --git a/src/osd/sdl/debugqtdasmwindow.c b/src/osd/modules/debugger/qt/debugqtdasmwindow.c similarity index 100% rename from src/osd/sdl/debugqtdasmwindow.c rename to src/osd/modules/debugger/qt/debugqtdasmwindow.c diff --git a/src/osd/sdl/debugqtdasmwindow.h b/src/osd/modules/debugger/qt/debugqtdasmwindow.h similarity index 100% rename from src/osd/sdl/debugqtdasmwindow.h rename to src/osd/modules/debugger/qt/debugqtdasmwindow.h diff --git a/src/osd/sdl/debugqtlogwindow.c b/src/osd/modules/debugger/qt/debugqtlogwindow.c similarity index 100% rename from src/osd/sdl/debugqtlogwindow.c rename to src/osd/modules/debugger/qt/debugqtlogwindow.c diff --git a/src/osd/sdl/debugqtlogwindow.h b/src/osd/modules/debugger/qt/debugqtlogwindow.h similarity index 100% rename from src/osd/sdl/debugqtlogwindow.h rename to src/osd/modules/debugger/qt/debugqtlogwindow.h diff --git a/src/osd/sdl/debugqtmainwindow.c b/src/osd/modules/debugger/qt/debugqtmainwindow.c similarity index 99% rename from src/osd/sdl/debugqtmainwindow.c rename to src/osd/modules/debugger/qt/debugqtmainwindow.c index e64a6f318a0..49f006830a2 100644 --- a/src/osd/sdl/debugqtmainwindow.c +++ b/src/osd/modules/debugger/qt/debugqtmainwindow.c @@ -489,3 +489,11 @@ void MainWindowQtConfig::recoverFromXmlNode(xml_data_node* node) m_windowState = QByteArray::fromPercentEncoding(state); m_rightBar = xml_get_attribute_int(node, "rightbar", m_rightBar); } + +DasmDockWidget::~DasmDockWidget() +{ +} + +ProcessorDockWidget::~ProcessorDockWidget() +{ +} diff --git a/src/osd/sdl/debugqtmainwindow.h b/src/osd/modules/debugger/qt/debugqtmainwindow.h similarity index 98% rename from src/osd/sdl/debugqtmainwindow.h rename to src/osd/modules/debugger/qt/debugqtmainwindow.h index fd1432d5b92..864f1c0f662 100644 --- a/src/osd/sdl/debugqtmainwindow.h +++ b/src/osd/modules/debugger/qt/debugqtmainwindow.h @@ -90,7 +90,7 @@ public: } - virtual ~DasmDockWidget() {} + virtual ~DasmDockWidget(); DebuggerView* view() { return m_dasmView; } @@ -140,7 +140,7 @@ public: } - virtual ~ProcessorDockWidget() {} + virtual ~ProcessorDockWidget(); DebuggerView* view() { return m_processorView; } diff --git a/src/osd/sdl/debugqtmemorywindow.c b/src/osd/modules/debugger/qt/debugqtmemorywindow.c similarity index 100% rename from src/osd/sdl/debugqtmemorywindow.c rename to src/osd/modules/debugger/qt/debugqtmemorywindow.c diff --git a/src/osd/sdl/debugqtmemorywindow.h b/src/osd/modules/debugger/qt/debugqtmemorywindow.h similarity index 100% rename from src/osd/sdl/debugqtmemorywindow.h rename to src/osd/modules/debugger/qt/debugqtmemorywindow.h diff --git a/src/osd/sdl/debugqtview.c b/src/osd/modules/debugger/qt/debugqtview.c similarity index 100% rename from src/osd/sdl/debugqtview.c rename to src/osd/modules/debugger/qt/debugqtview.c diff --git a/src/osd/sdl/debugqtview.h b/src/osd/modules/debugger/qt/debugqtview.h similarity index 100% rename from src/osd/sdl/debugqtview.h rename to src/osd/modules/debugger/qt/debugqtview.h diff --git a/src/osd/sdl/debugqtwindow.c b/src/osd/modules/debugger/qt/debugqtwindow.c similarity index 100% rename from src/osd/sdl/debugqtwindow.c rename to src/osd/modules/debugger/qt/debugqtwindow.c diff --git a/src/osd/sdl/debugqtwindow.h b/src/osd/modules/debugger/qt/debugqtwindow.h similarity index 100% rename from src/osd/sdl/debugqtwindow.h rename to src/osd/modules/debugger/qt/debugqtwindow.h diff --git a/src/osd/windows/sound.c b/src/osd/modules/sound/direct_sound.c similarity index 84% rename from src/osd/windows/sound.c rename to src/osd/modules/sound/direct_sound.c index f56c764987f..a1afcac61ca 100644 --- a/src/osd/windows/sound.c +++ b/src/osd/modules/sound/direct_sound.c @@ -22,11 +22,9 @@ #include "emuopts.h" // MAMEOS headers +#include "direct_sound.h" #include "winmain.h" #include "window.h" -#include "video.h" -#include "config.h" - //============================================================ // DEBUGGING @@ -41,60 +39,26 @@ // LOCAL VARIABLES //============================================================ -// DirectSound objects -static LPDIRECTSOUND dsound; -static DSCAPS dsound_caps; - -// sound buffers -static LPDIRECTSOUNDBUFFER primary_buffer; -static LPDIRECTSOUNDBUFFER stream_buffer; -static UINT32 stream_buffer_size; -static UINT32 stream_buffer_in; - -// descriptors and formats -static DSBUFFERDESC primary_desc; -static DSBUFFERDESC stream_desc; -static WAVEFORMATEX primary_format; -static WAVEFORMATEX stream_format; - -// buffer over/underflow counts -static int buffer_underflows; -static int buffer_overflows; - //============================================================ // PROTOTYPES //============================================================ -static HRESULT dsound_init(running_machine &machine); -static void dsound_kill(void); -static HRESULT dsound_create_buffers(void); -static void dsound_destroy_buffers(void); +const osd_sound_type OSD_SOUND_DIRECT_SOUND = &osd_sound_creator; - - -//============================================================ -// sound_init -//============================================================ - -bool windows_osd_interface::sound_init() +//------------------------------------------------- +// sound_direct_sound - constructor +//------------------------------------------------- +sound_direct_sound::sound_direct_sound(const osd_interface &osd) + : osd_sound_interface(osd) { - // if no sound, don't create anything - if (!machine().options().sound()) - return true; - // attempt to initialize directsound // don't make it fatal if we can't -- we'll just run without sound - dsound_init(machine()); - return true; + dsound_init(); } -//============================================================ -// sound_exit -//============================================================ - -void windows_osd_interface::sound_exit() +sound_direct_sound::~sound_direct_sound() { // kill the buffers and dsound dsound_destroy_buffers(); @@ -112,7 +76,7 @@ void windows_osd_interface::sound_exit() // copy_sample_data //============================================================ -static void copy_sample_data(const INT16 *data, int bytes_to_copy) +void sound_direct_sound::copy_sample_data(const INT16 *data, int bytes_to_copy) { void *buffer1, *buffer2; DWORD length1, length2; @@ -156,7 +120,7 @@ static void copy_sample_data(const INT16 *data, int bytes_to_copy) // update_audio_stream //============================================================ -void windows_osd_interface::update_audio_stream(const INT16 *buffer, int samples_this_frame) +void sound_direct_sound::update_audio_stream(const INT16 *buffer, int samples_this_frame) { int bytes_this_frame = samples_this_frame * stream_format.nBlockAlign; DWORD play_position, write_position; @@ -212,7 +176,7 @@ void windows_osd_interface::update_audio_stream(const INT16 *buffer, int samples // set_mastervolume //============================================================ -void windows_osd_interface::set_mastervolume(int attenuation) +void sound_direct_sound::set_mastervolume(int attenuation) { // clamp the attenuation to 0-32 range if (attenuation > 0) @@ -230,7 +194,7 @@ void windows_osd_interface::set_mastervolume(int attenuation) // dsound_init //============================================================ -static HRESULT dsound_init(running_machine &machine) +HRESULT sound_direct_sound::dsound_init() { HRESULT result; @@ -263,12 +227,12 @@ static HRESULT dsound_init(running_machine &machine) stream_format.wBitsPerSample = 16; stream_format.wFormatTag = WAVE_FORMAT_PCM; stream_format.nChannels = 2; - stream_format.nSamplesPerSec = machine.sample_rate(); + stream_format.nSamplesPerSec = m_osd.machine().sample_rate(); stream_format.nBlockAlign = stream_format.wBitsPerSample * stream_format.nChannels / 8; stream_format.nAvgBytesPerSec = stream_format.nSamplesPerSec * stream_format.nBlockAlign; // compute the buffer size based on the output sample rate - stream_buffer_size = stream_format.nSamplesPerSec * stream_format.nBlockAlign * downcast(machine.options()).audio_latency() / 10; + stream_buffer_size = stream_format.nSamplesPerSec * stream_format.nBlockAlign * downcast(m_osd.machine().options()).audio_latency() / 10; stream_buffer_size = (stream_buffer_size / 1024) * 1024; if (stream_buffer_size < 1024) stream_buffer_size = 1024; @@ -301,7 +265,7 @@ error: // dsound_kill //============================================================ -static void dsound_kill(void) +void sound_direct_sound::dsound_kill() { // release the object if (dsound != NULL) @@ -314,7 +278,7 @@ static void dsound_kill(void) // dsound_create_buffers //============================================================ -static HRESULT dsound_create_buffers(void) +HRESULT sound_direct_sound::dsound_create_buffers() { HRESULT result; void *buffer; @@ -391,7 +355,7 @@ error: // dsound_destroy_buffers //============================================================ -static void dsound_destroy_buffers(void) +void sound_direct_sound::dsound_destroy_buffers(void) { // stop any playback if (stream_buffer != NULL) @@ -407,3 +371,4 @@ static void dsound_destroy_buffers(void) IDirectSoundBuffer_Release(primary_buffer); primary_buffer = NULL; } + diff --git a/src/osd/modules/sound/direct_sound.h b/src/osd/modules/sound/direct_sound.h new file mode 100644 index 00000000000..95807209ba6 --- /dev/null +++ b/src/osd/modules/sound/direct_sound.h @@ -0,0 +1,64 @@ +// license:BSD-3-Clause +// copyright-holders:Aaron Giles +//============================================================ +// +// sound.c - Win32 implementation of MAME sound routines +// +//============================================================ +#pragma once + +#ifndef __SOUND_DSOUND_H__ +#define __SOUND_DSOUND_H__ + +// standard windows headers +#define WIN32_LEAN_AND_MEAN +#include +#include + +// undef WINNT for dsound.h to prevent duplicate definition +#undef WINNT +#include +#undef interface + +#include "osdepend.h" + +class sound_direct_sound : public osd_sound_interface +{ +public: + // construction/destruction + sound_direct_sound(const osd_interface &osd); + virtual ~sound_direct_sound(); + + virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); + virtual void set_mastervolume(int attenuation); + + HRESULT dsound_init(); + void dsound_kill(); + HRESULT dsound_create_buffers(); + void dsound_destroy_buffers(); + void copy_sample_data(const INT16 *data, int bytes_to_copy); +private: + // DirectSound objects + LPDIRECTSOUND dsound; + DSCAPS dsound_caps; + + // sound buffers + LPDIRECTSOUNDBUFFER primary_buffer; + LPDIRECTSOUNDBUFFER stream_buffer; + UINT32 stream_buffer_size; + UINT32 stream_buffer_in; + + // descriptors and formats + DSBUFFERDESC primary_desc; + DSBUFFERDESC stream_desc; + WAVEFORMATEX primary_format; + WAVEFORMATEX stream_format; + + // buffer over/underflow counts + int buffer_underflows; + int buffer_overflows; +}; + +extern const osd_sound_type OSD_SOUND_DIRECT_SOUND; + +#endif /* __SOUND_DSOUND_H__ */ diff --git a/src/osd/modules/sound/none.c b/src/osd/modules/sound/none.c new file mode 100644 index 00000000000..1ae0a608016 --- /dev/null +++ b/src/osd/modules/sound/none.c @@ -0,0 +1,23 @@ +// license:BSD-3-Clause +// copyright-holders:Miodrag Milanovic +/*************************************************************************** + + none.c + + Dummy sound interface. + +*******************************************************************c********/ + + +#include "none.h" + +//------------------------------------------------- +// sound_none - constructor +//------------------------------------------------- +sound_none::sound_none(const osd_interface &osd) + : osd_sound_interface(osd) +{ +} + + +const osd_sound_type OSD_SOUND_NONE = &osd_sound_creator; \ No newline at end of file diff --git a/src/osd/modules/sound/none.h b/src/osd/modules/sound/none.h new file mode 100644 index 00000000000..730567fc258 --- /dev/null +++ b/src/osd/modules/sound/none.h @@ -0,0 +1,31 @@ +// license:BSD-3-Clause +// copyright-holders:Miodrag Milanovic +/*************************************************************************** + + none.h + + Dummy sound interface. + +*******************************************************************c********/ + +#pragma once + +#ifndef __SOUND_NONE_H__ +#define __SOUND_NONE_H__ + +#include "osdepend.h" + +class sound_none : public osd_sound_interface +{ +public: + // construction/destruction + sound_none(const osd_interface &osd); + virtual ~sound_none() { } + + virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame) { } + virtual void set_mastervolume(int attenuation) { } +}; + +extern const osd_sound_type OSD_SOUND_NONE; + +#endif /* __SOUND_NONE_H__ */ diff --git a/src/osd/sdl/sound.c b/src/osd/modules/sound/sdl_sound.c similarity index 92% rename from src/osd/sdl/sound.c rename to src/osd/modules/sound/sdl_sound.c index 2abca395d7d..0f92a1e779c 100644 --- a/src/osd/sdl/sound.c +++ b/src/osd/modules/sound/sdl_sound.c @@ -10,14 +10,14 @@ //============================================================ // standard sdl header -#include "sdlinc.h" +#include "../../sdl/sdlinc.h" // MAME headers #include "emu.h" #include "emuopts.h" -#include "osdepend.h" -#include "osdsdl.h" +#include "sdl_sound.h" +#include "../../sdl/osdsdl.h" //============================================================ // DEBUGGING @@ -75,48 +75,48 @@ static int sdl_create_buffers(void); static void sdl_destroy_buffers(void); static void SDLCALL sdl_callback(void *userdata, Uint8 *stream, int len); +const osd_sound_type OSD_SOUND_SDL = &osd_sound_creator; - -//============================================================ -// osd_start_audio_stream -//============================================================ -bool sdl_osd_interface::sound_init() +//------------------------------------------------- +// sound_sdl - constructor +//------------------------------------------------- +sound_sdl::sound_sdl(const osd_interface &osd) + : osd_sound_interface(osd) { if (LOG_SOUND) sound_log = fopen(SDLMAME_SOUND_LOG, "w"); // skip if sound disabled - if (machine().sample_rate() != 0) + if (osd.machine().sample_rate() != 0) { if (initialized_audio) { - sound_exit(); + //sound_exit(); } // attempt to initialize SDL - if (sdl_init(machine())) - return false; + if (sdl_init(osd.machine())) + return; // set the startup volume - machine().osd().set_mastervolume(attenuation); + set_mastervolume(attenuation); } - return true; } //============================================================ -// osd_stop_audio_stream +// sound_sdl - destructor //============================================================ -void sdl_osd_interface::sound_exit() +sound_sdl::~sound_sdl() { // if nothing to do, don't do it - if (machine().sample_rate() == 0) + if (m_osd.machine().sample_rate() == 0) return; // kill the buffers and dsound - sdl_kill(machine()); + sdl_kill(m_osd.machine()); sdl_destroy_buffers(); // print out over/underflow stats @@ -264,10 +264,10 @@ static void copy_sample_data(running_machine &machine, const INT16 *data, int by // update_audio_stream //============================================================ -void sdl_osd_interface::update_audio_stream(const INT16 *buffer, int samples_this_frame) +void sound_sdl::update_audio_stream(const INT16 *buffer, int samples_this_frame) { // if nothing to do, don't do it - if (machine().sample_rate() != 0 && stream_buffer) + if (m_osd.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 sdl_osd_interface::update_audio_stream(const INT16 *buffer, int samples_thi play_position = stream_playpos; - write_position = stream_playpos + ((machine().sample_rate() / 50) * sizeof(INT16) * 2); + write_position = stream_playpos + ((m_osd.machine().sample_rate() / 50) * sizeof(INT16) * 2); orig_write = write_position; if (!stream_in_initialized) @@ -336,7 +336,7 @@ void sdl_osd_interface::update_audio_stream(const INT16 *buffer, int samples_thi // now we know where to copy; let's do it stream_buffer_in = stream_in; - copy_sample_data(machine(), buffer, bytes_this_frame); + copy_sample_data(m_osd.machine(), buffer, bytes_this_frame); } } @@ -346,7 +346,7 @@ void sdl_osd_interface::update_audio_stream(const INT16 *buffer, int samples_thi // set_mastervolume //============================================================ -void sdl_osd_interface::set_mastervolume(int _attenuation) +void sound_sdl::set_mastervolume(int _attenuation) { // clamp the attenuation to 0-32 range if (_attenuation > 0) @@ -429,6 +429,11 @@ static int sdl_init(running_machine &machine) SDL_AudioSpec aspec, obtained; char audio_driver[16] = ""; + if (SDL_InitSubSystem(SDL_INIT_AUDIO)) { + osd_printf_error("Could not initialize SDL %s\n", SDL_GetError()); + exit(-1); + } + osd_printf_verbose("Audio: Start initialization\n"); #if (SDLMAME_SDL2) strncpy(audio_driver, SDL_GetCurrentAudioDriver(), sizeof(audio_driver)); @@ -509,6 +514,7 @@ static void sdl_kill(running_machine &machine) SDL_CloseAudio(); } + SDL_QuitSubSystem(SDL_INIT_AUDIO); } diff --git a/src/osd/modules/sound/sdl_sound.h b/src/osd/modules/sound/sdl_sound.h new file mode 100644 index 00000000000..af9250d9838 --- /dev/null +++ b/src/osd/modules/sound/sdl_sound.h @@ -0,0 +1,31 @@ +//============================================================ +// +// sound.c - SDL implementation of MAME sound routines +// +// Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +// SDLMAME by Olivier Galibert and R. Belmont +// +//============================================================ +#pragma once + +#ifndef __SOUND_SDL_H__ +#define __SOUND_SDL_H__ + +#include "osdepend.h" + +class sound_sdl : public osd_sound_interface +{ +public: + // construction/destruction + sound_sdl(const osd_interface &osd); + virtual ~sound_sdl(); + + virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); + virtual void set_mastervolume(int attenuation); +}; + +extern const osd_sound_type OSD_SOUND_SDL; + +#endif /* __SOUND_SDL_H__ */ diff --git a/src/osd/osdepend.c b/src/osd/osdepend.c index c62ad1967c0..e05f5bacfeb 100644 --- a/src/osd/osdepend.c +++ b/src/osd/osdepend.c @@ -10,21 +10,146 @@ #include "emu.h" -#include "emuopts.h" #include "osdepend.h" #include "portmidi/portmidi.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 -nosound -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 } +}; + +//============================================================ +// 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_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); + } + 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 @@ -32,6 +157,8 @@ osd_interface::osd_interface() osd_interface::~osd_interface() { + m_debugger_options.reset(); + m_sound_options.reset(); } @@ -73,11 +200,11 @@ void osd_interface::init(running_machine &machine) m_machine = &machine; - emu_options &options = downcast(machine.options()); + 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)); } @@ -112,6 +239,15 @@ void osd_interface::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()); + 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(); } @@ -128,10 +264,22 @@ void osd_interface::wait_for_debugger(device_t &device, bool firststop) // 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; + } } //------------------------------------------------- @@ -146,6 +294,7 @@ void osd_interface::update_audio_stream(const INT16 *buffer, int samples_this_fr // 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); } @@ -162,6 +311,7 @@ void osd_interface::set_mastervolume(int attenuation) // while (attenuation++ < 0) // volume /= 1.122018454; // = (10 ^ (1/20)) = 1dB // + m_sound->set_mastervolume(attenuation); } @@ -237,7 +387,8 @@ void osd_interface::init_subsystems() fflush(stderr); fflush(stdout); exit(-1); - } + } + sound_init(); input_init(); // we need pause callbacks @@ -258,9 +409,33 @@ bool osd_interface::video_init() 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; @@ -312,6 +487,7 @@ void osd_interface::video_exit() void osd_interface::sound_exit() { + global_free(m_sound); } void osd_interface::input_exit() @@ -333,12 +509,59 @@ void osd_interface::midi_exit() #endif } -void osd_interface::debugger_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 82d61a10f42..b0e89f26cde 100644 --- a/src/osd/osdepend.h +++ b/src/osd/osdepend.h @@ -16,17 +16,115 @@ #include "emucore.h" #include "osdcore.h" #include "unicode.h" +#include "options.h" +//============================================================ +// Defines +//============================================================ -//************************************************************************** +#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 -//************************************************************************** +//============================================================ + +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(); +private: + 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; + 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 @@ -38,6 +136,8 @@ public: osd_interface(); virtual ~osd_interface(); + void register_options(osd_options &options); + // getters running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } @@ -46,14 +146,15 @@ public: virtual void update(bool skip_redraw); // debugger overridables - virtual void init_debugger(); - virtual void wait_for_debugger(device_t &device, bool firststop); - virtual void debugger_update(); - virtual void debugger_exit(); + void init_debugger(); + void wait_for_debugger(device_t &device, bool firststop); + void debugger_update(); + void debugger_exit(); + virtual void debugger_register(); // audio overridables - virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); - virtual void set_mastervolume(int attenuation); + void update_audio_stream(const INT16 *buffer, int samples_this_frame); + void set_mastervolume(int attenuation); // input overridables virtual void customize_input_type_list(simple_list &typelist); @@ -67,8 +168,14 @@ public: virtual void *get_slider_list(); void init_subsystems(); + virtual bool video_init(); - virtual bool sound_init(); + virtual void video_register(); + + bool sound_init(); + virtual void sound_register(); + bool no_sound(); + virtual bool input_init(); virtual void input_pause(); virtual void input_resume(); @@ -78,17 +185,77 @@ public: void exit_subsystems(); virtual void video_exit(); - virtual void sound_exit(); + void sound_exit(); virtual void input_exit(); virtual void output_exit(); virtual void network_exit(); virtual void midi_exit(); virtual void osd_exit(); + + 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; + 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/osdmini/minimain.c b/src/osd/osdmini/minimain.c index 9eec9b97515..98964fc546f 100644 --- a/src/osd/osdmini/minimain.c +++ b/src/osd/osdmini/minimain.c @@ -64,6 +64,7 @@ int main(int argc, char *argv[]) // create a derivative of cli_options and add our own cli_options options; mini_osd_interface osd; + osd.register_options(options); cli_frontend frontend(options, osd); return frontend.execute(argc, argv); } diff --git a/src/osd/sdl/debugwin.c b/src/osd/sdl/debugwin.c deleted file mode 100644 index c6f7468ffa0..00000000000 --- a/src/osd/sdl/debugwin.c +++ /dev/null @@ -1,38 +0,0 @@ -//============================================================ -// -// debugwin.c - stubs for linking when NO_DEBUGGER is defined -// -// Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -// SDLMAME by Olivier Galibert and R. Belmont -// -//============================================================ - -#if defined(NO_DEBUGGER) - -#include "sdlinc.h" - -#include "emu.h" -#include "osdepend.h" -#include "osdsdl.h" - -// win32 stubs for linking -void sdl_osd_interface::init_debugger() -{ -} - -void sdl_osd_interface::wait_for_debugger(device_t &device, bool firststop) -{ -} - -// win32 stubs for linking -void sdl_osd_interface::debugger_update() -{ -} - -void sdl_osd_interface::debugger_exit() -{ -} - -#endif diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index ca91d8d1f3b..211b48492de 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -41,20 +41,8 @@ //============================================================ #define SDLOPTION_INIPATH "inipath" -#define SDLOPTION_AUDIO_LATENCY "audio_latency" -#define SDLOPTION_SCREEN "screen" -#define SDLOPTION_ASPECT "aspect" -#define SDLOPTION_RESOLUTION "resolution" -#define SDLOPTION_VIEW "view" #define SDLOPTION_SDLVIDEOFPS "sdlvideofps" -#define SDLOPTION_KEEPASPECT "keepaspect" -#define SDLOPTION_WINDOW "window" -#define SDLOPTION_NUMSCREENS "numscreens" -#define SDLOPTION_UNEVENSTRETCH "unevenstretch" #define SDLOPTION_USEALLHEADS "useallheads" -#define SDLOPTION_MAXIMIZE "maximize" -#define SDLOPTION_VIDEO "video" -#define SDLOPTION_SWITCHRES "switchres" #define SDLOPTION_FILTER "filter" #define SDLOPTION_CENTERH "centerh" #define SDLOPTION_CENTERV "centerv" @@ -62,17 +50,11 @@ #define SDLOPTION_SCALEMODE "scalemode" -#define SDLOPTION_MULTITHREADING "multithreading" -#define SDLOPTION_BENCH "bench" -#define SDLOPTION_NUMPROCESSORS "numprocessors" - #define SDLOPTION_WAITVSYNC "waitvsync" #define SDLOPTION_SYNCREFRESH "syncrefresh" #define SDLOPTION_KEYMAP "keymap" #define SDLOPTION_KEYMAP_FILE "keymap_file" #define SDLOPTION_UIMODEKEY "uimodekey" -#define SDLOPTION_OSLOG "oslog" -#define SDLOPTION_WATCHDOG "watchdog" #define SDLOPTION_SIXAXIS "sixaxis" #define SDLOPTION_JOYINDEX "joy_idx" @@ -144,27 +126,12 @@ public: // construction/destruction sdl_options(); - // debugging options - bool oslog() const { return bool_value(SDLOPTION_OSLOG); } - int watchdog() const { return int_value(SDLOPTION_WATCHDOG); } - // performance options - bool multithreading() const { return bool_value(SDLOPTION_MULTITHREADING); } - const char *numprocessors() const { return value(SDLOPTION_NUMPROCESSORS); } bool video_fps() const { return bool_value(SDLOPTION_SDLVIDEOFPS); } - int bench() const { return int_value(SDLOPTION_BENCH); } // video options - const char *video() const { return value(SDLOPTION_VIDEO); } - int numscreens() const { return int_value(SDLOPTION_NUMSCREENS); } - bool window() const { return bool_value(SDLOPTION_WINDOW); } - bool maximize() const { return bool_value(SDLOPTION_MAXIMIZE); } - bool keep_aspect() const { return bool_value(SDLOPTION_KEEPASPECT); } - bool uneven_stretch() const { return bool_value(SDLOPTION_UNEVENSTRETCH); } bool centerh() const { return bool_value(SDLOPTION_CENTERH); } bool centerv() const { return bool_value(SDLOPTION_CENTERV); } - bool wait_vsync() const { return bool_value(SDLOPTION_WAITVSYNC); } - bool sync_refresh() const { return bool_value(SDLOPTION_SYNCREFRESH); } const char *scale_mode() const { return value(SDLOPTION_SCALEMODE); } // OpenGL specific options @@ -179,25 +146,11 @@ public: const char *shader_mame(int index) const { astring temp; return value(temp.format("%s%d", SDLOPTION_SHADER_MAME, index)); } const char *shader_screen(int index) const { astring temp; return value(temp.format("%s%d", SDLOPTION_SHADER_SCREEN, index)); } - // per-window options - const char *screen() const { return value(SDLOPTION_SCREEN); } - const char *aspect() const { return value(SDLOPTION_ASPECT); } - const char *resolution() const { return value(SDLOPTION_RESOLUTION); } - const char *view() const { return value(SDLOPTION_VIEW); } - const char *screen(int index) const { astring temp; return value(temp.format("%s%d", SDLOPTION_SCREEN, index)); } - const char *aspect(int index) const { astring temp; return value(temp.format("%s%d", SDLOPTION_ASPECT, index)); } - const char *resolution(int index) const { astring temp; return value(temp.format("%s%d", SDLOPTION_RESOLUTION, index)); } - const char *view(int index) const { astring temp; return value(temp.format("%s%d", SDLOPTION_VIEW, index)); } - // full screen options - bool switch_res() const { return bool_value(SDLOPTION_SWITCHRES); } #ifdef SDLMAME_X11 bool use_all_heads() const { return bool_value(SDLOPTION_USEALLHEADS); } #endif - // sound options - int audio_latency() const { return int_value(SDLOPTION_AUDIO_LATENCY); } - // keyboard mapping bool keymap() const { return bool_value(SDLOPTION_KEYMAP); } const char *keymap_file() const { return value(SDLOPTION_KEYMAP_FILE); } @@ -235,16 +188,6 @@ public: 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); - virtual void debugger_update(); - virtual void debugger_exit(); - - // audio overridables - virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); - virtual void set_mastervolume(int attenuation); - // input overridables virtual void customize_input_type_list(simple_list &typelist); @@ -253,8 +196,11 @@ public: 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 void video_register(); + virtual void sound_register(); + virtual void debugger_register(); + virtual bool video_init(); - virtual bool sound_init(); virtual bool input_init(); virtual void input_pause(); virtual void input_resume(); @@ -264,7 +210,6 @@ public: #endif virtual void video_exit(); - virtual void sound_exit(); virtual void input_exit(); virtual void output_exit(); #ifdef USE_NETWORK diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak index ebdd5ef9dd7..43ee7e4afce 100644 --- a/src/osd/sdl/sdl.mak +++ b/src/osd/sdl/sdl.mak @@ -83,6 +83,12 @@ SDL_FRAMEWORK_PATH = /Library/Frameworks/ ########################################################################### ################## END USER-CONFIGURABLE OPTIONS ###################### ########################################################################### +OSDSRC = $(SRC)/osd +OSDOBJ = $(OBJ)/osd + +ifndef NO_USE_QTDEBUG +OBJDIRS += $(OSDOBJ)/modules/debugger/qt +endif ifndef SDL_LIBVER SDL_LIBVER = sdl @@ -262,7 +268,7 @@ LIBS += -framework CoreAudio -framework CoreMIDI endif ifdef NO_USE_QTDEBUG -DEBUGOBJS = $(SDLOBJ)/debugosx.o +DEBUGOBJS = $(OSDOBJ)/modules/debugger/debugosx.o endif SYNC_IMPLEMENTATION = ntc @@ -391,7 +397,7 @@ OSDOBJS = \ $(SDLMAIN) \ $(SDLOBJ)/sdlmain.o \ $(SDLOBJ)/input.o \ - $(SDLOBJ)/sound.o \ + $(OSDOBJ)/modules/sound/sdl_sound.o \ $(SDLOBJ)/video.o \ $(SDLOBJ)/drawsdl.o \ $(SDLOBJ)/window.o \ @@ -631,31 +637,29 @@ endif # OS2 #------------------------------------------------- ifndef NO_USE_QTDEBUG -$(SDLOBJ)/%.moc.c: $(SDLSRC)/%.h +$(OSDOBJ)/%.moc.c: $(OSDSRC)/%.h $(MOC) $(MOCINCPATH) $(DEFS) $< -o $@ DEBUGOBJS = \ - $(SDLOBJ)/debugqt.o \ - $(SDLOBJ)/debugqtview.o \ - $(SDLOBJ)/debugqtwindow.o \ - $(SDLOBJ)/debugqtlogwindow.o \ - $(SDLOBJ)/debugqtdasmwindow.o \ - $(SDLOBJ)/debugqtmainwindow.o \ - $(SDLOBJ)/debugqtmemorywindow.o \ - $(SDLOBJ)/debugqtbreakpointswindow.o \ - $(SDLOBJ)/debugqtview.moc.o \ - $(SDLOBJ)/debugqtwindow.moc.o \ - $(SDLOBJ)/debugqtlogwindow.moc.o \ - $(SDLOBJ)/debugqtdasmwindow.moc.o \ - $(SDLOBJ)/debugqtmainwindow.moc.o \ - $(SDLOBJ)/debugqtmemorywindow.moc.o \ - $(SDLOBJ)/debugqtbreakpointswindow.moc.o + $(OSDOBJ)/modules/debugger/debugqt.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtview.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtwindow.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtlogwindow.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtdasmwindow.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtmainwindow.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtmemorywindow.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtbreakpointswindow.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtview.moc.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtwindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtlogwindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtdasmwindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtmainwindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtmemorywindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtbreakpointswindow.moc.o endif ifeq ($(NO_DEBUGGER),1) DEFS += -DNO_DEBUGGER -# debugwin compiles into a stub ... -OSDOBJS += $(SDLOBJ)/debugwin.o else OSDOBJS += $(DEBUGOBJS) endif # NO_DEBUGGER diff --git a/src/osd/sdl/sdlmain.c b/src/osd/sdl/sdlmain.c index 7f743b116d1..5bdf50e3edf 100644 --- a/src/osd/sdl/sdlmain.c +++ b/src/osd/sdl/sdlmain.c @@ -49,7 +49,14 @@ #include "input.h" #include "osdsdl.h" #include "sdlos.h" - +#include "modules/sound/sdl_sound.h" +#if !defined(NO_DEBUGGER) +#include "modules/debugger/debugqt.h" +#endif +#include "modules/debugger/none.h" +#if defined(SDLMAME_MACOSX) +#include "modules/debugger/debugosx.h" +#endif // we override SDL's normal startup on Win32 // please see sdlprefix.h as well @@ -91,36 +98,14 @@ const options_entry sdl_options::s_option_entries[] = { { SDLOPTION_INIPATH, INI_PATH, OPTION_STRING, "path to ini files" }, - // debugging options - { NULL, NULL, OPTION_HEADER, "DEBUGGING OPTIONS" }, - { SDLOPTION_OSLOG, "0", OPTION_BOOLEAN, "output error.log data to the system debugger" }, - { SDLOPTION_WATCHDOG ";wdog", "0", OPTION_INTEGER, "force the program to terminate if no updates within specified number of seconds" }, - // performance options - { NULL, NULL, OPTION_HEADER, "PERFORMANCE OPTIONS" }, - { SDLOPTION_MULTITHREADING ";mt", "0", OPTION_BOOLEAN, "enable multithreading; this enables rendering and blitting on a separate thread" }, - { SDLOPTION_NUMPROCESSORS ";np", "auto", OPTION_STRING, "number of processors; this overrides the number the system reports" }, + { NULL, NULL, OPTION_HEADER, "SDL PERFORMANCE OPTIONS" }, { SDLOPTION_SDLVIDEOFPS, "0", OPTION_BOOLEAN, "show sdl video performance" }, - { SDLOPTION_BENCH, "0", OPTION_INTEGER, "benchmark for the given number of emulated seconds; implies -video none -nosound -nothrottle" }, // video options - { NULL, NULL, OPTION_HEADER, "VIDEO OPTIONS" }, + { NULL, NULL, OPTION_HEADER, "SDL VIDEO OPTIONS" }, // OS X can be trusted to have working hardware OpenGL, so default to it on for the best user experience -#ifdef SDLMAME_MACOSX - { SDLOPTION_VIDEO, SDLOPTVAL_OPENGL, OPTION_STRING, "video output method: soft or opengl" }, -#else - { SDLOPTION_VIDEO, SDLOPTVAL_SOFT, OPTION_STRING, "video output method: soft or opengl" }, -#endif - { SDLOPTION_NUMSCREENS, "1", OPTION_INTEGER, "number of screens to create; SDLMAME only supports 1 at this time" }, - { SDLOPTION_WINDOW ";w", "0", OPTION_BOOLEAN, "enable window mode; otherwise, full screen mode is assumed" }, - { SDLOPTION_MAXIMIZE ";max", "1", OPTION_BOOLEAN, "default to maximized windows; otherwise, windows will be minimized" }, - { SDLOPTION_KEEPASPECT ";ka", "1", OPTION_BOOLEAN, "constrain to the proper aspect ratio" }, - { SDLOPTION_UNEVENSTRETCH ";ues", "1", OPTION_BOOLEAN, "allow non-integer stretch factors" }, { SDLOPTION_CENTERH, "1", OPTION_BOOLEAN, "center horizontally within the view area" }, { SDLOPTION_CENTERV, "1", OPTION_BOOLEAN, "center vertically within the view area" }, - #if (SDL_VERSION_ATLEAST(1,2,10)) - { SDLOPTION_WAITVSYNC ";vs", "0", OPTION_BOOLEAN, "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" }, - { SDLOPTION_SYNCREFRESH ";srf", "0", OPTION_BOOLEAN, "enable using the start of VBLANK for throttling instead of the game time" }, - #endif #if (SDLMAME_SDL2) { SDLOPTION_SCALEMODE ";sm", SDLOPTVAL_NONE, OPTION_STRING, "Scale mode: none, hwblit, hwbest, yv12, yuy2, yv12x2, yuy2x2 (-video soft only)" }, #else @@ -159,44 +144,12 @@ const options_entry sdl_options::s_option_entries[] = { SDLOPTION_SHADER_SCREEN "9", SDLOPTVAL_NONE, OPTION_STRING, "custom OpenGL GLSL shader screen bitmap 9" }, #endif - // per-window options - { NULL, NULL, OPTION_HEADER, "PER-WINDOW VIDEO OPTIONS" }, - { SDLOPTION_SCREEN, SDLOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, - { SDLOPTION_ASPECT ";screen_aspect", SDLOPTVAL_AUTO, OPTION_STRING, "aspect ratio for all screens; 'auto' here will try to make a best guess" }, - { SDLOPTION_RESOLUTION ";r", SDLOPTVAL_AUTO, OPTION_STRING, "preferred resolution for all screens; format is x[@] or 'auto'" }, - { SDLOPTION_VIEW, SDLOPTVAL_AUTO, OPTION_STRING, "preferred view for all screens" }, - - { SDLOPTION_SCREEN "0", SDLOPTVAL_AUTO, OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, - { SDLOPTION_ASPECT "0", SDLOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the first screen; 'auto' here will try to make a best guess" }, - { SDLOPTION_RESOLUTION "0;r0", SDLOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the first screen; format is x[@] or 'auto'" }, - { SDLOPTION_VIEW "0", SDLOPTVAL_AUTO, OPTION_STRING, "preferred view for the first screen" }, - - { SDLOPTION_SCREEN "1", SDLOPTVAL_AUTO, OPTION_STRING, "explicit name of the second screen; 'auto' here will try to make a best guess" }, - { SDLOPTION_ASPECT "1", SDLOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the second screen; 'auto' here will try to make a best guess" }, - { SDLOPTION_RESOLUTION "1;r1", SDLOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the second screen; format is x[@] or 'auto'" }, - { SDLOPTION_VIEW "1", SDLOPTVAL_AUTO, OPTION_STRING, "preferred view for the second screen" }, - - { SDLOPTION_SCREEN "2", SDLOPTVAL_AUTO, OPTION_STRING, "explicit name of the third screen; 'auto' here will try to make a best guess" }, - { SDLOPTION_ASPECT "2", SDLOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the third screen; 'auto' here will try to make a best guess" }, - { SDLOPTION_RESOLUTION "2;r2", SDLOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the third screen; format is x[@] or 'auto'" }, - { SDLOPTION_VIEW "2", SDLOPTVAL_AUTO, OPTION_STRING, "preferred view for the third screen" }, - - { SDLOPTION_SCREEN "3", SDLOPTVAL_AUTO, OPTION_STRING, "explicit name of the fourth screen; 'auto' here will try to make a best guess" }, - { SDLOPTION_ASPECT "3", SDLOPTVAL_AUTO, OPTION_STRING, "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" }, - { SDLOPTION_RESOLUTION "3;r3", SDLOPTVAL_AUTO, OPTION_STRING, "preferred resolution of the fourth screen; format is x[@] or 'auto'" }, - { SDLOPTION_VIEW "3", SDLOPTVAL_AUTO, OPTION_STRING, "preferred view for the fourth screen" }, - // full screen options - { NULL, NULL, OPTION_HEADER, "FULL SCREEN OPTIONS" }, - { SDLOPTION_SWITCHRES, "0", OPTION_BOOLEAN, "enable resolution switching" }, #ifdef SDLMAME_X11 + { NULL, NULL, OPTION_HEADER, "SDL FULL SCREEN OPTIONS" }, { SDLOPTION_USEALLHEADS, "0", OPTION_BOOLEAN, "split full screen image across monitors" }, #endif - // sound options - { NULL, NULL, OPTION_HEADER, "SOUND OPTIONS" }, - { SDLOPTION_AUDIO_LATENCY, "2", OPTION_INTEGER, "set audio latency (increase to reduce glitches, decrease for responsiveness)" }, - // keyboard mapping { NULL, NULL, OPTION_HEADER, "SDL KEYBOARD MAPPING" }, { SDLOPTION_KEYMAP, "0", OPTION_BOOLEAN, "enable keymap" }, @@ -371,6 +324,7 @@ int main(int argc, char *argv[]) { sdl_osd_interface osd; sdl_options options; + osd.register_options(options); cli_frontend frontend(options, osd); res = frontend.execute(argc, argv); } @@ -441,13 +395,13 @@ sdl_osd_interface::~sdl_osd_interface() void sdl_osd_interface::osd_exit() { - osd_interface::exit_subsystems(); + osd_interface::osd_exit(); if (!SDLMAME_INIT_IN_WORKER_THREAD) { /* FixMe: Bug in SDL2.0, Quitting joystick will cause SIGSEGV */ #if SDLMAME_SDL2 - SDL_QuitSubSystem(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO /*| SDL_INIT_JOYSTICK */); + SDL_QuitSubSystem(SDL_INIT_TIMER| SDL_INIT_VIDEO /*| SDL_INIT_JOYSTICK */); #else SDL_Quit(); #endif @@ -568,6 +522,46 @@ static void osd_sdl_info(void) } +//============================================================ +// video_register +//============================================================ + +void sdl_osd_interface::video_register() +{ + video_options_add("soft", NULL); + video_options_add("opengl", NULL); + //video_options_add("auto", NULL); // making d3d video default one +} + +//============================================================ +// sound_register +//============================================================ + +void sdl_osd_interface::sound_register() +{ + sound_options_add("sdl", OSD_SOUND_SDL); + sound_options_add("auto", OSD_SOUND_SDL); // making SDL audio default one +} + +//============================================================ +// debugger_register +//============================================================ + +void sdl_osd_interface::debugger_register() +{ +#if defined(NO_DEBUGGER) + debugger_options_add("auto", OSD_DEBUGGER_NONE); +#else +#if defined(SDLMAME_MACOSX) + debugger_options_add("osx", OSD_DEBUGGER_OSX); + debugger_options_add("auto", OSD_DEBUGGER_OSX); // making OSX debugger default one +#else + debugger_options_add("qt", OSD_DEBUGGER_QT); + debugger_options_add("auto", OSD_DEBUGGER_QT); // making QT debugger default one +#endif // SDLMAME_MACOSX +#endif // NO_DEBUGGER +} + //============================================================ // init //============================================================ @@ -587,7 +581,7 @@ void sdl_osd_interface::init(running_machine &machine) { options.set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM, error_string); options.set_value(OPTION_SOUND, false, OPTION_PRIORITY_MAXIMUM, error_string); - options.set_value(SDLOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM, error_string); + options.set_value(OSDOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM, error_string); options.set_value(OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM, error_string); assert(!error_string); } @@ -651,9 +645,9 @@ void sdl_osd_interface::init(running_machine &machine) if (!SDLMAME_INIT_IN_WORKER_THREAD) { #if (SDLMAME_SDL2) - if (SDL_InitSubSystem(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { + if (SDL_InitSubSystem(SDL_INIT_TIMER| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { #else - if (SDL_Init(SDL_INIT_TIMER|SDL_INIT_AUDIO| SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { + if (SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO| SDL_INIT_JOYSTICK|SDL_INIT_NOPARACHUTE)) { #endif osd_printf_error("Could not initialize SDL %s\n", SDL_GetError()); exit(-1); diff --git a/src/osd/windows/windows.mak b/src/osd/windows/windows.mak index 31ae2fa4a2f..9495e40f144 100644 --- a/src/osd/windows/windows.mak +++ b/src/osd/windows/windows.mak @@ -63,6 +63,11 @@ # set this to the minimum DirectInput version to support (7 or 8) # DIRECTINPUT = 8 +# uncomment next line to use SDL library for sound and video output +# USE_SDL = 1 + +# uncomment next line to use QT debugger +# USE_QTDEBUG = 1 ########################################################################### ################## END USER-CONFIGURABLE OPTIONS ###################### @@ -76,12 +81,26 @@ WINSRC = $(SRC)/osd/$(OSD) WINOBJ = $(OBJ)/osd/$(OSD) +OSDSRC = $(SRC)/osd +OSDOBJ = $(OBJ)/osd + OBJDIRS += $(WINOBJ) + ifdef USE_QTDEBUG -OBJDIRS += $(WINOBJ)/../sdl +OBJDIRS += $(OSDOBJ)/modules/debugger/qt +DEFS += -DUSE_QTDEBUG=1 +else +DEFS += -DUSE_QTDEBUG=0 endif - +ifdef USE_SDL +DEFS += -DSDLMAME_SDL2=0 +DEFS += -DUSE_XINPUT=0 +DEFS += -DUSE_OPENGL=0 +DEFS += -DUSE_SDL=1 +else +DEFS += -DUSE_SDL=0 +endif #------------------------------------------------- # configure the resource compiler @@ -289,6 +308,10 @@ endif # add the windows libraries LIBS += -luser32 -lgdi32 -ldsound -ldxguid -lwinmm -ladvapi32 -lcomctl32 -lshlwapi -lwsock32 +ifdef USE_SDL +LIBS += -lSDL.dll +endif + ifeq ($(DIRECTINPUT),8) LIBS += -ldinput8 CCOMFLAGS += -DDIRECTINPUT_VERSION=0x0800 @@ -332,12 +355,16 @@ OSDOBJS = \ $(WINOBJ)/drawnone.o \ $(WINOBJ)/input.o \ $(WINOBJ)/output.o \ - $(WINOBJ)/sound.o \ + $(OSDOBJ)/modules/sound/direct_sound.o \ $(WINOBJ)/video.o \ $(WINOBJ)/window.o \ $(WINOBJ)/winmenu.o \ $(WINOBJ)/winmain.o +ifdef USE_SDL +OSDOBJS += \ + $(OSDOBJ)/modules/sound/sdl_sound.o +endif ifdef USE_NETWORK OSDOBJS += \ @@ -351,11 +378,9 @@ CCOMFLAGS += -DDIRECT3D_VERSION=0x0900 $(WINOBJ)/drawdd.o : $(SRC)/emu/rendersw.inc $(WINOBJ)/drawgdi.o : $(SRC)/emu/rendersw.inc -ifndef USE_QTDEBUG # add debug-specific files OSDOBJS += \ - $(WINOBJ)/debugwin.o -endif + $(OSDOBJ)/modules/debugger/debugwin.o # add a stub resource file RESFILE = $(WINOBJ)/mame.res @@ -368,30 +393,28 @@ QT_INSTALL_HEADERS := $(shell qmake -query QT_INSTALL_HEADERS) QT_LIBS := -L$(shell qmake -query QT_INSTALL_LIBS) LIBS += $(QT_LIBS) -lqtmain -lQtGui4 -lQtCore4 INCPATH += -I$(QT_INSTALL_HEADERS)/QtCore -I$(QT_INSTALL_HEADERS)/QtGui -I$(QT_INSTALL_HEADERS) -SDLOBJ := $(WINOBJ)/../sdl -SDLSRC := $(WINSRC)/../sdl CFLAGS += -DUSE_QTDEBUG MOC = @moc -$(SDLOBJ)/%.moc.c: $(SDLSRC)/%.h +$(OSDOBJ)/%.moc.c: $(OSDSRC)/%.h $(MOC) $(INCPATH) $(DEFS) $< -o $@ OSDOBJS += \ - $(SDLOBJ)/debugqt.o \ - $(SDLOBJ)/debugqtview.o \ - $(SDLOBJ)/debugqtwindow.o \ - $(SDLOBJ)/debugqtlogwindow.o \ - $(SDLOBJ)/debugqtdasmwindow.o \ - $(SDLOBJ)/debugqtmainwindow.o \ - $(SDLOBJ)/debugqtmemorywindow.o \ - $(SDLOBJ)/debugqtbreakpointswindow.o \ - $(SDLOBJ)/debugqtview.moc.o \ - $(SDLOBJ)/debugqtwindow.moc.o \ - $(SDLOBJ)/debugqtlogwindow.moc.o \ - $(SDLOBJ)/debugqtdasmwindow.moc.o \ - $(SDLOBJ)/debugqtmainwindow.moc.o \ - $(SDLOBJ)/debugqtmemorywindow.moc.o \ - $(SDLOBJ)/debugqtbreakpointswindow.moc.o + $(OSDOBJ)/modules/debugger/debugqt.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtview.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtwindow.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtlogwindow.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtdasmwindow.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtmainwindow.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtmemorywindow.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtbreakpointswindow.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtview.moc.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtwindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtlogwindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtdasmwindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtmainwindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtmemorywindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/debugqtbreakpointswindow.moc.o endif #------------------------------------------------- diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index 938652f6215..c24112c2207 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -39,6 +39,16 @@ #include "debugger.h" #include "winfile.h" +#include "modules/sound/direct_sound.h" +#if (USE_SDL) +#include "modules/sound/sdl_sound.h" +#endif + +#include "modules/debugger/debugwin.h" + +#if (USE_QTDEBUG) +#include "modules/debugger/debugqt.h" +#endif #define DEBUG_SLOW_LOCKS 0 @@ -261,30 +271,17 @@ const options_entry windows_options::s_option_entries[] = { // debugging options { NULL, NULL, OPTION_HEADER, "WINDOWS DEBUGGING OPTIONS" }, - { WINOPTION_OSLOG, "0", OPTION_BOOLEAN, "output error.log data to the system debugger" }, - { WINOPTION_WATCHDOG ";wdog", "0", OPTION_INTEGER, "force the program to terminate if no updates within specified number of seconds" }, { WINOPTION_DEBUGGER_FONT ";dfont", "Lucida Console", OPTION_STRING,"specifies the font to use for debugging; defaults to Lucida Console" }, { WINOPTION_DEBUGGER_FONT_SIZE ";dfontsize", "9", OPTION_FLOAT, "specifies the font size to use for debugging; defaults to 9 pt" }, // performance options { NULL, NULL, OPTION_HEADER, "WINDOWS PERFORMANCE OPTIONS" }, { WINOPTION_PRIORITY "(-15-1)", "0", OPTION_INTEGER, "thread priority for the main game thread; range from -15 to 1" }, - { WINOPTION_MULTITHREADING ";mt", "0", OPTION_BOOLEAN, "enable multithreading; this enables rendering and blitting on a separate thread" }, - { WINOPTION_NUMPROCESSORS ";np", "auto", OPTION_STRING, "number of processors; this overrides the number the system reports" }, { WINOPTION_PROFILE, "0", OPTION_INTEGER, "enable profiling, specifying the stack depth to track" }, - { WINOPTION_BENCH, "0", OPTION_INTEGER, "benchmark for the given number of emulated seconds; implies -video none -nosound -nothrottle" }, // video options { NULL, NULL, OPTION_HEADER, "WINDOWS VIDEO OPTIONS" }, - { WINOPTION_VIDEO, "d3d", OPTION_STRING, "video output method: none, gdi, ddraw, or d3d" }, - { WINOPTION_NUMSCREENS "(1-4)", "1", OPTION_INTEGER, "number of screens to create; usually, you want just one" }, - { WINOPTION_WINDOW ";w", "0", OPTION_BOOLEAN, "enable window mode; otherwise, full screen mode is assumed" }, - { WINOPTION_MAXIMIZE ";max", "1", OPTION_BOOLEAN, "default to maximized windows; otherwise, windows will be minimized" }, - { WINOPTION_KEEPASPECT ";ka", "1", OPTION_BOOLEAN, "constrain to the proper aspect ratio" }, - { WINOPTION_UNEVENSTRETCH ";ues", "1", OPTION_BOOLEAN, "allow non-integer stretch factors" }, { WINOPTION_PRESCALE, "1", OPTION_INTEGER, "scale screen rendering by this amount in software" }, - { WINOPTION_WAITVSYNC ";vs", "0", OPTION_BOOLEAN, "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" }, - { WINOPTION_SYNCREFRESH ";srf", "0", OPTION_BOOLEAN, "enable using the start of VBLANK for throttling instead of the game time" }, { WINOPTION_MENU, "0", OPTION_BOOLEAN, "enable menu bar if available by UI implementation" }, // DirectDraw-specific options @@ -371,45 +368,13 @@ const options_entry windows_options::s_option_entries[] = { WINOPTION_BLOOM_LEVEL9_WEIGHT, "0.10", OPTION_FLOAT, "Bloom level 9 (.) weight" }, { WINOPTION_BLOOM_LEVEL10_WEIGHT, "0.09", OPTION_FLOAT, "Bloom level 10 (1x1 target) weight" }, - // per-window options - { NULL, NULL, OPTION_HEADER, "PER-WINDOW VIDEO OPTIONS" }, - { WINOPTION_SCREEN, "auto", OPTION_STRING, "explicit name of all screens; 'auto' here will try to make a best guess" }, - { WINOPTION_ASPECT ";screen_aspect", "auto", OPTION_STRING, "aspect ratio for all screens; 'auto' here will try to make a best guess" }, - { WINOPTION_RESOLUTION ";r", "auto", OPTION_STRING, "preferred resolution for all screens; format is x[@] or 'auto'" }, - { WINOPTION_VIEW, "auto", OPTION_STRING, "preferred view for all screens" }, - - { WINOPTION_SCREEN "0", "auto", OPTION_STRING, "explicit name of the first screen; 'auto' here will try to make a best guess" }, - { WINOPTION_ASPECT "0", "auto", OPTION_STRING, "aspect ratio of the first screen; 'auto' here will try to make a best guess" }, - { WINOPTION_RESOLUTION "0;r0", "auto", OPTION_STRING, "preferred resolution of the first screen; format is x[@] or 'auto'" }, - { WINOPTION_VIEW "0", "auto", OPTION_STRING, "preferred view for the first screen" }, - - { WINOPTION_SCREEN "1", "auto", OPTION_STRING, "explicit name of the second screen; 'auto' here will try to make a best guess" }, - { WINOPTION_ASPECT "1", "auto", OPTION_STRING, "aspect ratio of the second screen; 'auto' here will try to make a best guess" }, - { WINOPTION_RESOLUTION "1;r1", "auto", OPTION_STRING, "preferred resolution of the second screen; format is x[@] or 'auto'" }, - { WINOPTION_VIEW "1", "auto", OPTION_STRING, "preferred view for the second screen" }, - - { WINOPTION_SCREEN "2", "auto", OPTION_STRING, "explicit name of the third screen; 'auto' here will try to make a best guess" }, - { WINOPTION_ASPECT "2", "auto", OPTION_STRING, "aspect ratio of the third screen; 'auto' here will try to make a best guess" }, - { WINOPTION_RESOLUTION "2;r2", "auto", OPTION_STRING, "preferred resolution of the third screen; format is x[@] or 'auto'" }, - { WINOPTION_VIEW "2", "auto", OPTION_STRING, "preferred view for the third screen" }, - - { WINOPTION_SCREEN "3", "auto", OPTION_STRING, "explicit name of the fourth screen; 'auto' here will try to make a best guess" }, - { WINOPTION_ASPECT "3", "auto", OPTION_STRING, "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" }, - { WINOPTION_RESOLUTION "3;r3", "auto", OPTION_STRING, "preferred resolution of the fourth screen; format is x[@] or 'auto'" }, - { WINOPTION_VIEW "3", "auto", OPTION_STRING, "preferred view for the fourth screen" }, - // full screen options { NULL, NULL, OPTION_HEADER, "FULL SCREEN OPTIONS" }, { WINOPTION_TRIPLEBUFFER ";tb", "0", OPTION_BOOLEAN, "enable triple buffering" }, - { WINOPTION_SWITCHRES, "0", OPTION_BOOLEAN, "enable resolution switching" }, { WINOPTION_FULLSCREENBRIGHTNESS ";fsb(0.1-2.0)", "1.0", OPTION_FLOAT, "brightness value in full screen mode" }, { WINOPTION_FULLSCREENCONTRAST ";fsc(0.1-2.0)", "1.0", OPTION_FLOAT, "contrast value in full screen mode" }, { WINOPTION_FULLSCREENGAMMA ";fsg(0.1-3.0)", "1.0", OPTION_FLOAT, "gamma value in full screen mode" }, - // sound options - { NULL, NULL, OPTION_HEADER, "WINDOWS SOUND OPTIONS" }, - { WINOPTION_AUDIO_LATENCY "(1-5)", "2", OPTION_INTEGER, "set audio latency (increase to reduce glitches)" }, - // input options { NULL, NULL, OPTION_HEADER, "INPUT DEVICE OPTIONS" }, { WINOPTION_DUAL_LIGHTGUN ";dual", "0", OPTION_BOOLEAN, "enable dual lightgun input" }, @@ -467,6 +432,7 @@ int main(int argc, char *argv[]) { windows_options options; windows_osd_interface osd; + osd.register_options(options); cli_frontend frontend(options, osd); result = frontend.execute(argc, argv); } @@ -570,6 +536,45 @@ windows_osd_interface::~windows_osd_interface() } +//============================================================ +// video_register +//============================================================ + +void windows_osd_interface::video_register() +{ + video_options_add("gdi", NULL); + video_options_add("ddraw", NULL); + video_options_add("d3d", NULL); + //video_options_add("auto", NULL); // making d3d video default one +} + +//============================================================ +// sound_register +//============================================================ + +void windows_osd_interface::sound_register() +{ + sound_options_add("dsound", OSD_SOUND_DIRECT_SOUND); +#if (USE_SDL) + sound_options_add("sdl", OSD_SOUND_SDL); +#endif + sound_options_add("auto", OSD_SOUND_DIRECT_SOUND); // making Direct Sound audio default one +} + + +//============================================================ +// debugger_register +//============================================================ + +void windows_osd_interface::debugger_register() +{ + debugger_options_add("windows", OSD_DEBUGGER_WINDOWS); +#if (USE_QTDEBUG) + debugger_options_add("qt", OSD_DEBUGGER_QT); +#endif + debugger_options_add("auto", OSD_DEBUGGER_WINDOWS); // making windows debugger default one +} + //============================================================ // init //============================================================ @@ -588,8 +593,8 @@ void windows_osd_interface::init(running_machine &machine) if (bench > 0) { options.set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM, error_string); - options.set_value(OPTION_SOUND, false, OPTION_PRIORITY_MAXIMUM, error_string); - options.set_value(WINOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM, error_string); + options.set_value(OSDOPTION_SOUND, "none", OPTION_PRIORITY_MAXIMUM, error_string); + options.set_value(OSDOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM, error_string); options.set_value(OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM, error_string); assert(!error_string); } @@ -599,8 +604,8 @@ void windows_osd_interface::init(running_machine &machine) if (profile > 0) { options.set_value(OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM, error_string); - options.set_value(WINOPTION_MULTITHREADING, false, OPTION_PRIORITY_MAXIMUM, error_string); - options.set_value(WINOPTION_NUMPROCESSORS, 1, OPTION_PRIORITY_MAXIMUM, error_string); + options.set_value(OSDOPTION_MULTITHREADING, false, OPTION_PRIORITY_MAXIMUM, error_string); + options.set_value(OSDOPTION_NUMPROCESSORS, 1, OPTION_PRIORITY_MAXIMUM, error_string); assert(!error_string); } @@ -689,7 +694,7 @@ void windows_osd_interface::osd_exit() // cleanup sockets win_cleanup_sockets(); - osd_interface::exit_subsystems(); + osd_interface::osd_exit(); // take down the watchdog thread if it exists if (watchdog_thread != NULL) diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index 105c72586da..40cbf4fd1d5 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -15,28 +15,15 @@ //============================================================ // debugging options -#define WINOPTION_OSLOG "oslog" -#define WINOPTION_WATCHDOG "watchdog" #define WINOPTION_DEBUGGER_FONT "debugger_font" #define WINOPTION_DEBUGGER_FONT_SIZE "debugger_font_size" // performance options #define WINOPTION_PRIORITY "priority" -#define WINOPTION_MULTITHREADING "multithreading" -#define WINOPTION_NUMPROCESSORS "numprocessors" #define WINOPTION_PROFILE "profile" -#define WINOPTION_BENCH "bench" // video options -#define WINOPTION_VIDEO "video" -#define WINOPTION_NUMSCREENS "numscreens" -#define WINOPTION_WINDOW "window" -#define WINOPTION_MAXIMIZE "maximize" -#define WINOPTION_KEEPASPECT "keepaspect" -#define WINOPTION_UNEVENSTRETCH "unevenstretch" #define WINOPTION_PRESCALE "prescale" -#define WINOPTION_WAITVSYNC "waitvsync" -#define WINOPTION_SYNCREFRESH "syncrefresh" #define WINOPTION_MENU "menu" // DirectDraw-specific options @@ -111,22 +98,12 @@ #define WINOPTION_BLOOM_LEVEL9_WEIGHT "bloom_lvl9_weight" #define WINOPTION_BLOOM_LEVEL10_WEIGHT "bloom_lvl10_weight" -// per-window options -#define WINOPTION_SCREEN "screen" -#define WINOPTION_ASPECT "aspect" -#define WINOPTION_RESOLUTION "resolution" -#define WINOPTION_VIEW "view" - // full screen options #define WINOPTION_TRIPLEBUFFER "triplebuffer" -#define WINOPTION_SWITCHRES "switchres" #define WINOPTION_FULLSCREENBRIGHTNESS "full_screen_brightness" #define WINOPTION_FULLSCREENCONTRAST "full_screen_contrast" #define WINOPTION_FULLSCREENGAMMA "full_screen_gamma" -// sound options -#define WINOPTION_AUDIO_LATENCY "audio_latency" - // input options #define WINOPTION_DUAL_LIGHTGUN "dual_lightgun" @@ -143,28 +120,15 @@ public: windows_options(); // debugging options - bool oslog() const { return bool_value(WINOPTION_OSLOG); } - int watchdog() const { return int_value(WINOPTION_WATCHDOG); } const char *debugger_font() const { return value(WINOPTION_DEBUGGER_FONT); } float debugger_font_size() const { return float_value(WINOPTION_DEBUGGER_FONT_SIZE); } // performance options int priority() const { return int_value(WINOPTION_PRIORITY); } - bool multithreading() const { return bool_value(WINOPTION_MULTITHREADING); } - const char *numprocessors() const { return value(WINOPTION_NUMPROCESSORS); } int profile() const { return int_value(WINOPTION_PROFILE); } - int bench() const { return int_value(WINOPTION_BENCH); } // video options - const char *video() const { return value(WINOPTION_VIDEO); } - int numscreens() const { return int_value(WINOPTION_NUMSCREENS); } - bool window() const { return bool_value(WINOPTION_WINDOW); } - bool maximize() const { return bool_value(WINOPTION_MAXIMIZE); } - bool keep_aspect() const { return bool_value(WINOPTION_KEEPASPECT); } - bool uneven_stretch() const { return bool_value(WINOPTION_UNEVENSTRETCH); } int prescale() const { return int_value(WINOPTION_PRESCALE); } - bool wait_vsync() const { return bool_value(WINOPTION_WAITVSYNC); } - bool sync_refresh() const { return bool_value(WINOPTION_SYNCREFRESH); } bool menu() const { return bool_value(WINOPTION_MENU); } // DirectDraw-specific options @@ -239,26 +203,12 @@ public: const char *screen_phosphor() const { return value(WINOPTION_PHOSPHOR); } float screen_saturation() const { return float_value(WINOPTION_SATURATION); } - // per-window options - const char *screen() const { return value(WINOPTION_SCREEN); } - const char *aspect() const { return value(WINOPTION_ASPECT); } - const char *resolution() const { return value(WINOPTION_RESOLUTION); } - const char *view() const { return value(WINOPTION_VIEW); } - const char *screen(int index) const { astring temp; return value(temp.format("%s%d", WINOPTION_SCREEN, index)); } - const char *aspect(int index) const { astring temp; return value(temp.format("%s%d", WINOPTION_ASPECT, index)); } - const char *resolution(int index) const { astring temp; return value(temp.format("%s%d", WINOPTION_RESOLUTION, index)); } - const char *view(int index) const { astring temp; return value(temp.format("%s%d", WINOPTION_VIEW, index)); } - // full screen options bool triple_buffer() const { return bool_value(WINOPTION_TRIPLEBUFFER); } - bool switch_res() const { return bool_value(WINOPTION_SWITCHRES); } float full_screen_brightness() const { return float_value(WINOPTION_FULLSCREENBRIGHTNESS); } float full_screen_contrast() const { return float_value(WINOPTION_FULLSCREENCONTRAST); } float full_screen_gamma() const { return float_value(WINOPTION_FULLSCREENGAMMA); } - // sound options - int audio_latency() const { return int_value(WINOPTION_AUDIO_LATENCY); } - // input options bool dual_lightgun() const { return bool_value(WINOPTION_DUAL_LIGHTGUN); } @@ -295,16 +245,6 @@ public: 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); - virtual void debugger_update(); - virtual void debugger_exit(); - - // audio overridables - virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); - virtual void set_mastervolume(int attenuation); - // video overridables virtual void *get_slider_list(); @@ -316,8 +256,11 @@ public: 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 bool video_init(); - virtual bool sound_init(); + virtual void video_register(); + virtual void sound_register(); + virtual void debugger_register(); + + virtual bool video_init(); virtual bool input_init(); virtual void input_pause(); virtual void input_resume(); @@ -327,7 +270,6 @@ public: #endif virtual void video_exit(); - virtual void sound_exit(); virtual void input_exit(); virtual void output_exit(); #ifdef USE_NETWORK