diff options
| author | 2010-10-21 15:59:44 +0000 | |
|---|---|---|
| committer | 2010-10-21 15:59:44 +0000 | |
| commit | e4beed95a6b4191ea8ec415ccb8b2c0a36e9ecaa (patch) | |
| tree | 443aad796122599d6c892ff00e3fe4a846db01ce /src | |
| parent | f3be589604f81b0635b251d957bdeb7c616e5c4f (diff) | |
Create new class osd_interface to house OSD callbacks. Added new
module osdepend.c with default empty implementations. Changed
mame_execute() and cli_execute() to accept a reference to an
osd_interface which is provided by the caller.
Updated SDL and Windows OSD to create an osd_interface-derived
class and moved their OSD callbacks to be members.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emu/clifront.c | 4 | ||||
| -rw-r--r-- | src/emu/clifront.h | 2 | ||||
| -rw-r--r-- | src/emu/debug/debugcpu.c | 33 | ||||
| -rw-r--r-- | src/emu/debugger.c | 2 | ||||
| -rw-r--r-- | src/emu/debugint/debugint.c | 24 | ||||
| -rw-r--r-- | src/emu/debugint/debugint.h | 2 | ||||
| -rw-r--r-- | src/emu/emu.mak | 8 | ||||
| -rw-r--r-- | src/emu/inptport.c | 2 | ||||
| -rw-r--r-- | src/emu/machine.c | 5 | ||||
| -rw-r--r-- | src/emu/machine.h | 5 | ||||
| -rw-r--r-- | src/emu/mame.c | 4 | ||||
| -rw-r--r-- | src/emu/mame.h | 2 | ||||
| -rw-r--r-- | src/emu/sound.c | 10 | ||||
| -rw-r--r-- | src/emu/video.c | 2 | ||||
| -rw-r--r-- | src/osd/osdepend.c | 198 | ||||
| -rw-r--r-- | src/osd/osdepend.h | 165 | ||||
| -rw-r--r-- | src/osd/osdmini/minimain.c | 57 | ||||
| -rw-r--r-- | src/osd/sdl/debugwin.c | 32 | ||||
| -rw-r--r-- | src/osd/sdl/input.c | 4 | ||||
| -rw-r--r-- | src/osd/sdl/osdsdl.h | 32 | ||||
| -rw-r--r-- | src/osd/sdl/sdlmain.c | 62 | ||||
| -rw-r--r-- | src/osd/sdl/sound.c | 18 | ||||
| -rw-r--r-- | src/osd/sdl/video.c | 14 | ||||
| -rw-r--r-- | src/osd/windows/debugwin.c | 21 | ||||
| -rw-r--r-- | src/osd/windows/input.c | 4 | ||||
| -rw-r--r-- | src/osd/windows/sound.c | 10 | ||||
| -rw-r--r-- | src/osd/windows/video.c | 14 | ||||
| -rw-r--r-- | src/osd/windows/winmain.c | 76 | ||||
| -rw-r--r-- | src/osd/windows/winmain.h | 34 |
29 files changed, 528 insertions, 318 deletions
diff --git a/src/emu/clifront.c b/src/emu/clifront.c index 5e3a4e1f7ff..4cf32c954af 100644 --- a/src/emu/clifront.c +++ b/src/emu/clifront.c @@ -112,7 +112,7 @@ static const options_entry cli_options[] = command line interface -------------------------------------------------*/ -int cli_execute(int argc, char **argv, const options_entry *osd_options) +int cli_execute(int argc, char **argv, osd_interface &osd, const options_entry *osd_options) { core_options *options = NULL; const char *gamename_option; @@ -172,7 +172,7 @@ int cli_execute(int argc, char **argv, const options_entry *osd_options) } /* run the game */ - result = mame_execute(options); + result = mame_execute(osd, options); } catch (emu_fatalerror &fatal) { diff --git a/src/emu/clifront.h b/src/emu/clifront.h index f5498fb6329..111b21e5c3d 100644 --- a/src/emu/clifront.h +++ b/src/emu/clifront.h @@ -47,7 +47,7 @@ FUNCTION PROTOTYPES ***************************************************************************/ -int cli_execute(int argc, char **argv, const options_entry *osd_options); +int cli_execute(int argc, char **argv, osd_interface &osd, const options_entry *osd_options); /* informational functions */ int cli_info_listxml(core_options *options, const char *gamename); diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index 4802085c9d0..09d1acdee32 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -1916,7 +1916,8 @@ void device_debug::exception_hook(int exception) void device_debug::instruction_hook(offs_t curpc) { - debugcpu_private *global = m_device.machine->debugcpu_data; + running_machine &machine = *m_device.machine; + debugcpu_private *global = machine.debugcpu_data; // note that we are in the debugger code global->within_instruction_hook = true; @@ -1949,9 +1950,9 @@ void device_debug::instruction_hook(offs_t curpc) // update every 100 steps until we are within 200 of the end else if ((m_flags & DEBUG_FLAG_STEPPING_OUT) == 0 && (m_stepsleft < 200 || m_stepsleft % 100 == 0)) { - m_device.machine->debug_view().update_all(); - m_device.machine->debug_view().flush_osd_updates(); - debugger_refresh_display(m_device.machine); + machine.debug_view().update_all(); + machine.debug_view().flush_osd_updates(); + debugger_refresh_display(&machine); } } } @@ -1960,16 +1961,16 @@ void device_debug::instruction_hook(offs_t curpc) if (global->execution_state != EXECUTION_STATE_STOPPED && (m_flags & (DEBUG_FLAG_STOP_TIME | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_LIVE_BP)) != 0) { // see if we hit a target time - if ((m_flags & DEBUG_FLAG_STOP_TIME) != 0 && attotime_compare(timer_get_time(m_device.machine), m_stoptime) >= 0) + if ((m_flags & DEBUG_FLAG_STOP_TIME) != 0 && attotime_compare(timer_get_time(&machine), m_stoptime) >= 0) { - debug_console_printf(m_device.machine, "Stopped at time interval %.1g\n", attotime_to_double(timer_get_time(m_device.machine))); + debug_console_printf(&machine, "Stopped at time interval %.1g\n", attotime_to_double(timer_get_time(&machine))); global->execution_state = EXECUTION_STATE_STOPPED; } // check the temp running breakpoint and break if we hit it else if ((m_flags & DEBUG_FLAG_STOP_PC) != 0 && m_stopaddr == curpc) { - debug_console_printf(m_device.machine, "Stopped at temporary breakpoint %X on CPU '%s'\n", m_stopaddr, m_device.tag()); + debug_console_printf(&machine, "Stopped at temporary breakpoint %X on CPU '%s'\n", m_stopaddr, m_device.tag()); global->execution_state = EXECUTION_STATE_STOPPED; } @@ -1981,7 +1982,7 @@ void device_debug::instruction_hook(offs_t curpc) // if we are supposed to halt, do it now if (global->execution_state == EXECUTION_STATE_STOPPED) { - int firststop = true; + bool firststop = true; // load comments if we haven't yet if (!global->comments_loaded) @@ -1998,7 +1999,7 @@ void device_debug::instruction_hook(offs_t curpc) global->visiblecpu = &m_device; // update all views - m_device.machine->debug_view().update_all(); + machine.debug_view().update_all(); debugger_refresh_display(m_device.machine); // wait for the debugger; during this time, disable sound output @@ -2006,20 +2007,20 @@ void device_debug::instruction_hook(offs_t curpc) while (global->execution_state == EXECUTION_STATE_STOPPED) { // flush any pending updates before waiting again - m_device.machine->debug_view().flush_osd_updates(); + machine.debug_view().flush_osd_updates(); // clear the memory modified flag and wait global->memory_modified = false; - if (m_device.machine->debug_flags & DEBUG_FLAG_OSD_ENABLED) - osd_wait_for_debugger(&m_device, firststop); - else if (m_device.machine->debug_flags & DEBUG_FLAG_ENABLED) - debugint_wait_for_debugger(&m_device, firststop); + 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 if (global->memory_modified) { - m_device.machine->debug_view().update_all(DVT_DISASSEMBLY); + machine.debug_view().update_all(DVT_DISASSEMBLY); debugger_refresh_display(m_device.machine); } @@ -2027,7 +2028,7 @@ void device_debug::instruction_hook(offs_t curpc) process_source_file(m_device.machine); // if an event got scheduled, resume - if (m_device.machine->scheduled_event_pending()) + if (machine.scheduled_event_pending()) global->execution_state = EXECUTION_STATE_RUNNING; } sound_mute(m_device.machine, false); diff --git a/src/emu/debugger.c b/src/emu/debugger.c index 1572b5db6ea..c1ff23863aa 100644 --- a/src/emu/debugger.c +++ b/src/emu/debugger.c @@ -92,7 +92,7 @@ void debugger_init(running_machine *machine) machine->add_logerror_callback(debug_errorlog_write_line); /* initialize osd debugger features */ - osd_init_debugger(machine); + machine->osd().init_debugger(); } } diff --git a/src/emu/debugint/debugint.c b/src/emu/debugint/debugint.c index 918d8dd5335..54973eb082f 100644 --- a/src/emu/debugint/debugint.c +++ b/src/emu/debugint/debugint.c @@ -1439,7 +1439,7 @@ static void update_views(void) } -void debugint_wait_for_debugger(running_device *device, int firststop) +void debugint_wait_for_debugger(running_device &device, bool firststop) { if (firststop && list == NULL) @@ -1447,28 +1447,28 @@ void debugint_wait_for_debugger(running_device *device, int firststop) DView *dv; render_target *target; - target = &device->machine->render().ui_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 = 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); + 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(); + dv->editor.container = &device.machine->render().ui_container(); set_focus_view(dv); } - followers_set_cpu(device); + followers_set_cpu(&device); - //ui_update_and_render(device->machine, &device->machine->render().ui_container()()); + //ui_update_and_render(device.machine, &device.machine->render().ui_container()()); update_views(); - osd_update(device->machine, FALSE); - handle_menus(device->machine); - handle_mouse(device->machine); + device.machine->osd().update(false); + handle_menus(device.machine); + handle_mouse(device.machine); //osd_sleep(osd_ticks_per_second()/60); } diff --git a/src/emu/debugint/debugint.h b/src/emu/debugint/debugint.h index 88b55608657..5964ee83caa 100644 --- a/src/emu/debugint/debugint.h +++ b/src/emu/debugint/debugint.h @@ -39,7 +39,7 @@ void debugint_init(running_machine *machine); /* process events for internal debugger */ -void debugint_wait_for_debugger(running_device *device, int firststop); +void debugint_wait_for_debugger(running_device &device, bool firststop); /* update the internal debugger during a game */ void debugint_update_during_game(running_machine *machine); diff --git a/src/emu/emu.mak b/src/emu/emu.mak index eee48ed4b45..6e48b248a00 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -30,6 +30,11 @@ OBJDIRS += \ $(EMUOBJ)/layout \ $(EMUOBJ)/video \ +OSDSRC = $(SRC)/osd +OSDOBJ = $(OBJ)/osd + +OBJDIRS += \ + $(OSDOBJ) #------------------------------------------------- @@ -110,7 +115,8 @@ EMUOBJS = \ $(EMUOBJ)/debug/express.o \ $(EMUOBJ)/debug/textbuf.o \ $(EMUOBJ)/debugint/debugint.o \ - $(EMUOBJ)/profiler.o + $(EMUOBJ)/profiler.o \ + $(OSDOBJ)/osdepend.o EMUSOUNDOBJS = \ $(EMUOBJ)/sound/filter.o \ diff --git a/src/emu/inptport.c b/src/emu/inptport.c index f8754de707d..6bba1595049 100644 --- a/src/emu/inptport.c +++ b/src/emu/inptport.c @@ -1881,7 +1881,7 @@ static void init_port_types(running_machine *machine) } /* ask the OSD to customize the list */ - osd_customize_input_type_list(&portdata->typestatelist->typedesc); + machine->osd().customize_input_type_list(&portdata->typestatelist->typedesc); /* now iterate over the OSD-modified types */ for (curtype = portdata->typestatelist; curtype != NULL; curtype = curtype->next) diff --git a/src/emu/machine.c b/src/emu/machine.c index 4dd78aca057..1843c0e25a7 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -138,7 +138,7 @@ static char giant_string_buffer[65536] = { 0 }; // running_machine - constructor //------------------------------------------------- -running_machine::running_machine(const machine_config &_config, core_options &options, bool exit_to_game_select) +running_machine::running_machine(const machine_config &_config, osd_interface &osd, core_options &options, bool exit_to_game_select) : m_regionlist(m_respool), m_devicelist(m_respool), config(&_config), @@ -176,6 +176,7 @@ running_machine::running_machine(const machine_config &_config, core_options &op m_logerror_list(NULL), m_scheduler(*this), m_options(options), + m_osd(osd), m_basename(_config.gamedrv().name), m_current_phase(MACHINE_PHASE_PREINIT), m_paused(false), @@ -284,7 +285,7 @@ void running_machine::start() m_soft_reset_timer = timer_alloc(this, static_soft_reset, NULL); // init the osd layer - osd_init(this); + m_osd.init(*this); // initialize the base time (needed for doing record/playback) time(&m_base_time); diff --git a/src/emu/machine.h b/src/emu/machine.h index fb01cdb434a..cd7ee2d7056 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -182,6 +182,7 @@ class gfx_element; class colortable_t; class debug_view_manager; class render_manager; +class osd_interface; typedef struct _mame_private mame_private; typedef struct _cpuexec_private cpuexec_private; @@ -337,7 +338,7 @@ class running_machine : public bindable_object public: // construction/destruction - running_machine(const machine_config &config, core_options &options, bool exit_to_game_select = false); + running_machine(const machine_config &config, osd_interface &osd, core_options &options, bool exit_to_game_select = false); ~running_machine(); // fetch items by name @@ -360,6 +361,7 @@ public: bool new_driver_pending() const { return (m_new_driver_pending != NULL); } const char *new_driver_name() const { return m_new_driver_pending->name; } device_scheduler &scheduler() { return m_scheduler; } + osd_interface &osd() const { return m_osd; } // immediate operations int run(bool firstrun); @@ -493,6 +495,7 @@ private: device_scheduler m_scheduler; // scheduler object core_options & m_options; + osd_interface & m_osd; astring m_context; // context string astring m_basename; // basename used for game-related paths diff --git a/src/emu/mame.c b/src/emu/mame.c index 166ed0705c7..fa98cf081b6 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -149,7 +149,7 @@ int mame_is_valid_machine(running_machine *machine) mame_execute - run the core emulation -------------------------------------------------*/ -int mame_execute(core_options *options) +int mame_execute(osd_interface &osd, core_options *options) { bool firstgame = true; bool firstrun = true; @@ -192,7 +192,7 @@ int mame_execute(core_options *options) const machine_config *config = global_alloc(machine_config(*driver)); // create the machine structure and driver - running_machine *machine = global_alloc(running_machine(*config, *options, started_empty)); + running_machine *machine = global_alloc(running_machine(*config, osd, *options, started_empty)); // looooong term: remove this global_machine = machine; diff --git a/src/emu/mame.h b/src/emu/mame.h index e339c93b1d9..a971d4cb21e 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -96,7 +96,7 @@ extern const char build_version[]; /* ----- core system management ----- */ /* execute as configured by the OPTION_GAMENAME option on the specified options */ -int mame_execute(core_options *options); +int mame_execute(osd_interface &osd, core_options *options); /* accesses the core_options for the currently running emulation */ core_options *mame_options(void); diff --git a/src/emu/sound.c b/src/emu/sound.c index bc4a322054b..9917678a368 100644 --- a/src/emu/sound.c +++ b/src/emu/sound.c @@ -212,14 +212,14 @@ static void sound_pause(running_machine &machine) { sound_private *global = machine.sound_data; global->muted |= 0x02; - osd_set_mastervolume(global->muted ? -32 : global->attenuation); + machine.osd().set_mastervolume(global->muted ? -32 : global->attenuation); } static void sound_resume(running_machine &machine) { sound_private *global = machine.sound_data; global->muted &= ~0x02; - osd_set_mastervolume(global->muted ? -32 : global->attenuation); + machine.osd().set_mastervolume(global->muted ? -32 : global->attenuation); } @@ -235,7 +235,7 @@ void sound_mute(running_machine *machine, int mute) global->muted |= 0x01; else global->muted &= ~0x01; - osd_set_mastervolume(global->muted ? -32 : global->attenuation); + machine->osd().set_mastervolume(global->muted ? -32 : global->attenuation); } @@ -247,7 +247,7 @@ void sound_set_attenuation(running_machine *machine, int attenuation) { sound_private *global = machine->sound_data; global->attenuation = attenuation; - osd_set_mastervolume(global->muted ? -32 : global->attenuation); + machine->osd().set_mastervolume(global->muted ? -32 : global->attenuation); } @@ -408,7 +408,7 @@ static TIMER_CALLBACK( sound_update ) if (finalmix_offset > 0) { if (!global->nosound_mode) - osd_update_audio_stream(machine, finalmix, finalmix_offset / 2); + machine->osd().update_audio_stream(finalmix, finalmix_offset / 2); video_avi_add_sound(machine, finalmix, finalmix_offset / 2); if (global->wavfile != NULL) wav_add_data_16(global->wavfile, finalmix, finalmix_offset); diff --git a/src/emu/video.c b/src/emu/video.c index dce8c1239ec..ee45042a9e1 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -467,7 +467,7 @@ void video_frame_update(running_machine *machine, int debug) /* ask the OSD to update */ g_profiler.start(PROFILER_BLIT); - osd_update(machine, !debug && skipped_it); + machine->osd().update(!debug && skipped_it); g_profiler.stop(); /* perform tasks for this frame */ diff --git a/src/osd/osdepend.c b/src/osd/osdepend.c new file mode 100644 index 00000000000..7ea9dd57d2e --- /dev/null +++ b/src/osd/osdepend.c @@ -0,0 +1,198 @@ +/*************************************************************************** + + osdepend.c + + OS-dependent code interface. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +*******************************************************************c********/ + +#include "osdepend.h" + + +//------------------------------------------------- +// osd_interface - constructor +//------------------------------------------------- + +osd_interface::osd_interface() + : m_machine(NULL) +{ +} + + +//------------------------------------------------- +// osd_interface - destructor +//------------------------------------------------- + +osd_interface::~osd_interface() +{ +} + + +//------------------------------------------------- +// init - initialize the OSD system. +//------------------------------------------------- + +void osd_interface::init(running_machine &machine) +{ + // + // This function is responsible for initializing the OSD-specific + // video and input functionality, and registering that functionality + // with the MAME core. + // + // In terms of video, this function is expected to create one or more + // render_targets that will be used by the MAME core to provide graphics + // data to the system. Although it is possible to do this later, the + // assumption in the MAME core is that the user interface will be + // visible starting at init() time, so you will have some work to + // do to avoid these assumptions. + // + // In terms of input, this function is expected to enumerate all input + // devices available and describe them to the MAME core by adding + // input devices and their attached items (buttons/axes) via the input + // system. + // + // Beyond these core responsibilities, init() should also initialize + // any other OSD systems that require information about the current + // running_machine. + // + // This callback is also the last opportunity to adjust the options + // before they are consumed by the rest of the core. + // + // Future work/changes: + // + // Audio initialization may eventually move into here as well, + // instead of relying on independent callbacks from each system. + // + + m_machine = &machine; +} + + +//------------------------------------------------- +// update - periodic system update +//------------------------------------------------- + +void osd_interface::update(bool skip_redraw) +{ + // + // This method is called periodically to flush video updates to the + // screen, and also to allow the OSD a chance to update other systems + // on a regular basis. In general this will be called at the frame + // rate of the system being run; however, it may be called at more + // irregular intervals in some circumstances (e.g., multi-screen games + // or games with asynchronous updates). + // +} + + +//------------------------------------------------- +// init_debugger - perform debugger-specific +// initialization +//------------------------------------------------- + +void osd_interface::init_debugger() +{ + // + // Unlike init() above, this method is only called if the debugger + // is active. This gives any OSD debugger interface a chance to + // create all of its structures. + // +} + + +//------------------------------------------------- +// wait_for_debugger - wait for a debugger +// command to be processed +//------------------------------------------------- + +void osd_interface::wait_for_debugger(device_t &device, bool firststop) +{ + // + // When implementing an OSD-driver debugger, this method should be + // overridden to wait for input, process it, and return. It will be + // called repeatedly until a command is issued that resumes + // execution. + // +} + + +//------------------------------------------------- +// update_audio_stream - update the stereo audio +// stream +//------------------------------------------------- + +void osd_interface::update_audio_stream(const INT16 *buffer, int samples_this_frame) +{ + // + // This method is called whenever the system has new audio data to stream. + // It provides an array of stereo samples in L-R order which should be + // output at the configured sample_rate. + // +} + + +//------------------------------------------------- +// set_mastervolume - set the system volume +//------------------------------------------------- + +void osd_interface::set_mastervolume(int attenuation) +{ + // + // Attenuation is the attenuation in dB (a negative number). + // To convert from dB to a linear volume scale do the following: + // volume = MAX_VOLUME; + // while (attenuation++ < 0) + // volume /= 1.122018454; // = (10 ^ (1/20)) = 1dB + // +} + + +//------------------------------------------------- +// customize_input_type_list - provide OSD +// additions/modifications to the input list +//------------------------------------------------- + +void osd_interface::customize_input_type_list(input_type_desc *typelist) +{ + // + // inptport.c defines some general purpose defaults for key and joystick bindings. + // They may be further adjusted by the OS dependent code to better match the + // available keyboard, e.g. one could map pause to the Pause key instead of P, or + // snapshot to PrtScr instead of F12. Of course the user can further change the + // settings to anything he/she likes. + // + // This function is called on startup, before reading the configuration from disk. + // Scan the list, and change the keys/joysticks you want. + // +} diff --git a/src/osd/osdepend.h b/src/osd/osdepend.h index 467642bb8f6..a344482d4f1 100644 --- a/src/osd/osdepend.h +++ b/src/osd/osdepend.h @@ -35,30 +35,6 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**************************************************************************** - - The prototypes in this file describe the interfaces that the MAME core - relies upon to interact with the outside world. They are broken out into - several categories. - - The general flow for an OSD port of MAME is as follows: - - - parse the command line or display the frontend - - call run_game (mame.c) with the index in the driver list of - the game selected - - osd_init() is called shortly afterwards; at this time, you are - expected to set up the display system and create render_targets - - the input system will call osd_get_code_list() - - the input port system will call osd_customize_inputport_list() - - the sound system will call osd_start_audio_stream() - - while the game runs, osd_update() will be called periodically - - when the game exits, we return from run_game() - - the OSD layer is now in control again - - This process is expected to be in flux over the next several versions - (this was written during 0.109u2 development) as some of the OSD - responsibilities are pushed into the core. - *******************************************************************c********/ #pragma once @@ -70,114 +46,47 @@ #include "osdcore.h" +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// forward references class input_type_desc; class device_t; -/*----------------------------------------------------------------------------- - osd_init: initialize the OSD system. - - Parameters: - - machine - pointer to a structure that contains parameters for the - current "machine" - - Return value: - - None - - Notes: - - This function is responsible for initializing the OSD-specific - video and input functionality, and registering that functionality - with the MAME core. - - In terms of video, this function is expected to create one or more - render_targets that will be used by the MAME core to provide graphics - data to the system. Although it is possible to do this later, the - assumption in the MAME core is that the user interface will be - visible starting at osd_init() time, so you will have some work to - do to avoid these assumptions. - - In terms of input, this function is expected to enumerate all input - devices available and describe them to the MAME core by adding - input devices and their attached items (buttons/axes) via the input - system. - - Beyond these core responsibilities, osd_init() should also initialize - any other OSD systems that require information about the current - running_machine. - - This callback is also the last opportunity to adjust the options - before they are consumed by the rest of the core. - - Note that there is no corresponding osd_exit(). Rather, like most - systems in MAME, you can register an exit callback via the - add_notifier() function in mame.c. - - Also note that there is no return value. If you need to report a - fatal error, use the fatalerror() function with a friendly message - to the user. - - Future work/changes: - - Audio initialization may eventually move into here as well, - instead of relying on independent callbacks from each system. ------------------------------------------------------------------------------*/ -void osd_init(running_machine *machine); - -void osd_init_debugger(running_machine *machine); -void osd_wait_for_debugger(device_t *device, int firststop); - - - -/****************************************************************************** - - Display - -******************************************************************************/ - -void osd_update(running_machine *machine, int skip_redraw); - - - - -/****************************************************************************** - - Sound - -******************************************************************************/ - -void osd_update_audio_stream(running_machine *machine, INT16 *buffer, int samples_this_frame); - -/* - control master volume. attenuation is the attenuation in dB (a negative - number). To convert from dB to a linear volume scale do the following: - volume = MAX_VOLUME; - while (attenuation++ < 0) - volume /= 1.122018454; // = (10 ^ (1/20)) = 1dB -*/ -void osd_set_mastervolume(int attenuation); - - - -/****************************************************************************** - - Controls - -******************************************************************************/ - -/* - inptport.c defines some general purpose defaults for key and joystick bindings. - They may be further adjusted by the OS dependent code to better match the - available keyboard, e.g. one could map pause to the Pause key instead of P, or - snapshot to PrtScr instead of F12. Of course the user can further change the - settings to anything he/she likes. - This function is called on startup, before reading the configuration from disk. - Scan the list, and change the keys/joysticks you want. -*/ -void osd_customize_input_type_list(input_type_desc *typelist); - +// ======================> osd_interface + +// description of the currently-running machine +class osd_interface +{ +public: + // construction/destruction + osd_interface(); + virtual ~osd_interface(); + + // getters + running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } + + // general overridables + virtual void init(running_machine &machine); + virtual void update(bool skip_redraw); + + // debugger overridables + virtual void init_debugger(); + virtual void wait_for_debugger(device_t &device, bool firststop); + + // audio overridables + virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); + virtual void set_mastervolume(int attenuation); + + // input overridables + virtual void customize_input_type_list(input_type_desc *typelist); + +private: + // internal state + running_machine * m_machine; +}; #endif /* __OSDEPEND_H__ */ diff --git a/src/osd/osdmini/minimain.c b/src/osd/osdmini/minimain.c index 1c8d49c0884..af92a78e197 100644 --- a/src/osd/osdmini/minimain.c +++ b/src/osd/osdmini/minimain.c @@ -99,20 +99,23 @@ int main(int argc, char *argv[]) //============================================================ -// osd_init +// init //============================================================ -void osd_init(running_machine *machine) +void mini_osd_interface::init(running_machine &machine) { + // call our parent + osd_interface::init(machine); + // initialize the video system by allocating a rendering target - our_target = machine->render().target_alloc(); + our_target = machine.render().target_alloc(); // nothing yet to do to initialize sound, since we don't have any - // sound updates are handled by osd_update_audio_stream() below + // sound updates are handled by update_audio_stream() below // initialize the input system by adding devices // let's pretend like we have a keyboard device - keyboard_device = input_device_add(machine, DEVICE_CLASS_KEYBOARD, "Keyboard", NULL); + keyboard_device = input_device_add(&machine, DEVICE_CLASS_KEYBOARD, "Keyboard", NULL); if (keyboard_device == NULL) fatalerror("Error creating keyboard device"); @@ -134,46 +137,26 @@ void osd_init(running_machine *machine) //============================================================ -// osd_init_debugger -//============================================================ - -void osd_init_debugger(running_machine *machine) -{ -} - - -//============================================================ -// osd_wait_for_debugger -//============================================================ - -void osd_wait_for_debugger(running_device *device, int firststop) -{ - // we don't have a debugger, so we just return here -} - - -//============================================================ // osd_update //============================================================ -void osd_update(running_machine *machine, int skip_redraw) +void mini_osd_interface::update(bool skip_redraw) { - const render_primitive_list *primlist; - int minwidth, minheight; - // get the minimum width/height for the current layout + int minwidth, minheight; our_target->compute_minimum_size(minwidth, minheight); // make that the size of our target our_target->render_target_set_bounds(minwidth, minheight); // get the list of primitives for the target at the current size - primlist = our_target->get_primitives(); + const render_primitive_list *primlist = our_target->get_primitives(); // lock them, and then render them - osd_lock_acquire(primlist->lock); + primlist->acquire_locK(); + // do the drawing here - osd_lock_release(primlist->lock); + primlist->release_lock(); // after 5 seconds, exit if (attotime_compare(timer_get_time(machine), attotime_make(5, 0)) > 0) @@ -182,10 +165,10 @@ void osd_update(running_machine *machine, int skip_redraw) //============================================================ -// osd_update_audio_stream +// update_audio_stream //============================================================ -void osd_update_audio_stream(running_machine *machine, INT16 *buffer, int samples_this_frame) +void mini_osd_interface::update_audio_stream(const INT16 *buffer, int samples_this_frame) { // if we had actual sound output, we would copy the // interleaved stereo samples to our sound stream @@ -193,10 +176,10 @@ void osd_update_audio_stream(running_machine *machine, INT16 *buffer, int sample //============================================================ -// osd_set_mastervolume +// set_mastervolume //============================================================ -void osd_set_mastervolume(int attenuation) +void mini_osd_interface::set_mastervolume(int attenuation) { // if we had actual sound output, we would adjust the global // volume in response to this function @@ -204,10 +187,10 @@ void osd_set_mastervolume(int attenuation) //============================================================ -// osd_customize_input_type_list +// customize_input_type_list //============================================================ -void osd_customize_input_type_list(input_type_desc *typelist) +void mini_osd_interface::customize_input_type_list(input_type_desc *typelist) { // This function is called on startup, before reading the // configuration from disk. Scan the list, and change the diff --git a/src/osd/sdl/debugwin.c b/src/osd/sdl/debugwin.c index 61802218b5f..97c90a1b168 100644 --- a/src/osd/sdl/debugwin.c +++ b/src/osd/sdl/debugwin.c @@ -537,21 +537,21 @@ static void configuration_save(running_machine *machine, int config_type, xml_da //============================================================ -// osd_init_debugger +// sdl_osd_interface::init_debugger //============================================================ -void osd_init_debugger(running_machine *machine) +void sdl_osd_interface::init_debugger() { /* register callbacks */ - config_register(machine, "debugger", configuration_load, configuration_save); + config_register(&machine(), "debugger", configuration_load, configuration_save); } //============================================================ -// osd_wait_for_debugger +// wait_for_debugger //============================================================ -void osd_wait_for_debugger(running_device *device, int firststop) +void sdl_osd_interface::wait_for_debugger(running_device &device, bool firststop) { win_i *dmain = get_first_win_i(WIN_TYPE_MAIN); @@ -560,7 +560,7 @@ void osd_wait_for_debugger(running_device *device, int firststop) { // GTK init should probably be done earlier gtk_init(0, 0); - debugmain_init(device->machine); + debugmain_init(&machine()); // Resize the main window for (int i = 0; i < windowStateCount; i++) @@ -580,9 +580,9 @@ void osd_wait_for_debugger(running_device *device, int firststop) switch (windowStateArray[i].type) { - case WIN_TYPE_MEMORY: memorywin_new(device->machine); break; - case WIN_TYPE_DISASM: disasmwin_new(device->machine); break; - case WIN_TYPE_LOG: logwin_new(device->machine); break; + case WIN_TYPE_MEMORY: memorywin_new(&machine()); break; + case WIN_TYPE_DISASM: disasmwin_new(&machine()); break; + case WIN_TYPE_LOG: logwin_new(&machine()); break; default: break; } @@ -592,7 +592,7 @@ void osd_wait_for_debugger(running_device *device, int firststop) } // update the views in the console to reflect the current CPU - debugmain_set_cpu(device); + debugmain_set_cpu(&device); debugwin_show(1); gtk_main_iteration(); @@ -1269,17 +1269,23 @@ on_memoryview_key_press_event (GtkWidget *widget, #else +#include <SDL/SDL.h> +#include <SDL/SDL_version.h> + #include "emu.h" +#include "osdepend.h" +#include "osdsdl.h" -// win32 stubs for linking -void osd_init_debugger(running_machine *machine) + // win32 stubs for linking +void sdl_osd_interface::init_debugger() { } -void osd_wait_for_debugger(running_device *device, int firststop) +void sdl_osd_interface::wait_for_debugger(running_device &device, bool firststop) { } +// win32 stubs for linking void debugwin_update_during_game(running_machine *machine) { } diff --git a/src/osd/sdl/input.c b/src/osd/sdl/input.c index 8c6ea4a648f..caecdb7c172 100644 --- a/src/osd/sdl/input.c +++ b/src/osd/sdl/input.c @@ -1586,10 +1586,10 @@ int sdlinput_should_hide_mouse(running_machine *machine) //============================================================ -// osd_customize_inputport_list +// customize_input_type_list //============================================================ -void osd_customize_input_type_list(input_type_desc *typelist) +void sdl_osd_interface::customize_input_type_list(input_type_desc *typelist) { int mameid_code ,ui_code; input_type_desc *typedesc; diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index 617987fa14a..5ff61a4c9f3 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -117,6 +117,38 @@ //============================================================ +// TYPE DEFINITIONS +//============================================================ + +class sdl_osd_interface : public osd_interface +{ +public: + // construction/destruction + sdl_osd_interface(); + virtual ~sdl_osd_interface(); + + // general overridables + virtual void init(running_machine &machine); + virtual void update(bool skip_redraw); + + // debugger overridables + virtual void init_debugger(); + virtual void wait_for_debugger(device_t &device, bool firststop); + + // audio overridables + virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); + virtual void set_mastervolume(int attenuation); + + // input overridables + virtual void customize_input_type_list(input_type_desc *typelist); + +private: + static void osd_exit(running_machine &machine); +}; + + + +//============================================================ // sound.c //============================================================ diff --git a/src/osd/sdl/sdlmain.c b/src/osd/sdl/sdlmain.c index 011748cd686..1a7c8761d88 100644 --- a/src/osd/sdl/sdlmain.c +++ b/src/osd/sdl/sdlmain.c @@ -303,7 +303,10 @@ int main(int argc, char *argv[]) } #endif - res = cli_execute(argc, argv, mame_sdl_options); + { + sdl_osd_interface osd; + res = cli_execute(argc, argv, osd, mame_sdl_options); + } #ifdef MALLOC_DEBUG { @@ -334,10 +337,28 @@ static void output_oslog(running_machine &machine, const char *buffer) //============================================================ +// constructor +//============================================================ + +sdl_osd_interface::sdl_osd_interface() +{ +} + + +//============================================================ +// destructor +//============================================================ + +sdl_osd_interface::~sdl_osd_interface() +{ +} + + +//============================================================ // osd_exit //============================================================ -static void osd_exit(running_machine &machine) +void sdl_osd_interface::osd_exit(running_machine &machine) { if (!SDLMAME_INIT_IN_WORKER_THREAD) @@ -462,22 +483,25 @@ static void osd_sdl_info(void) //============================================================ -// osd_init +// init //============================================================ -void osd_init(running_machine *machine) +void sdl_osd_interface::init(running_machine &machine) { + // call our parent + osd_interface::init(machine); + const char *stemp; // Some driver options - must be before audio init! - stemp = options_get_string(machine->options(), SDLOPTION_AUDIODRIVER); + stemp = options_get_string(machine.options(), SDLOPTION_AUDIODRIVER); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) { mame_printf_verbose("Setting SDL audiodriver '%s' ...\n", stemp); osd_setenv(SDLENV_AUDIODRIVER, stemp, 1); } - stemp = options_get_string(machine->options(), SDLOPTION_VIDEODRIVER); + stemp = options_get_string(machine.options(), SDLOPTION_VIDEODRIVER); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) { mame_printf_verbose("Setting SDL videodriver '%s' ...\n", stemp); @@ -486,7 +510,7 @@ void osd_init(running_machine *machine) if (SDL_VERSION_ATLEAST(1,3,0)) { - stemp = options_get_string(machine->options(), SDLOPTION_RENDERDRIVER); + stemp = options_get_string(machine.options(), SDLOPTION_RENDERDRIVER); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) { mame_printf_verbose("Setting SDL renderdriver '%s' ...\n", stemp); @@ -499,7 +523,7 @@ void osd_init(running_machine *machine) */ /* FIXME: move lib loading code from drawogl.c here */ - stemp = options_get_string(machine->options(), SDLOPTION_GL_LIB); + stemp = options_get_string(machine.options(), SDLOPTION_GL_LIB); if (stemp != NULL && strcmp(stemp, SDLOPTVAL_AUTO) != 0) { osd_setenv("SDL_VIDEO_GL_DRIVER", stemp, 1); @@ -507,7 +531,7 @@ void osd_init(running_machine *machine) } /* get number of processors */ - stemp = options_get_string(machine->options(), SDLOPTION_NUMPROCESSORS); + stemp = options_get_string(machine.options(), SDLOPTION_NUMPROCESSORS); sdl_num_processors = 0; @@ -536,35 +560,35 @@ void osd_init(running_machine *machine) osd_sdl_info(); } // must be before sdlvideo_init! - machine->add_notifier(MACHINE_NOTIFY_EXIT, osd_exit); + machine.add_notifier(MACHINE_NOTIFY_EXIT, osd_exit); defines_verbose(); if (!SDLMAME_HAS_DEBUGGER) - if (machine->debug_flags & DEBUG_FLAG_OSD_ENABLED) + if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) { mame_printf_error("sdlmame: -debug not supported on X11-less builds\n\n"); - osd_exit(*machine); + osd_exit(machine); exit(-1); } - if (sdlvideo_init(machine)) + if (sdlvideo_init(&machine)) { - osd_exit(*machine); + osd_exit(machine); mame_printf_error("sdlvideo_init: Initialization failed!\n\n\n"); fflush(stderr); fflush(stdout); exit(-1); } - sdlinput_init(machine); + sdlinput_init(&machine); - sdlaudio_init(machine); + sdlaudio_init(&machine); - sdloutput_init(machine); + sdloutput_init(&machine); - if (options_get_bool(machine->options(), SDLOPTION_OSLOG)) - machine->add_logerror_callback(output_oslog); + if (options_get_bool(machine.options(), SDLOPTION_OSLOG)) + machine.add_logerror_callback(output_oslog); #if (SDL_VERSION_ATLEAST(1,3,0)) SDL_EventState(SDL_TEXTINPUT, SDL_TRUE); diff --git a/src/osd/sdl/sound.c b/src/osd/sdl/sound.c index bcb734d7e97..b4bf8b38368 100644 --- a/src/osd/sdl/sound.c +++ b/src/osd/sdl/sound.c @@ -95,7 +95,7 @@ void sdlaudio_init(running_machine *machine) machine->add_notifier(MACHINE_NOTIFY_EXIT, sdl_cleanup_audio); // set the startup volume - osd_set_mastervolume(attenuation); + machine->osd().set_mastervolume(attenuation); } return; } @@ -197,7 +197,7 @@ static void unlock_buffer(void) // Apply attenuation //============================================================ -static void att_memcpy(void *dest, INT16 *data, int bytes_to_copy) +static void att_memcpy(void *dest, const INT16 *data, int bytes_to_copy) { int level= (int) (pow(10.0, (float) attenuation / 20.0) * 128.0); INT16 *d = (INT16 *) dest; @@ -213,7 +213,7 @@ static void att_memcpy(void *dest, INT16 *data, int bytes_to_copy) // copy_sample_data //============================================================ -static void copy_sample_data(INT16 *data, int bytes_to_copy) +static void copy_sample_data(const INT16 *data, int bytes_to_copy) { void *buffer1, *buffer2 = (void *)NULL; long length1, length2; @@ -258,13 +258,13 @@ static void copy_sample_data(INT16 *data, int bytes_to_copy) //============================================================ -// osd_update_audio_stream +// update_audio_stream //============================================================ -void osd_update_audio_stream(running_machine *machine, INT16 *buffer, int samples_this_frame) +void sdl_osd_interface::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 (machine().sample_rate != 0 && stream_buffer) { int bytes_this_frame = samples_this_frame * sizeof(INT16) * 2; int play_position, write_position, stream_in; @@ -272,7 +272,7 @@ void osd_update_audio_stream(running_machine *machine, INT16 *buffer, int sample play_position = stream_playpos; - write_position = stream_playpos + ((machine->sample_rate / 50) * sizeof(INT16) * 2); + write_position = stream_playpos + ((machine().sample_rate / 50) * sizeof(INT16) * 2); orig_write = write_position; if (!stream_in_initialized) @@ -340,10 +340,10 @@ void osd_update_audio_stream(running_machine *machine, INT16 *buffer, int sample //============================================================ -// osd_set_mastervolume +// set_mastervolume //============================================================ -void osd_set_mastervolume(int _attenuation) +void sdl_osd_interface::set_mastervolume(int _attenuation) { // clamp the attenuation to 0-32 range if (_attenuation > 0) diff --git a/src/osd/sdl/video.c b/src/osd/sdl/video.c index 72ba0067739..28d712dcf93 100644 --- a/src/osd/sdl/video.c +++ b/src/osd/sdl/video.c @@ -326,10 +326,10 @@ sdl_monitor_info *sdlvideo_monitor_from_handle(UINT32 hmonitor) //============================================================ -// osd_update +// update //============================================================ -void osd_update(running_machine *machine, int skip_redraw) +void sdl_osd_interface::update(bool skip_redraw) { sdl_window_info *window; @@ -338,16 +338,16 @@ void osd_update(running_machine *machine, int skip_redraw) { // profiler_mark(PROFILER_BLIT); for (window = sdl_window_list; window != NULL; window = window->next) - sdlwindow_video_window_update(machine, window); + sdlwindow_video_window_update(&machine(), window); // profiler_mark(PROFILER_END); } // poll the joystick values here - sdlinput_poll(machine); - check_osd_inputs(machine); + sdlinput_poll(&machine()); + check_osd_inputs(&machine()); - if ((machine->debug_flags & DEBUG_FLAG_OSD_ENABLED) != 0) - debugwin_update_during_game(machine); + if ((machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) != 0) + debugwin_update_during_game(&machine()); } diff --git a/src/osd/windows/debugwin.c b/src/osd/windows/debugwin.c index 5160732f923..746b9e52a21 100644 --- a/src/osd/windows/debugwin.c +++ b/src/osd/windows/debugwin.c @@ -262,29 +262,20 @@ static void smart_show_all(BOOL show); //============================================================ -// osd_init_debugger +// wait_for_debugger //============================================================ -void osd_init_debugger(running_machine *machine) -{ -} - - -//============================================================ -// osd_wait_for_debugger -//============================================================ - -void osd_wait_for_debugger(running_device *device, int firststop) +void windows_osd_interface::wait_for_debugger(running_device &device, bool firststop) { MSG message; // create a console window if (main_console == NULL) - console_create_window(device->machine); + console_create_window(&machine()); // update the views in the console to reflect the current CPU if (main_console != NULL) - console_set_cpu(device); + console_set_cpu(&device); // when we are first stopped, adjust focus to us if (firststop && main_console != NULL) @@ -299,7 +290,7 @@ void osd_wait_for_debugger(running_device *device, int firststop) smart_show_all(TRUE); // run input polling to ensure that our status is in sync - wininput_poll(device->machine); + wininput_poll(&machine()); // get and process messages GetMessage(&message, NULL, 0, 0); @@ -317,7 +308,7 @@ void osd_wait_for_debugger(running_device *device, int firststop) // process everything else default: - winwindow_dispatch_message(device->machine, &message); + winwindow_dispatch_message(&machine(), &message); break; } diff --git a/src/osd/windows/input.c b/src/osd/windows/input.c index 740289ff5ea..a2cd7b66567 100644 --- a/src/osd/windows/input.c +++ b/src/osd/windows/input.c @@ -756,10 +756,10 @@ int wininput_vkey_for_mame_code(input_code code) //============================================================ -// osd_customize_mapping_list +// customize_input_type_list //============================================================ -void osd_customize_input_type_list(input_type_desc *typelist) +void windows_osd_interface::customize_input_type_list(input_type_desc *typelist) { input_type_desc *typedesc; diff --git a/src/osd/windows/sound.c b/src/osd/windows/sound.c index ad329255159..3a81db07347 100644 --- a/src/osd/windows/sound.c +++ b/src/osd/windows/sound.c @@ -149,7 +149,7 @@ static void sound_exit(running_machine &machine) // copy_sample_data //============================================================ -static void copy_sample_data(INT16 *data, int bytes_to_copy) +static void copy_sample_data(const INT16 *data, int bytes_to_copy) { void *buffer1, *buffer2; DWORD length1, length2; @@ -190,10 +190,10 @@ static void copy_sample_data(INT16 *data, int bytes_to_copy) //============================================================ -// osd_update_audio_stream +// update_audio_stream //============================================================ -void osd_update_audio_stream(running_machine *machine, INT16 *buffer, int samples_this_frame) +void windows_osd_interface::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; @@ -246,10 +246,10 @@ void osd_update_audio_stream(running_machine *machine, INT16 *buffer, int sample //============================================================ -// osd_set_mastervolume +// set_mastervolume //============================================================ -void osd_set_mastervolume(int attenuation) +void windows_osd_interface::set_mastervolume(int attenuation) { // clamp the attenuation to 0-32 range if (attenuation > 0) diff --git a/src/osd/windows/video.c b/src/osd/windows/video.c index 05adf542a8f..4a517d94c6d 100644 --- a/src/osd/windows/video.c +++ b/src/osd/windows/video.c @@ -210,25 +210,23 @@ win_monitor_info *winvideo_monitor_from_handle(HMONITOR hmonitor) //============================================================ -// osd_update +// update //============================================================ -void osd_update(running_machine *machine, int skip_redraw) +void windows_osd_interface::update(bool skip_redraw) { - win_window_info *window; - // ping the watchdog on each update winmain_watchdog_ping(); // if we're not skipping this redraw, update all windows if (!skip_redraw) - for (window = win_window_list; window != NULL; window = window->next) + for (win_window_info *window = win_window_list; window != NULL; window = window->next) winwindow_video_window_update(window); // poll the joystick values here - winwindow_process_events(machine, TRUE); - wininput_poll(machine); - check_osd_inputs(machine); + winwindow_process_events(&machine(), TRUE); + wininput_poll(&machine()); + check_osd_inputs(&machine()); } diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index cb9ff0ec332..f3c4d9fc405 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -279,7 +279,6 @@ bool stack_walker::s_initialized = false; // FUNCTION PROTOTYPES //************************************************************************** -static void osd_exit(running_machine &machine); static BOOL WINAPI control_handler(DWORD type); static int is_double_click_start(int argc); static DWORD WINAPI watchdog_thread_entry(LPVOID lpParameter); @@ -418,7 +417,11 @@ int main(int argc, char *argv[]) } // parse config and cmdline options - DWORD result = cli_execute(argc, argv, mame_win_options); + DWORD result = 0; + { + windows_osd_interface osd; + result = cli_execute(argc, argv, osd, mame_win_options); + } // free symbols symbols = NULL; @@ -492,41 +495,62 @@ static void output_oslog(running_machine &machine, const char *buffer) //============================================================ -// osd_init +// constructor +//============================================================ + +windows_osd_interface::windows_osd_interface() +{ +} + + +//============================================================ +// destructor //============================================================ -void osd_init(running_machine *machine) +windows_osd_interface::~windows_osd_interface() { +} + + +//============================================================ +// init +//============================================================ + +void windows_osd_interface::init(running_machine &machine) +{ + // call our parent + osd_interface::init(machine); + const char *stemp; // determine if we are benchmarking, and adjust options appropriately - int bench = options_get_int(machine->options(), WINOPTION_BENCH); + int bench = options_get_int(machine.options(), WINOPTION_BENCH); if (bench > 0) { - options_set_bool(machine->options(), OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM); - options_set_bool(machine->options(), OPTION_SOUND, false, OPTION_PRIORITY_MAXIMUM); - options_set_string(machine->options(), WINOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM); - options_set_int(machine->options(), OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM); + options_set_bool(machine.options(), OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM); + options_set_bool(machine.options(), OPTION_SOUND, false, OPTION_PRIORITY_MAXIMUM); + options_set_string(machine.options(), WINOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM); + options_set_int(machine.options(), OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM); } // determine if we are profiling, and adjust options appropriately - int profile = options_get_int(machine->options(), WINOPTION_PROFILE); + int profile = options_get_int(machine.options(), WINOPTION_PROFILE); if (profile > 0) { - options_set_bool(machine->options(), OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM); - options_set_bool(machine->options(), WINOPTION_MULTITHREADING, false, OPTION_PRIORITY_MAXIMUM); - options_set_int(machine->options(), WINOPTION_NUMPROCESSORS, 1, OPTION_PRIORITY_MAXIMUM); + options_set_bool(machine.options(), OPTION_THROTTLE, false, OPTION_PRIORITY_MAXIMUM); + options_set_bool(machine.options(), WINOPTION_MULTITHREADING, false, OPTION_PRIORITY_MAXIMUM); + options_set_int(machine.options(), WINOPTION_NUMPROCESSORS, 1, OPTION_PRIORITY_MAXIMUM); } // thread priority - if (!(machine->debug_flags & DEBUG_FLAG_OSD_ENABLED)) - SetThreadPriority(GetCurrentThread(), options_get_int(machine->options(), WINOPTION_PRIORITY)); + if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)) + SetThreadPriority(GetCurrentThread(), options_get_int(machine.options(), WINOPTION_PRIORITY)); // ensure we get called on the way out - machine->add_notifier(MACHINE_NOTIFY_EXIT, osd_exit); + machine.add_notifier(MACHINE_NOTIFY_EXIT, osd_exit); // get number of processors - stemp = options_get_string(machine->options(), WINOPTION_NUMPROCESSORS); + stemp = options_get_string(machine.options(), WINOPTION_NUMPROCESSORS); osd_num_processors = 0; @@ -541,10 +565,10 @@ void osd_init(running_machine *machine) } // initialize the subsystems - winvideo_init(machine); - winsound_init(machine); - wininput_init(machine); - winoutput_init(machine); + winvideo_init(&machine); + winsound_init(&machine); + wininput_init(&machine); + winoutput_init(&machine); // notify listeners of screen configuration astring tempstring; @@ -555,8 +579,8 @@ void osd_init(running_machine *machine) } // hook up the debugger log - if (options_get_bool(machine->options(), WINOPTION_OSLOG)) - machine->add_logerror_callback(output_oslog); + if (options_get_bool(machine.options(), WINOPTION_OSLOG)) + machine.add_logerror_callback(output_oslog); // crank up the multimedia timer resolution to its max // this gives the system much finer timeslices @@ -569,7 +593,7 @@ void osd_init(running_machine *machine) // mm_task = (*av_set_mm_thread_characteristics)(TEXT("Playback"), &task_index); // if a watchdog thread is requested, create one - int watchdog = options_get_int(machine->options(), WINOPTION_WATCHDOG); + int watchdog = options_get_int(machine.options(), WINOPTION_WATCHDOG); if (watchdog != 0) { watchdog_reset_event = CreateEvent(NULL, FALSE, FALSE, NULL); @@ -588,7 +612,7 @@ void osd_init(running_machine *machine) } // note the existence of a machine - g_current_machine = machine; + g_current_machine = &machine; } @@ -596,7 +620,7 @@ void osd_init(running_machine *machine) // osd_exit //============================================================ -static void osd_exit(running_machine &machine) +void windows_osd_interface::osd_exit(running_machine &machine) { // no longer have a machine g_current_machine = NULL; diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index 2c6dfa5aeb7..56ff0ae7c88 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -40,6 +40,7 @@ //============================================================ #include "options.h" +#include "osdepend.h" //============================================================ @@ -130,6 +131,38 @@ //============================================================ +// TYPE DEFINITIONS +//============================================================ + +class windows_osd_interface : public osd_interface +{ +public: + // construction/destruction + windows_osd_interface(); + virtual ~windows_osd_interface(); + + // general overridables + virtual void init(running_machine &machine); + virtual void update(bool skip_redraw); + + // debugger overridables +// virtual void init_debugger(); + virtual void wait_for_debugger(device_t &device, bool firststop); + + // audio overridables + virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); + virtual void set_mastervolume(int attenuation); + + // input overridables + virtual void customize_input_type_list(input_type_desc *typelist); + +private: + static void osd_exit(running_machine &machine); +}; + + + +//============================================================ // GLOBAL VARIABLES //============================================================ @@ -139,6 +172,7 @@ extern const options_entry mame_win_options[]; extern int osd_num_processors; + //============================================================ // FUNCTION PROTOTYPES //============================================================ |
