Previous 199869 Revisions Next

r34353 Monday 12th January, 2015 at 01:19:14 UTC by Couriersud
Converted back osd_interface into a pure interface.
The previous version just exhibited any member of osd_interface to the
core. This one limits core access to osd to those functions originally
specified.
There is room for improvement going forward here in the design. Left
FIXMEs where appropriate. (nw)
[src/emu]clifront.c
[src/osd]osdepend.c osdepend.h
[src/osd/modules/debugger]debugint.c debugint.h debugosx.h debugosx.m debugqt.c debugqt.h debugwin.c debugwin.h none.c none.h
[src/osd/modules/lib]osdobj_common.c* osdobj_common.h*
[src/osd/modules/sound]direct_sound.c direct_sound.h none.c none.h sdl_sound.c sdl_sound.h
[src/osd/sdl]osdsdl.h output.c sdl.mak sdlmain.c
[src/osd/windows]windows.mak winmain.c winmain.h

trunk/src/emu/clifront.c
r242864r242865
791791
792792void cli_frontend::listnetworkadapters(const char *gamename)
793793{
794   m_osd.network_init();
795   osd_list_network_adapters();
796   m_osd.network_exit();
794    m_osd.list_network_adapters();
797795}
798796
799797
trunk/src/osd/modules/debugger/debugint.c
r242864r242865
851851   }
852852   if (debug_font != NULL)
853853   {
854      m_osd.machine().render().font_free(debug_font);
854      m_machine->render().font_free(debug_font);
855855      debug_font = NULL;
856856   }
857857   if (menu)
858858      global_free(menu);
859859}
860860
861void debugger_internal::init_debugger()
861void debugger_internal::init_debugger(running_machine &machine)
862862{
863863   unicode_char ch;
864864   int chw;
865   debug_font = m_osd.machine().render().font_alloc("ui.bdf"); //ui_get_font(machine);
865
866   m_machine = &machine;
867
868   debug_font = m_machine->render().font_alloc("ui.bdf"); //ui_get_font(machine);
866869   debug_font_width = 0;
867870   debug_font_height = 15;
868871
r242864r242865
871874   list = NULL;
872875   focus_view = NULL;
873876
874   debug_font_aspect = m_osd.machine().render().ui_aspect();
877   debug_font_aspect = m_machine->render().ui_aspect();
875878
876879   for (ch=0;ch<=127;ch++)
877880   {
r242864r242865
14421445
14431446void debugger_internal::debugger_update()
14441447{
1445   if (!debug_cpu_is_stopped(m_osd.machine()) && m_osd.machine().phase() == MACHINE_PHASE_RUNNING)
1448   if (!debug_cpu_is_stopped(*m_machine) && m_machine->phase() == MACHINE_PHASE_RUNNING)
14461449   {
14471450      update_views();
14481451   }
r242864r242865
14521455//  debugger_internal - constructor
14531456//-------------------------------------------------
14541457debugger_internal::debugger_internal(const osd_interface &osd)
1455   : osd_debugger_interface(osd)
1458   : osd_debugger_interface(osd), m_machine(NULL)
14561459{
14571460}
trunk/src/osd/modules/debugger/debugint.h
r242864r242865
1515#define __DEBUGGER_INTERNAL_H__
1616
1717#include "osdepend.h"
18#include "modules/lib/osdobj_common.h"
1819
1920class debugger_internal : public osd_debugger_interface
2021{
r242864r242865
2324   debugger_internal(const osd_interface &osd);
2425   virtual ~debugger_internal() { }
2526
26   virtual void init_debugger();
27   virtual void init_debugger(running_machine &machine);
2728   virtual void wait_for_debugger(device_t &device, bool firststop);
2829   virtual void debugger_update();
2930   virtual void debugger_exit();
31private:
32   running_machine *m_machine;
3033};
3134
3235extern const osd_debugger_type OSD_DEBUGGER_INTERNAL;
trunk/src/osd/modules/debugger/debugosx.h
r242864r242865
1818// MAME headers
1919#include "emu.h"
2020#include "debug/debugvw.h"
21#include "modules/lib/osdobj_common.h"
2122
2223
2324#ifdef __OBJC__
r242864r242865
373374   debugger_osx(const osd_interface &osd);
374375   virtual ~debugger_osx() { }
375376
376   virtual void init_debugger();
377   virtual void init_debugger(running_machine &machine);
377378   virtual void wait_for_debugger(device_t &device, bool firststop);
378379   virtual void debugger_update();
379380   virtual void debugger_exit();
381private:
382   running_machine *m_machine;
380383};
381384
382385extern const osd_debugger_type OSD_DEBUGGER_OSX;
trunk/src/osd/modules/debugger/debugosx.m
r242864r242865
7373//  debugger_osx - constructor
7474//-------------------------------------------------
7575debugger_osx::debugger_osx(const osd_interface &osd)
76   : osd_debugger_interface(osd)
76   : osd_debugger_interface(osd), m_machine(NULL)
7777{
7878}
7979
r242864r242865
8181//  debugger_osx::init_debugger
8282//============================================================
8383
84void debugger_osx::init_debugger()
84void debugger_osx::init_debugger(running_machine &machine)
8585{
86    m_machine = &machine;
8687}
8788
8889//============================================================
r242864r242865
9394{
9495   // create a console window
9596   if (main_console == nil)
96      console_create_window(m_osd.machine());
97      console_create_window(*m_machine);
9798
9899   // make sure the debug windows are visible
99100   waiting_for_debugger = YES;
trunk/src/osd/modules/debugger/debugqt.c
r242864r242865
1919#include "emu.h"
2020#include "config.h"
2121#include "debugger.h"
22#include "modules/lib/osdobj_common.h"
2223
2324#include "qt/debugqtlogwindow.h"
2425#include "qt/debugqtmainwindow.h"
r242864r242865
5051//  debugger_qt - constructor
5152//-------------------------------------------------
5253debugger_qt::debugger_qt(const osd_interface &osd)
53   : osd_debugger_interface(osd)
54   : osd_debugger_interface(osd), m_machine(NULL)
5455{
5556}
5657
r242864r242865
227228bool winwindow_qt_filter(void *message);
228229#endif
229230
230void debugger_qt::init_debugger()
231void debugger_qt::init_debugger(running_machine &machine)
231232{
232233   if (qApp == NULL)
233234   {
r242864r242865
249250      oneShot = true;
250251   }
251252
253   m_machine = &machine;
252254   // Setup the configuration XML saving and loading
253   config_register(m_osd.machine(),
255   config_register(machine,
254256               "debugger",
255               config_saveload_delegate(FUNC(xml_configuration_load), &m_osd.machine()),
256               config_saveload_delegate(FUNC(xml_configuration_save), &m_osd.machine()));
257               config_saveload_delegate(FUNC(xml_configuration_load), &machine),
258               config_saveload_delegate(FUNC(xml_configuration_save), &machine));
257259}
258260
259261
r242864r242865
276278   // Dialog initialization
277279   if (oneShot)
278280   {
279      mainQtWindow = new MainWindow(&m_osd.machine());
281      mainQtWindow = new MainWindow(m_machine);
280282      load_and_clear_main_window_config(xmlConfigurations);
281      setup_additional_startup_windows(m_osd.machine(), xmlConfigurations);
283      setup_additional_startup_windows(*m_machine, xmlConfigurations);
282284      mainQtWindow->show();
283285      oneShot = false;
284286   }
r242864r242865
325327   }
326328
327329   // Exit if the machine has been instructed to do so (scheduled event == exit || hard_reset)
328   if (m_osd.machine().scheduled_event_pending())
330   if (m_machine->scheduled_event_pending())
329331   {
330332      // Keep a list of windows we want to save.
331333      // We need to do this here because by the time xml_configuration_save gets called
trunk/src/osd/modules/debugger/debugqt.h
r242864r242865
1414#ifndef __DEBUGGER_QT_H__
1515#define __DEBUGGER_QT_H__
1616
17#include "osdepend.h"
17#include "emu.h"
1818
1919class debugger_qt : public osd_debugger_interface
2020{
r242864r242865
2323   debugger_qt(const osd_interface &osd);
2424   virtual ~debugger_qt();
2525
26   virtual void init_debugger();
26   virtual void init_debugger(running_machine &machine);
2727   virtual void wait_for_debugger(device_t &device, bool firststop);
2828   virtual void debugger_update();
2929   virtual void debugger_exit();
30
31private:
32   running_machine *m_machine;
3033};
3134
3235extern const osd_debugger_type OSD_DEBUGGER_QT;
trunk/src/osd/modules/debugger/debugwin.c
r242864r242865
257257
258258   // create a console window
259259   if (main_console == NULL)
260      console_create_window(m_osd.machine());
260      console_create_window(*m_machine);
261261
262262   // update the views in the console to reflect the current CPU
263263   if (main_console != NULL)
r242864r242865
276276   smart_show_all(TRUE);
277277
278278   // run input polling to ensure that our status is in sync
279   wininput_poll(m_osd.machine());
279   wininput_poll(*m_machine);
280280
281281   // get and process messages
282282   GetMessage(&message, NULL, 0, 0);
r242864r242865
294294
295295      // process everything else
296296      default:
297         winwindow_dispatch_message(m_osd.machine(), &message);
297         winwindow_dispatch_message(*m_machine, &message);
298298         break;
299299   }
300300
r242864r242865
368368//  debugwin_init_windows
369369//============================================================
370370
371void debugger_windows::init_debugger()
371void debugger_windows::init_debugger(running_machine &machine)
372372{
373373   static int class_registered;
374374
375   m_machine = &machine;
375376   // register the window classes
376377   if (!class_registered)
377378   {
r242864r242865
414415
415416      if (temp_dc != NULL)
416417      {
417         windows_options &options = downcast<windows_options &>(m_osd.machine().options());
418         windows_options &options = downcast<windows_options &>(m_machine->options());
418419         int size = options.debugger_font_size();
419420         TCHAR *t_face;
420421
r242864r242865
474475void debugger_windows::debugger_update()
475476{
476477   // if we're running live, do some checks
477   if (!winwindow_has_focus() && !debug_cpu_is_stopped(m_osd.machine()) && m_osd.machine().phase() == MACHINE_PHASE_RUNNING)
478   if (!winwindow_has_focus() && !debug_cpu_is_stopped(*m_machine) && m_machine->phase() == MACHINE_PHASE_RUNNING)
478479   {
479480      // see if the interrupt key is pressed and break if it is
480      if (debugwin_seq_pressed(m_osd.machine()))
481      if (debugwin_seq_pressed(*m_machine))
481482      {
482483         HWND focuswnd = GetFocus();
483484         debugwin_info *info;
484485
485         debug_cpu_get_visible_cpu(m_osd.machine())->debug()->halt_on_next_instruction("User-initiated break\n");
486         debug_cpu_get_visible_cpu(*m_machine)->debug()->halt_on_next_instruction("User-initiated break\n");
486487
487488         // if we were focused on some window's edit box, reset it to default
488489         for (info = window_list; info != NULL; info = info->next)
trunk/src/osd/modules/debugger/debugwin.h
r242864r242865
1313#define __DEBUGGER_WINDOWS_H__
1414
1515#include "osdepend.h"
16#include "modules/lib/osdobj_common.h"
1617
1718class debugger_windows : public osd_debugger_interface
1819{
r242864r242865
2122   debugger_windows(const osd_interface &osd);
2223   virtual ~debugger_windows() { }
2324
24   virtual void init_debugger();
25   virtual void init_debugger(running_machine &machine);
2526   virtual void wait_for_debugger(device_t &device, bool firststop);
2627   virtual void debugger_update();
2728   virtual void debugger_exit();
29private:
30   running_machine *m_machine;
2831};
2932
3033extern const osd_debugger_type OSD_DEBUGGER_WINDOWS;
trunk/src/osd/modules/debugger/none.c
r242864r242865
1313//  debugger_none - constructor
1414//-------------------------------------------------
1515debugger_none::debugger_none(const osd_interface &osd)
16   : osd_debugger_interface(osd)
16   : osd_debugger_interface(osd), m_machine(NULL)
1717{
1818}
1919
20void debugger_none::init_debugger()
20void debugger_none::init_debugger(running_machine &machine)
2121{
22    m_machine = &machine;
2223}
2324
2425void debugger_none::wait_for_debugger(device_t &device, bool firststop)
2526{
26   debug_cpu_get_visible_cpu(m_osd.machine())->debug()->go();
27   debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
2728}
2829
2930void debugger_none::debugger_update()
trunk/src/osd/modules/debugger/none.h
r242864r242865
1414#define __DEBUGGER_NONE_H__
1515
1616#include "osdepend.h"
17#include "modules/lib/osdobj_common.h"
1718
1819class debugger_none : public osd_debugger_interface
1920{
r242864r242865
2223   debugger_none(const osd_interface &osd);
2324   virtual ~debugger_none() { }
2425
25   virtual void init_debugger();
26   virtual void init_debugger(running_machine &machine);
2627   virtual void wait_for_debugger(device_t &device, bool firststop);
2728   virtual void debugger_update();
2829   virtual void debugger_exit();
30private:
31   running_machine *m_machine;
2932};
3033
3134extern const osd_debugger_type OSD_DEBUGGER_NONE;
trunk/src/osd/modules/lib/osdobj_common.c
r0r242865
1// license:BSD-3-Clause
2// copyright-holders:Aaron Giles
3/***************************************************************************
4
5    osdepend.c
6
7    OS-dependent code interface.
8
9*******************************************************************c********/
10
11
12#include "emu.h"
13#include "osdepend.h"
14#include "modules/sound/none.h"
15#include "modules/debugger/none.h"
16#include "modules/debugger/debugint.h"
17
18extern bool g_print_verbose;
19
20
21//-------------------------------------------------
22//  osd_interface - constructor
23//-------------------------------------------------
24
25osd_common_t::osd_common_t()
26   : m_machine(NULL),
27      m_sound(NULL),
28      m_debugger(NULL)
29
30{
31}
32
33void osd_common_t::update_option(osd_options &options, const char * key, dynamic_array<const char *> &values)
34{
35   astring current_value(options.description(key));
36   astring new_option_value("");
37   for (int index = 0; index < values.count(); index++)
38   {
39      astring t(values[index]);
40      if (new_option_value.len() > 0)
41      {
42         if( index != (values.count()-1))
43            new_option_value.cat(", ");
44         else
45            new_option_value.cat(" or ");
46      }
47      new_option_value.cat(t);
48   }
49   // TODO: core_strdup() is leaked
50   options.set_description(key, core_strdup(current_value.cat(new_option_value).cstr()));
51}
52
53void osd_common_t::register_options(osd_options &options)
54{
55   // Register video options and update options
56   video_options_add("none", NULL);
57   video_register();
58   update_option(options, OSDOPTION_VIDEO, m_video_names);
59
60   // Register sound options and update options
61   sound_options_add("none", OSD_SOUND_NONE);
62   sound_register();
63   update_option(options, OSDOPTION_SOUND, m_sound_names);
64
65   // Register debugger options and update options
66   debugger_options_add("none", OSD_DEBUGGER_NONE);
67   debugger_options_add("internal", OSD_DEBUGGER_INTERNAL);
68   debugger_register();
69   update_option(options, OSDOPTION_DEBUGGER, m_debugger_names);
70}
71
72
73//-------------------------------------------------
74//  osd_interface - destructor
75//-------------------------------------------------
76
77osd_common_t::~osd_common_t()
78{
79   for(int i= 0; i < m_video_names.count(); ++i)
80      osd_free(const_cast<char*>(m_video_names[i]));
81   //m_video_options,reset();
82
83   for(int i= 0; i < m_sound_names.count(); ++i)
84      osd_free(const_cast<char*>(m_sound_names[i]));
85   m_sound_options.reset();
86
87   for(int i= 0; i < m_debugger_names.count(); ++i)
88      osd_free(const_cast<char*>(m_debugger_names[i]));
89   m_debugger_options.reset();
90}
91
92
93//-------------------------------------------------
94//  init - initialize the OSD system.
95//-------------------------------------------------
96
97void osd_common_t::init(running_machine &machine)
98{
99   //
100   // This function is responsible for initializing the OSD-specific
101   // video and input functionality, and registering that functionality
102   // with the MAME core.
103   //
104   // In terms of video, this function is expected to create one or more
105   // render_targets that will be used by the MAME core to provide graphics
106   // data to the system. Although it is possible to do this later, the
107   // assumption in the MAME core is that the user interface will be
108   // visible starting at init() time, so you will have some work to
109   // do to avoid these assumptions.
110   //
111   // In terms of input, this function is expected to enumerate all input
112   // devices available and describe them to the MAME core by adding
113   // input devices and their attached items (buttons/axes) via the input
114   // system.
115   //
116   // Beyond these core responsibilities, init() should also initialize
117   // any other OSD systems that require information about the current
118   // running_machine.
119   //
120   // This callback is also the last opportunity to adjust the options
121   // before they are consumed by the rest of the core.
122   //
123   // Future work/changes:
124   //
125   // Audio initialization may eventually move into here as well,
126   // instead of relying on independent callbacks from each system.
127   //
128
129   m_machine = &machine;
130
131   osd_options &options = downcast<osd_options &>(machine.options());
132   // extract the verbose printing option
133   if (options.verbose())
134      g_print_verbose = true;
135
136   // ensure we get called on the way out
137   machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_common_t::osd_exit), this));
138}
139
140
141//-------------------------------------------------
142//  update - periodic system update
143//-------------------------------------------------
144
145void osd_common_t::update(bool skip_redraw)
146{
147   //
148   // This method is called periodically to flush video updates to the
149   // screen, and also to allow the OSD a chance to update other systems
150   // on a regular basis. In general this will be called at the frame
151   // rate of the system being run; however, it may be called at more
152   // irregular intervals in some circumstances (e.g., multi-screen games
153   // or games with asynchronous updates).
154   //
155}
156
157
158//-------------------------------------------------
159//  init_debugger - perform debugger-specific
160//  initialization
161//-------------------------------------------------
162
163void osd_common_t::init_debugger()
164{
165   //
166   // Unlike init() above, this method is only called if the debugger
167   // is active. This gives any OSD debugger interface a chance to
168   // create all of its structures.
169   //
170   osd_debugger_type debugger = m_debugger_options.find(machine().options().debugger());
171   if (debugger==NULL)
172   {
173      osd_printf_warning("debugger_init: option %s not found switching to auto\n",machine().options().debugger());
174      debugger = m_debugger_options.find("auto");
175   }
176   m_debugger = (*debugger)(*this);
177
178   m_debugger->init_debugger(machine());
179}
180
181
182//-------------------------------------------------
183//  wait_for_debugger - wait for a debugger
184//  command to be processed
185//-------------------------------------------------
186
187void osd_common_t::wait_for_debugger(device_t &device, bool firststop)
188{
189   //
190   // When implementing an OSD-driver debugger, this method should be
191   // overridden to wait for input, process it, and return. It will be
192   // called repeatedly until a command is issued that resumes
193   // execution.
194   //
195   m_debugger->wait_for_debugger(device, firststop);
196}
197
198void osd_common_t::debugger_update()
199{
200   if (m_debugger) m_debugger->debugger_update();
201}
202
203void osd_common_t::debugger_exit()
204{
205   if (m_debugger)
206   {
207      m_debugger->debugger_exit();
208      global_free(m_debugger);
209      m_debugger = NULL;
210   }
211}
212
213//-------------------------------------------------
214//  update_audio_stream - update the stereo audio
215//  stream
216//-------------------------------------------------
217
218void osd_common_t::update_audio_stream(const INT16 *buffer, int samples_this_frame)
219{
220   //
221   // This method is called whenever the system has new audio data to stream.
222   // It provides an array of stereo samples in L-R order which should be
223   // output at the configured sample_rate.
224   //
225   m_sound->update_audio_stream(buffer,samples_this_frame);
226}
227
228
229//-------------------------------------------------
230//  set_mastervolume - set the system volume
231//-------------------------------------------------
232
233void osd_common_t::set_mastervolume(int attenuation)
234{
235   //
236   // Attenuation is the attenuation in dB (a negative number).
237   // To convert from dB to a linear volume scale do the following:
238   //    volume = MAX_VOLUME;
239   //    while (attenuation++ < 0)
240   //       volume /= 1.122018454;      //  = (10 ^ (1/20)) = 1dB
241   //
242   m_sound->set_mastervolume(attenuation);
243}
244
245
246//-------------------------------------------------
247//  customize_input_type_list - provide OSD
248//  additions/modifications to the input list
249//-------------------------------------------------
250
251void osd_common_t::customize_input_type_list(simple_list<input_type_entry> &typelist)
252{
253   //
254   // inptport.c defines some general purpose defaults for key and joystick bindings.
255   // They may be further adjusted by the OS dependent code to better match the
256   // available keyboard, e.g. one could map pause to the Pause key instead of P, or
257   // snapshot to PrtScr instead of F12. Of course the user can further change the
258   // settings to anything he/she likes.
259   //
260   // This function is called on startup, before reading the configuration from disk.
261   // Scan the list, and change the keys/joysticks you want.
262   //
263}
264
265
266//-------------------------------------------------
267//  font_open - attempt to "open" a handle to the
268//  font with the given name
269//-------------------------------------------------
270
271osd_font osd_common_t::font_open(const char *name, int &height)
272{
273   return NULL;
274}
275
276
277//-------------------------------------------------
278//  font_close - release resources associated with
279//  a given OSD font
280//-------------------------------------------------
281
282void osd_common_t::font_close(osd_font font)
283{
284}
285
286
287//-------------------------------------------------
288//  font_get_bitmap - allocate and populate a
289//  BITMAP_FORMAT_ARGB32 bitmap containing the
290//  pixel values rgb_t(0xff,0xff,0xff,0xff)
291//  or rgb_t(0x00,0xff,0xff,0xff) for each
292//  pixel of a black & white font
293//-------------------------------------------------
294
295bool osd_common_t::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
296{
297   return false;
298}
299
300//-------------------------------------------------
301//  get_slider_list - allocate and populate a
302//  list of OS-dependent slider values.
303//-------------------------------------------------
304void *osd_common_t::get_slider_list()
305{
306   return NULL;
307}
308
309void osd_common_t::init_subsystems()
310{
311   if (!video_init())
312   {
313      video_exit();
314      osd_printf_error("video_init: Initialization failed!\n\n\n");
315      fflush(stderr);
316      fflush(stdout);
317      exit(-1);
318   }
319
320   sound_init();
321   input_init();
322   // we need pause callbacks
323   machine().add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(osd_common_t::input_pause), this));
324   machine().add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(osd_common_t::input_resume), this));
325
326   output_init();
327#ifdef USE_NETWORK
328   network_init();
329#endif
330   midi_init();
331}
332
333bool osd_common_t::video_init()
334{
335   return true;
336}
337
338bool osd_common_t::window_init()
339{
340   return true;
341}
342
343bool osd_common_t::sound_init()
344{
345   osd_sound_type sound = m_sound_options.find(machine().options().sound());
346   if (sound==NULL)
347   {
348      osd_printf_warning("sound_init: option %s not found switching to auto\n",machine().options().sound());
349      sound = m_sound_options.find("auto");
350   }
351   m_sound = (*sound)(*this, machine());
352   return true;
353}
354
355bool osd_common_t::no_sound()
356{
357   return (strcmp(machine().options().sound(),"none")==0) ? true : false;
358}
359
360void osd_common_t::video_register()
361{
362}
363
364void osd_common_t::sound_register()
365{
366}
367
368void osd_common_t::debugger_register()
369{
370}
371
372bool osd_common_t::input_init()
373{
374   return true;
375}
376
377void osd_common_t::input_pause()
378{
379}
380
381void osd_common_t::input_resume()
382{
383}
384
385bool osd_common_t::output_init()
386{
387   return true;
388}
389
390bool osd_common_t::network_init()
391{
392   return true;
393}
394
395void osd_common_t::exit_subsystems()
396{
397   video_exit();
398   sound_exit();
399   input_exit();
400   output_exit();
401   #ifdef USE_NETWORK
402   network_exit();
403   #endif
404   midi_exit();
405   debugger_exit();
406}
407
408void osd_common_t::video_exit()
409{
410}
411
412void osd_common_t::window_exit()
413{
414}
415
416void osd_common_t::sound_exit()
417{
418   global_free(m_sound);
419}
420
421void osd_common_t::input_exit()
422{
423}
424
425void osd_common_t::output_exit()
426{
427}
428
429void osd_common_t::network_exit()
430{
431}
432
433void osd_common_t::osd_exit()
434{
435   exit_subsystems();
436}
437
438void osd_common_t::video_options_add(const char *name, void *type)
439{
440   //m_video_options.add(name, type, false);
441   m_video_names.append(core_strdup(name));
442}
443
444void osd_common_t::sound_options_add(const char *name, osd_sound_type type)
445{
446   m_sound_options.add(name, type, false);
447   m_sound_names.append(core_strdup(name));
448}
449
450void osd_common_t::debugger_options_add(const char *name, osd_debugger_type type)
451{
452   m_debugger_options.add(name, type, false);
453   m_debugger_names.append(core_strdup(name));
454}
455
456bool osd_common_t::midi_init()
457{
458    // this should be done on the OS_level
459    return osd_midi_init();
460}
461
462//-------------------------------------------------
463//  list_midi_devices - list available midi devices
464//-------------------------------------------------
465
466void osd_common_t::list_midi_devices(void)
467{
468    osd_list_midi_devices();
469}
470
471void osd_common_t::midi_exit()
472{
473    osd_midi_exit();
474}
475
476//-------------------------------------------------
477//  osd_sound_interface - constructor
478//-------------------------------------------------
479
480osd_sound_interface::osd_sound_interface(const osd_interface &osd, running_machine &machine)
481    : m_osd(osd), m_machine(machine)
482{
483}
484
485//-------------------------------------------------
486//  osd_sound_interface - destructor
487//-------------------------------------------------
488
489osd_sound_interface::~osd_sound_interface()
490{
491}
492
493//-------------------------------------------------
494//  osd_debugger_interface - constructor
495//-------------------------------------------------
496
497osd_debugger_interface::osd_debugger_interface(const osd_interface &osd)
498    : m_osd(osd)
499{
500}
501
502//-------------------------------------------------
503//  osd_debugger_interface - destructor
504//-------------------------------------------------
505
506osd_debugger_interface::~osd_debugger_interface()
507{
508}
509
trunk/src/osd/modules/lib/osdobj_common.h
r0r242865
1// license:BSD-3-Clause
2// copyright-holders:Aaron Giles
3/***************************************************************************
4
5    osdepend.h
6
7    OS-dependent code interface.
8
9*******************************************************************c********/
10
11#pragma once
12
13#ifndef __OSDOBJ_COMMON_H__
14#define __OSDOBJ_COMMON__
15
16#include "osdepend.h"
17#include "options.h"
18
19
20#if 0
21// forward references
22class input_type_entry;
23class device_t;
24#endif
25
26class osd_sound_interface;
27class osd_debugger_interface;
28
29// a osd_sound_type is simply a pointer to its alloc function
30typedef osd_sound_interface *(*osd_sound_type)(const osd_interface &osd, running_machine &machine);
31
32// a osd_sound_type is simply a pointer to its alloc function
33typedef osd_debugger_interface *(*osd_debugger_type)(const osd_interface &osd);
34
35
36// ======================> osd_interface
37
38// description of the currently-running machine
39class osd_common_t : public osd_interface
40{
41public:
42   // construction/destruction
43   osd_common_t();
44   virtual ~osd_common_t();
45
46   virtual void register_options(osd_options &options);
47
48   // general overridables
49   virtual void init(running_machine &machine);
50   virtual void update(bool skip_redraw);
51
52   // debugger overridables
53   virtual void init_debugger();
54   virtual void wait_for_debugger(device_t &device, bool firststop);
55
56   // audio overridables
57   virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame);
58   virtual void set_mastervolume(int attenuation);
59   virtual bool no_sound();
60
61   // input overridables
62   virtual void customize_input_type_list(simple_list<input_type_entry> &typelist);
63
64   // font overridables
65   virtual osd_font font_open(const char *name, int &height);
66   virtual void font_close(osd_font font);
67   virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
68
69   // video overridables
70   virtual void *get_slider_list();
71
72   // midi overridables
73   // FIXME: this should return a list of devices, not list them on stdout
74   virtual void list_midi_devices(void);
75
76   virtual void list_network_adapters()
77    {
78        network_init();
79        osd_list_network_adapters();
80        network_exit();
81    }
82
83
84   // FIXME: everything below seems to be osd specific and not part of
85   //        this INTERFACE but part of the osd IMPLEMENTATION
86
87    // getters
88    running_machine &machine() { assert(m_machine != NULL); return *m_machine; }
89
90
91    virtual void debugger_update();
92    virtual void debugger_exit();
93    virtual void debugger_register();
94
95    virtual void init_subsystems();
96
97    virtual bool video_init();
98    virtual void video_register();
99    virtual bool window_init();
100
101    virtual bool sound_init();
102    virtual void sound_register();
103
104    virtual bool input_init();
105    virtual void input_pause();
106    virtual void input_resume();
107    virtual bool output_init();
108    virtual bool network_init();
109    virtual bool midi_init();
110
111    virtual void exit_subsystems();
112    virtual void video_exit();
113    virtual void window_exit();
114    virtual void sound_exit();
115    virtual void input_exit();
116    virtual void output_exit();
117    virtual void network_exit();
118    virtual void midi_exit();
119
120    virtual void osd_exit();
121
122    virtual void video_options_add(const char *name, void *type);
123    virtual void sound_options_add(const char *name, osd_sound_type type);
124    virtual void debugger_options_add(const char *name, osd_debugger_type type);
125
126private:
127   // internal state
128   running_machine *   m_machine;
129
130   void update_option(osd_options &options, const char * key, dynamic_array<const char *> &values);
131
132protected:
133   osd_sound_interface* m_sound;
134   osd_debugger_interface* m_debugger;
135private:
136   //tagmap_t<osd_video_type>  m_video_options;
137   dynamic_array<const char *> m_video_names;
138   tagmap_t<osd_sound_type>  m_sound_options;
139   dynamic_array<const char *> m_sound_names;
140   tagmap_t<osd_debugger_type>  m_debugger_options;
141   dynamic_array<const char *> m_debugger_names;
142};
143
144
145class osd_sound_interface
146{
147public:
148   // construction/destruction
149   osd_sound_interface(const osd_interface &osd, running_machine &machine);
150   virtual ~osd_sound_interface();
151
152   virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame) = 0;
153   virtual void set_mastervolume(int attenuation) = 0;
154protected:
155   const osd_interface& m_osd;
156   running_machine& m_machine;
157};
158
159// this template function creates a stub which constructs a sound subsystem
160template<class _DeviceClass>
161osd_sound_interface *osd_sound_creator(const osd_interface &osd, running_machine &machine)
162{
163   return global_alloc(_DeviceClass(osd, machine));
164}
165
166class osd_debugger_interface
167{
168public:
169   // construction/destruction
170   osd_debugger_interface(const osd_interface &osd);
171   virtual ~osd_debugger_interface();
172
173   virtual void init_debugger(running_machine &machine) = 0;
174   virtual void wait_for_debugger(device_t &device, bool firststop) = 0;
175   virtual void debugger_update() = 0;
176   virtual void debugger_exit() = 0;
177
178protected:
179   const osd_interface& m_osd;
180};
181
182// this template function creates a stub which constructs a debugger
183template<class _DeviceClass>
184osd_debugger_interface *osd_debugger_creator(const osd_interface &osd)
185{
186   return global_alloc(_DeviceClass(osd));
187}
188
189#endif  /* __OSDOBJ_COMMON_H__ */
trunk/src/osd/modules/sound/direct_sound.c
r242864r242865
7878//-------------------------------------------------
7979//  sound_direct_sound - constructor
8080//-------------------------------------------------
81sound_direct_sound::sound_direct_sound(const osd_interface &osd)
82   : osd_sound_interface(osd)
81sound_direct_sound::sound_direct_sound(const osd_interface &osd, running_machine &machine)
82   : osd_sound_interface(osd, machine)
8383{
8484   // attempt to initialize directsound
8585   // don't make it fatal if we can't -- we'll just run without sound
r242864r242865
268268   stream_format.wBitsPerSample    = 16;
269269   stream_format.wFormatTag        = WAVE_FORMAT_PCM;
270270   stream_format.nChannels         = 2;
271   stream_format.nSamplesPerSec    = m_osd.machine().sample_rate();
271   stream_format.nSamplesPerSec    = m_machine.sample_rate();
272272   stream_format.nBlockAlign       = stream_format.wBitsPerSample * stream_format.nChannels / 8;
273273   stream_format.nAvgBytesPerSec   = stream_format.nSamplesPerSec * stream_format.nBlockAlign;
274274
r242864r242865
276276   // compute the buffer size based on the output sample rate
277277   int audio_latency;
278278   #ifdef SDLMAME_WIN32
279   audio_latency = downcast<sdl_options &>(m_osd.machine().options()).audio_latency();
279   audio_latency = downcast<sdl_options &>(m_machine.options()).audio_latency();
280280   #else
281   audio_latency = downcast<windows_options &>(m_osd.machine().options()).audio_latency();
281   audio_latency = downcast<windows_options &>(m_machine.options()).audio_latency();
282282   #endif
283283   stream_buffer_size = stream_format.nSamplesPerSec * stream_format.nBlockAlign * audio_latency / 10;
284284   stream_buffer_size = (stream_buffer_size / 1024) * 1024;
trunk/src/osd/modules/sound/direct_sound.h
r242864r242865
2121#undef interface
2222
2323#include "osdepend.h"
24#include "modules/lib/osdobj_common.h"
2425
2526class sound_direct_sound : public osd_sound_interface
2627{
2728public:
2829   // construction/destruction
29   sound_direct_sound(const osd_interface &osd);
30   sound_direct_sound(const osd_interface &osd, running_machine &machine);
3031   virtual ~sound_direct_sound();
3132
3233   virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame);
trunk/src/osd/modules/sound/none.c
r242864r242865
1414//-------------------------------------------------
1515//  sound_none - constructor
1616//-------------------------------------------------
17sound_none::sound_none(const osd_interface &osd)
18   : osd_sound_interface(osd)
17sound_none::sound_none(const osd_interface &osd, running_machine &machine)
18   : osd_sound_interface(osd, machine)
1919{
2020}
2121
trunk/src/osd/modules/sound/none.h
r242864r242865
1414#define __SOUND_NONE_H__
1515
1616#include "osdepend.h"
17#include "modules/lib/osdobj_common.h"
1718
1819class sound_none : public osd_sound_interface
1920{
2021public:
2122   // construction/destruction
22   sound_none(const osd_interface &osd);
23   sound_none(const osd_interface &osd, running_machine &machine);
2324   virtual ~sound_none() { }
2425
2526   virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame) { }
trunk/src/osd/modules/sound/sdl_sound.c
r242864r242865
8080//-------------------------------------------------
8181//  sound_sdl - constructor
8282//-------------------------------------------------
83sound_sdl::sound_sdl(const osd_interface &osd)
84   : osd_sound_interface(osd)
83sound_sdl::sound_sdl(const osd_interface &osd, running_machine &machine)
84   : osd_sound_interface(osd, machine)
8585{
8686   if (LOG_SOUND)
8787      sound_log = fopen(SDLMAME_SOUND_LOG, "w");
8888
8989   // skip if sound disabled
90   if (osd.machine().sample_rate() != 0)
90   if (m_machine.sample_rate() != 0)
9191   {
9292      if (initialized_audio)
9393      {
r242864r242865
9595      }
9696
9797      // attempt to initialize SDL
98      if (sdl_init(osd.machine()))
98      if (sdl_init(m_machine))
9999         return;
100100
101101      // set the startup volume
r242864r242865
112112sound_sdl::~sound_sdl()
113113{
114114   // if nothing to do, don't do it
115   if (m_osd.machine().sample_rate() == 0)
115   if (m_machine.sample_rate() == 0)
116116      return;
117117
118118   // kill the buffers and dsound
119   sdl_kill(m_osd.machine());
119   sdl_kill(m_machine);
120120   sdl_destroy_buffers();
121121
122122   // print out over/underflow stats
r242864r242865
267267void sound_sdl::update_audio_stream(const INT16 *buffer, int samples_this_frame)
268268{
269269   // if nothing to do, don't do it
270   if (m_osd.machine().sample_rate() != 0 && stream_buffer)
270   if (m_machine.sample_rate() != 0 && stream_buffer)
271271   {
272272      int bytes_this_frame = samples_this_frame * sizeof(INT16) * 2;
273273      int play_position, write_position, stream_in;
r242864r242865
275275
276276      play_position = stream_playpos;
277277
278      write_position = stream_playpos + ((m_osd.machine().sample_rate() / 50) * sizeof(INT16) * 2);
278      write_position = stream_playpos + ((m_machine.sample_rate() / 50) * sizeof(INT16) * 2);
279279      orig_write = write_position;
280280
281281      if (!stream_in_initialized)
r242864r242865
336336
337337      // now we know where to copy; let's do it
338338      stream_buffer_in = stream_in;
339      copy_sample_data(m_osd.machine(), buffer, bytes_this_frame);
339      copy_sample_data(m_machine, buffer, bytes_this_frame);
340340   }
341341}
342342
trunk/src/osd/modules/sound/sdl_sound.h
r242864r242865
1414#define __SOUND_SDL_H__
1515
1616#include "osdepend.h"
17#include "modules/lib/osdobj_common.h"
1718
1819class sound_sdl : public osd_sound_interface
1920{
2021public:
2122   // construction/destruction
22   sound_sdl(const osd_interface &osd);
23   sound_sdl(const osd_interface &osd, running_machine &machine);
2324   virtual ~sound_sdl();
2425
2526   virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame);
trunk/src/osd/osdepend.c
r242864r242865
1// license:BSD-3-Clause
2// copyright-holders:Aaron Giles
3/***************************************************************************
4
5    osdepend.c
6
7    OS-dependent code interface.
8
9*******************************************************************c********/
10
11
12#include "emu.h"
131#include "osdepend.h"
14#include "modules/sound/none.h"
15#include "modules/debugger/none.h"
16#include "modules/debugger/debugint.h"
172
18extern bool g_print_verbose;
19
203const options_entry osd_options::s_option_entries[] =
214{
22   // debugging options
23   { NULL,                                   NULL,       OPTION_HEADER,     "OSD DEBUGGING OPTIONS" },
24   { OSDOPTION_LOG,                          "0",        OPTION_BOOLEAN,    "generate an error.log file" },
25   { OSDOPTION_VERBOSE ";v",                 "0",        OPTION_BOOLEAN,    "display additional diagnostic information" },
26   { OSDOPTION_DEBUG ";d",                   "0",        OPTION_BOOLEAN,    "enable/disable debugger" },
27   { OSDOPTION_DEBUGGER,                     OSDOPTVAL_AUTO,      OPTION_STRING,    "debugger used : " },
28   { OSDOPTION_OSLOG,                        "0",        OPTION_BOOLEAN,    "output error.log data to the system debugger" },
29   { OSDOPTION_WATCHDOG ";wdog",             "0",        OPTION_INTEGER,    "force the program to terminate if no updates within specified number of seconds" },
5    // debugging options
6    { NULL,                                   NULL,       OPTION_HEADER,     "OSD DEBUGGING OPTIONS" },
7    { OSDOPTION_LOG,                          "0",        OPTION_BOOLEAN,    "generate an error.log file" },
8    { OSDOPTION_VERBOSE ";v",                 "0",        OPTION_BOOLEAN,    "display additional diagnostic information" },
9    { OSDOPTION_DEBUG ";d",                   "0",        OPTION_BOOLEAN,    "enable/disable debugger" },
10    { OSDOPTION_DEBUGGER,                     OSDOPTVAL_AUTO,      OPTION_STRING,    "debugger used : " },
11    { OSDOPTION_OSLOG,                        "0",        OPTION_BOOLEAN,    "output error.log data to the system debugger" },
12    { OSDOPTION_WATCHDOG ";wdog",             "0",        OPTION_INTEGER,    "force the program to terminate if no updates within specified number of seconds" },
3013
31   // performance options
32   { NULL,                                   NULL,       OPTION_HEADER,     "OSD PERFORMANCE OPTIONS" },
33   { OSDOPTION_MULTITHREADING ";mt",         "0",        OPTION_BOOLEAN,    "enable multithreading; this enables rendering and blitting on a separate thread" },
34   { OSDOPTION_NUMPROCESSORS ";np",          OSDOPTVAL_AUTO,      OPTION_STRING,     "number of processors; this overrides the number the system reports" },
35   { OSDOPTION_BENCH,                        "0",        OPTION_INTEGER,    "benchmark for the given number of emulated seconds; implies -video none -sound none -nothrottle" },
36   // video options
37   { NULL,                                   NULL,       OPTION_HEADER,     "OSD VIDEO OPTIONS" },
14    // performance options
15    { NULL,                                   NULL,       OPTION_HEADER,     "OSD PERFORMANCE OPTIONS" },
16    { OSDOPTION_MULTITHREADING ";mt",         "0",        OPTION_BOOLEAN,    "enable multithreading; this enables rendering and blitting on a separate thread" },
17    { OSDOPTION_NUMPROCESSORS ";np",          OSDOPTVAL_AUTO,      OPTION_STRING,     "number of processors; this overrides the number the system reports" },
18    { OSDOPTION_BENCH,                        "0",        OPTION_INTEGER,    "benchmark for the given number of emulated seconds; implies -video none -sound none -nothrottle" },
19    // video options
20    { NULL,                                   NULL,       OPTION_HEADER,     "OSD VIDEO OPTIONS" },
3821// OS X can be trusted to have working hardware OpenGL, so default to it on for the best user experience
39   { OSDOPTION_VIDEO,                        OSDOPTVAL_AUTO,     OPTION_STRING,     "video output method: " },
40   { OSDOPTION_NUMSCREENS "(1-4)",           "1",        OPTION_INTEGER,    "number of screens to create; usually, you want just one" },
41   { OSDOPTION_WINDOW ";w",                  "0",        OPTION_BOOLEAN,    "enable window mode; otherwise, full screen mode is assumed" },
42   { OSDOPTION_MAXIMIZE ";max",              "1",        OPTION_BOOLEAN,    "default to maximized windows; otherwise, windows will be minimized" },
43   { OSDOPTION_KEEPASPECT ";ka",             "1",        OPTION_BOOLEAN,    "constrain to the proper aspect ratio" },
44   { OSDOPTION_UNEVENSTRETCH ";ues",         "1",        OPTION_BOOLEAN,    "allow non-integer stretch factors" },
45   { OSDOPTION_WAITVSYNC ";vs",              "0",        OPTION_BOOLEAN,    "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" },
46   { OSDOPTION_SYNCREFRESH ";srf",           "0",        OPTION_BOOLEAN,    "enable using the start of VBLANK for throttling instead of the game time" },
22    { OSDOPTION_VIDEO,                        OSDOPTVAL_AUTO,     OPTION_STRING,     "video output method: " },
23    { OSDOPTION_NUMSCREENS "(1-4)",           "1",        OPTION_INTEGER,    "number of screens to create; usually, you want just one" },
24    { OSDOPTION_WINDOW ";w",                  "0",        OPTION_BOOLEAN,    "enable window mode; otherwise, full screen mode is assumed" },
25    { OSDOPTION_MAXIMIZE ";max",              "1",        OPTION_BOOLEAN,    "default to maximized windows; otherwise, windows will be minimized" },
26    { OSDOPTION_KEEPASPECT ";ka",             "1",        OPTION_BOOLEAN,    "constrain to the proper aspect ratio" },
27    { OSDOPTION_UNEVENSTRETCH ";ues",         "1",        OPTION_BOOLEAN,    "allow non-integer stretch factors" },
28    { OSDOPTION_WAITVSYNC ";vs",              "0",        OPTION_BOOLEAN,    "enable waiting for the start of VBLANK before flipping screens; reduces tearing effects" },
29    { OSDOPTION_SYNCREFRESH ";srf",           "0",        OPTION_BOOLEAN,    "enable using the start of VBLANK for throttling instead of the game time" },
4730
48   // per-window options
49   { NULL,                                   NULL,             OPTION_HEADER,    "OSD PER-WINDOW VIDEO OPTIONS" },
50   { OSDOPTION_SCREEN,                   OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the first screen; 'auto' here will try to make a best guess" },
51   { OSDOPTION_ASPECT ";screen_aspect",  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio for all screens; 'auto' here will try to make a best guess" },
52   { OSDOPTION_RESOLUTION ";r",          OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution for all screens; format is <width>x<height>[@<refreshrate>] or 'auto'" },
53   { OSDOPTION_VIEW,                     OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for all screens" },
31    // per-window options
32    { NULL,                                   NULL,             OPTION_HEADER,    "OSD PER-WINDOW VIDEO OPTIONS" },
33    { OSDOPTION_SCREEN,                   OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the first screen; 'auto' here will try to make a best guess" },
34    { OSDOPTION_ASPECT ";screen_aspect",  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio for all screens; 'auto' here will try to make a best guess" },
35    { OSDOPTION_RESOLUTION ";r",          OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution for all screens; format is <width>x<height>[@<refreshrate>] or 'auto'" },
36    { OSDOPTION_VIEW,                     OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for all screens" },
5437
55   { OSDOPTION_SCREEN "0",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the first screen; 'auto' here will try to make a best guess" },
56   { OSDOPTION_ASPECT "0",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the first screen; 'auto' here will try to make a best guess" },
57   { OSDOPTION_RESOLUTION "0;r0",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the first screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
58   { OSDOPTION_VIEW "0",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the first screen" },
38    { OSDOPTION_SCREEN "0",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the first screen; 'auto' here will try to make a best guess" },
39    { OSDOPTION_ASPECT "0",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the first screen; 'auto' here will try to make a best guess" },
40    { OSDOPTION_RESOLUTION "0;r0",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the first screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
41    { OSDOPTION_VIEW "0",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the first screen" },
5942
60   { OSDOPTION_SCREEN "1",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the second screen; 'auto' here will try to make a best guess" },
61   { OSDOPTION_ASPECT "1",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the second screen; 'auto' here will try to make a best guess" },
62   { OSDOPTION_RESOLUTION "1;r1",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the second screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
63   { OSDOPTION_VIEW "1",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the second screen" },
43    { OSDOPTION_SCREEN "1",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the second screen; 'auto' here will try to make a best guess" },
44    { OSDOPTION_ASPECT "1",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the second screen; 'auto' here will try to make a best guess" },
45    { OSDOPTION_RESOLUTION "1;r1",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the second screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
46    { OSDOPTION_VIEW "1",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the second screen" },
6447
65   { OSDOPTION_SCREEN "2",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the third screen; 'auto' here will try to make a best guess" },
66   { OSDOPTION_ASPECT "2",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the third screen; 'auto' here will try to make a best guess" },
67   { OSDOPTION_RESOLUTION "2;r2",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the third screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
68   { OSDOPTION_VIEW "2",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the third screen" },
48    { OSDOPTION_SCREEN "2",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the third screen; 'auto' here will try to make a best guess" },
49    { OSDOPTION_ASPECT "2",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the third screen; 'auto' here will try to make a best guess" },
50    { OSDOPTION_RESOLUTION "2;r2",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the third screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
51    { OSDOPTION_VIEW "2",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the third screen" },
6952
70   { OSDOPTION_SCREEN "3",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the fourth screen; 'auto' here will try to make a best guess" },
71   { OSDOPTION_ASPECT "3",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" },
72   { OSDOPTION_RESOLUTION "3;r3",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the fourth screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
73   { OSDOPTION_VIEW "3",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the fourth screen" },
53    { OSDOPTION_SCREEN "3",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "explicit name of the fourth screen; 'auto' here will try to make a best guess" },
54    { OSDOPTION_ASPECT "3",                  OSDOPTVAL_AUTO,   OPTION_STRING,    "aspect ratio of the fourth screen; 'auto' here will try to make a best guess" },
55    { OSDOPTION_RESOLUTION "3;r3",        OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred resolution of the fourth screen; format is <width>x<height>[@<refreshrate>] or 'auto'" },
56    { OSDOPTION_VIEW "3",                    OSDOPTVAL_AUTO,   OPTION_STRING,    "preferred view for the fourth screen" },
7457
75   // full screen options
76   { NULL,                                   NULL,  OPTION_HEADER,     "OSD FULL SCREEN OPTIONS" },
77   { OSDOPTION_SWITCHRES,                    "0",   OPTION_BOOLEAN,    "enable resolution switching" },
58    // full screen options
59    { NULL,                                   NULL,  OPTION_HEADER,     "OSD FULL SCREEN OPTIONS" },
60    { OSDOPTION_SWITCHRES,                    "0",   OPTION_BOOLEAN,    "enable resolution switching" },
7861
79   // sound options
80   { NULL,                                   NULL,  OPTION_HEADER,     "OSD SOUND OPTIONS" },
81   { OSDOPTION_SOUND,                        OSDOPTVAL_AUTO, OPTION_STRING,     "sound output method: " },
82   { OSDOPTION_AUDIO_LATENCY "(1-5)",        "2",   OPTION_INTEGER,    "set audio latency (increase to reduce glitches, decrease for responsiveness)" },
62    // sound options
63    { NULL,                                   NULL,  OPTION_HEADER,     "OSD SOUND OPTIONS" },
64    { OSDOPTION_SOUND,                        OSDOPTVAL_AUTO, OPTION_STRING,     "sound output method: " },
65    { OSDOPTION_AUDIO_LATENCY "(1-5)",        "2",   OPTION_INTEGER,    "set audio latency (increase to reduce glitches, decrease for responsiveness)" },
8366
84   // End of list
85   { NULL }
67    // End of list
68    { NULL }
8669};
87
88//============================================================
89//  osd_options
90//============================================================
91
92osd_options::osd_options()
93{
94}
95
96
97void osd_options::add_osd_options()
98{
99   add_entries(s_option_entries);
100}
101
102//-------------------------------------------------
103//  osd_interface - constructor
104//-------------------------------------------------
105
106osd_interface::osd_interface()
107   : m_machine(NULL),
108      m_sound(NULL),
109      m_debugger(NULL)
110
111{
112}
113
114void osd_interface::update_option(osd_options &options, const char * key, dynamic_array<const char *> &values)
115{
116   astring current_value(options.description(key));
117   astring new_option_value("");
118   for (int index = 0; index < values.count(); index++)
119   {
120      astring t(values[index]);
121      if (new_option_value.len() > 0)
122      {
123         if( index != (values.count()-1))
124            new_option_value.cat(", ");
125         else
126            new_option_value.cat(" or ");
127      }
128      new_option_value.cat(t);
129   }
130   // TODO: core_strdup() is leaked
131   options.set_description(key, core_strdup(current_value.cat(new_option_value).cstr()));
132}
133
134void osd_interface::register_options(osd_options &options)
135{
136   // Register video options and update options
137   video_options_add("none", NULL);
138   video_register();
139   update_option(options, OSDOPTION_VIDEO, m_video_names);
140
141   // Register sound options and update options
142   sound_options_add("none", OSD_SOUND_NONE);
143   sound_register();
144   update_option(options, OSDOPTION_SOUND, m_sound_names);
145
146   // Register debugger options and update options
147   debugger_options_add("none", OSD_DEBUGGER_NONE);
148   debugger_options_add("internal", OSD_DEBUGGER_INTERNAL);
149   debugger_register();
150   update_option(options, OSDOPTION_DEBUGGER, m_debugger_names);
151}
152
153
154//-------------------------------------------------
155//  osd_interface - destructor
156//-------------------------------------------------
157
158osd_interface::~osd_interface()
159{
160   for(int i= 0; i < m_video_names.count(); ++i)
161      osd_free(const_cast<char*>(m_video_names[i]));
162   //m_video_options,reset();
163
164   for(int i= 0; i < m_sound_names.count(); ++i)
165      osd_free(const_cast<char*>(m_sound_names[i]));
166   m_sound_options.reset();
167
168   for(int i= 0; i < m_debugger_names.count(); ++i)
169      osd_free(const_cast<char*>(m_debugger_names[i]));
170   m_debugger_options.reset();
171}
172
173
174//-------------------------------------------------
175//  init - initialize the OSD system.
176//-------------------------------------------------
177
178void osd_interface::init(running_machine &machine)
179{
180   //
181   // This function is responsible for initializing the OSD-specific
182   // video and input functionality, and registering that functionality
183   // with the MAME core.
184   //
185   // In terms of video, this function is expected to create one or more
186   // render_targets that will be used by the MAME core to provide graphics
187   // data to the system. Although it is possible to do this later, the
188   // assumption in the MAME core is that the user interface will be
189   // visible starting at init() time, so you will have some work to
190   // do to avoid these assumptions.
191   //
192   // In terms of input, this function is expected to enumerate all input
193   // devices available and describe them to the MAME core by adding
194   // input devices and their attached items (buttons/axes) via the input
195   // system.
196   //
197   // Beyond these core responsibilities, init() should also initialize
198   // any other OSD systems that require information about the current
199   // running_machine.
200   //
201   // This callback is also the last opportunity to adjust the options
202   // before they are consumed by the rest of the core.
203   //
204   // Future work/changes:
205   //
206   // Audio initialization may eventually move into here as well,
207   // instead of relying on independent callbacks from each system.
208   //
209
210   m_machine = &machine;
211
212   osd_options &options = downcast<osd_options &>(machine.options());
213   // extract the verbose printing option
214   if (options.verbose())
215      g_print_verbose = true;
216
217   // ensure we get called on the way out
218   machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_interface::osd_exit), this));
219}
220
221
222//-------------------------------------------------
223//  update - periodic system update
224//-------------------------------------------------
225
226void osd_interface::update(bool skip_redraw)
227{
228   //
229   // This method is called periodically to flush video updates to the
230   // screen, and also to allow the OSD a chance to update other systems
231   // on a regular basis. In general this will be called at the frame
232   // rate of the system being run; however, it may be called at more
233   // irregular intervals in some circumstances (e.g., multi-screen games
234   // or games with asynchronous updates).
235   //
236}
237
238
239//-------------------------------------------------
240//  init_debugger - perform debugger-specific
241//  initialization
242//-------------------------------------------------
243
244void osd_interface::init_debugger()
245{
246   //
247   // Unlike init() above, this method is only called if the debugger
248   // is active. This gives any OSD debugger interface a chance to
249   // create all of its structures.
250   //
251   osd_debugger_type debugger = m_debugger_options.find(machine().options().debugger());
252   if (debugger==NULL)
253   {
254      osd_printf_warning("debugger_init: option %s not found switching to auto\n",machine().options().debugger());
255      debugger = m_debugger_options.find("auto");
256   }
257   m_debugger = (*debugger)(*this);
258
259   m_debugger->init_debugger();
260}
261
262
263//-------------------------------------------------
264//  wait_for_debugger - wait for a debugger
265//  command to be processed
266//-------------------------------------------------
267
268void osd_interface::wait_for_debugger(device_t &device, bool firststop)
269{
270   //
271   // When implementing an OSD-driver debugger, this method should be
272   // overridden to wait for input, process it, and return. It will be
273   // called repeatedly until a command is issued that resumes
274   // execution.
275   //
276   m_debugger->wait_for_debugger(device, firststop);
277}
278
279void osd_interface::debugger_update()
280{
281   if (m_debugger) m_debugger->debugger_update();
282}
283
284void osd_interface::debugger_exit()
285{
286   if (m_debugger)
287   {
288      m_debugger->debugger_exit();
289      global_free(m_debugger);
290      m_debugger = NULL;
291   }
292}
293
294//-------------------------------------------------
295//  update_audio_stream - update the stereo audio
296//  stream
297//-------------------------------------------------
298
299void osd_interface::update_audio_stream(const INT16 *buffer, int samples_this_frame)
300{
301   //
302   // This method is called whenever the system has new audio data to stream.
303   // It provides an array of stereo samples in L-R order which should be
304   // output at the configured sample_rate.
305   //
306   m_sound->update_audio_stream(buffer,samples_this_frame);
307}
308
309
310//-------------------------------------------------
311//  set_mastervolume - set the system volume
312//-------------------------------------------------
313
314void osd_interface::set_mastervolume(int attenuation)
315{
316   //
317   // Attenuation is the attenuation in dB (a negative number).
318   // To convert from dB to a linear volume scale do the following:
319   //    volume = MAX_VOLUME;
320   //    while (attenuation++ < 0)
321   //       volume /= 1.122018454;      //  = (10 ^ (1/20)) = 1dB
322   //
323   m_sound->set_mastervolume(attenuation);
324}
325
326
327//-------------------------------------------------
328//  customize_input_type_list - provide OSD
329//  additions/modifications to the input list
330//-------------------------------------------------
331
332void osd_interface::customize_input_type_list(simple_list<input_type_entry> &typelist)
333{
334   //
335   // inptport.c defines some general purpose defaults for key and joystick bindings.
336   // They may be further adjusted by the OS dependent code to better match the
337   // available keyboard, e.g. one could map pause to the Pause key instead of P, or
338   // snapshot to PrtScr instead of F12. Of course the user can further change the
339   // settings to anything he/she likes.
340   //
341   // This function is called on startup, before reading the configuration from disk.
342   // Scan the list, and change the keys/joysticks you want.
343   //
344}
345
346
347//-------------------------------------------------
348//  font_open - attempt to "open" a handle to the
349//  font with the given name
350//-------------------------------------------------
351
352osd_font osd_interface::font_open(const char *name, int &height)
353{
354   return NULL;
355}
356
357
358//-------------------------------------------------
359//  font_close - release resources associated with
360//  a given OSD font
361//-------------------------------------------------
362
363void osd_interface::font_close(osd_font font)
364{
365}
366
367
368//-------------------------------------------------
369//  font_get_bitmap - allocate and populate a
370//  BITMAP_FORMAT_ARGB32 bitmap containing the
371//  pixel values rgb_t(0xff,0xff,0xff,0xff)
372//  or rgb_t(0x00,0xff,0xff,0xff) for each
373//  pixel of a black & white font
374//-------------------------------------------------
375
376bool osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs)
377{
378   return false;
379}
380
381//-------------------------------------------------
382//  get_slider_list - allocate and populate a
383//  list of OS-dependent slider values.
384//-------------------------------------------------
385void *osd_interface::get_slider_list()
386{
387   return NULL;
388}
389
390void osd_interface::init_subsystems()
391{
392   if (!video_init())
393   {
394      video_exit();
395      osd_printf_error("video_init: Initialization failed!\n\n\n");
396      fflush(stderr);
397      fflush(stdout);
398      exit(-1);
399   }
400
401   sound_init();
402   input_init();
403   // we need pause callbacks
404   machine().add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(osd_interface::input_pause), this));
405   machine().add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(osd_interface::input_resume), this));
406
407   output_init();
408#ifdef USE_NETWORK
409   network_init();
410#endif
411   midi_init();
412}
413
414bool osd_interface::video_init()
415{
416   return true;
417}
418
419bool osd_interface::window_init()
420{
421   return true;
422}
423
424bool osd_interface::sound_init()
425{
426   osd_sound_type sound = m_sound_options.find(machine().options().sound());
427   if (sound==NULL)
428   {
429      osd_printf_warning("sound_init: option %s not found switching to auto\n",machine().options().sound());
430      sound = m_sound_options.find("auto");
431   }
432   m_sound = (*sound)(*this);
433   return true;
434}
435
436bool osd_interface::no_sound()
437{
438   return (strcmp(machine().options().sound(),"none")==0) ? true : false;
439}
440
441void osd_interface::video_register()
442{
443}
444
445void osd_interface::sound_register()
446{
447}
448
449void osd_interface::debugger_register()
450{
451}
452
453bool osd_interface::input_init()
454{
455   return true;
456}
457
458void osd_interface::input_pause()
459{
460}
461
462void osd_interface::input_resume()
463{
464}
465
466bool osd_interface::output_init()
467{
468   return true;
469}
470
471bool osd_interface::network_init()
472{
473   return true;
474}
475
476void osd_interface::exit_subsystems()
477{
478   video_exit();
479   sound_exit();
480   input_exit();
481   output_exit();
482   #ifdef USE_NETWORK
483   network_exit();
484   #endif
485   midi_exit();
486   debugger_exit();
487}
488
489void osd_interface::video_exit()
490{
491}
492
493void osd_interface::window_exit()
494{
495}
496
497void osd_interface::sound_exit()
498{
499   global_free(m_sound);
500}
501
502void osd_interface::input_exit()
503{
504}
505
506void osd_interface::output_exit()
507{
508}
509
510void osd_interface::network_exit()
511{
512}
513
514void osd_interface::osd_exit()
515{
516   exit_subsystems();
517}
518
519void osd_interface::video_options_add(const char *name, void *type)
520{
521   //m_video_options.add(name, type, false);
522   m_video_names.append(core_strdup(name));
523}
524
525void osd_interface::sound_options_add(const char *name, osd_sound_type type)
526{
527   m_sound_options.add(name, type, false);
528   m_sound_names.append(core_strdup(name));
529}
530
531void osd_interface::debugger_options_add(const char *name, osd_debugger_type type)
532{
533   m_debugger_options.add(name, type, false);
534   m_debugger_names.append(core_strdup(name));
535}
536//-------------------------------------------------
537//  osd_sound_interface - constructor
538//-------------------------------------------------
539
540osd_sound_interface::osd_sound_interface(const osd_interface &osd)
541   : m_osd(osd)
542{
543}
544
545//-------------------------------------------------
546//  osd_sound_interface - destructor
547//-------------------------------------------------
548
549osd_sound_interface::~osd_sound_interface()
550{
551}
552
553//-------------------------------------------------
554//  osd_debugger_interface - constructor
555//-------------------------------------------------
556
557osd_debugger_interface::osd_debugger_interface(const osd_interface &osd)
558   : m_osd(osd)
559{
560}
561
562//-------------------------------------------------
563//  osd_debugger_interface - destructor
564//-------------------------------------------------
565
566osd_debugger_interface::~osd_debugger_interface()
567{
568}
trunk/src/osd/osdepend.h
r242864r242865
1616#include "emucore.h"
1717#include "osdcore.h"
1818#include "unicode.h"
19#include "options.h"
2019
20// forward references
21class input_type_entry;     // FIXME: including emu.h does not work because emu.h includes osdepend.h
22
2123//============================================================
2224//  Defines
2325//============================================================
2426
27/* FIXME: void cli_frontend::listnetworkadapters should be
28 * moved here.
29 */
30#include "options.h"
31
2532#define OSDOPTION_LOG                   "log"
2633#define OSDOPTION_VERBOSE               "verbose"
2734#define OSDOPTION_DEBUG                 "debug"
r242864r242865
5865//  TYPE DEFINITIONS
5966//============================================================
6067
68/* FIXME: core_options inherits from osd_options. This will force any
69 * future osd implementation to use the options below. Actually, these
70 * options are *private* to the osd_core. This object should actually be an
71 * accessor object. Later ...
72 */
73
6174class osd_options : public core_options
6275{
6376public:
64   // construction/destruction
65   osd_options();
77    // construction/destruction
78    osd_options() : core_options() {};
6679
67   // debugging options
68   bool verbose() const { return bool_value(OSDOPTION_VERBOSE); }
69   bool log() const { return bool_value(OSDOPTION_LOG); }
70   bool debug() const { return bool_value(OSDOPTION_DEBUG); }
71   const char *debugger() const { return value(OSDOPTION_DEBUGGER); }
72   bool oslog() const { return bool_value(OSDOPTION_OSLOG); }
73   int watchdog() const { return int_value(OSDOPTION_WATCHDOG); }
80    // debugging options
81    bool verbose() const { return bool_value(OSDOPTION_VERBOSE); }
82    bool log() const { return bool_value(OSDOPTION_LOG); }
83    bool debug() const { return bool_value(OSDOPTION_DEBUG); }
84    const char *debugger() const { return value(OSDOPTION_DEBUGGER); }
85    bool oslog() const { return bool_value(OSDOPTION_OSLOG); }
86    int watchdog() const { return int_value(OSDOPTION_WATCHDOG); }
7487
75   // performance options
76   bool multithreading() const { return bool_value(OSDOPTION_MULTITHREADING); }
77   const char *numprocessors() const { return value(OSDOPTION_NUMPROCESSORS); }
78   int bench() const { return int_value(OSDOPTION_BENCH); }
88    // performance options
89    bool multithreading() const { return bool_value(OSDOPTION_MULTITHREADING); }
90    const char *numprocessors() const { return value(OSDOPTION_NUMPROCESSORS); }
91    int bench() const { return int_value(OSDOPTION_BENCH); }
7992
80   // video options
81   const char *video() const { return value(OSDOPTION_VIDEO); }
82   int numscreens() const { return int_value(OSDOPTION_NUMSCREENS); }
83   bool window() const { return bool_value(OSDOPTION_WINDOW); }
84   bool maximize() const { return bool_value(OSDOPTION_MAXIMIZE); }
85   bool keep_aspect() const { return bool_value(OSDOPTION_KEEPASPECT); }
86   bool uneven_stretch() const { return bool_value(OSDOPTION_UNEVENSTRETCH); }
87   bool wait_vsync() const { return bool_value(OSDOPTION_WAITVSYNC); }
88   bool sync_refresh() const { return bool_value(OSDOPTION_SYNCREFRESH); }
93    // video options
94    const char *video() const { return value(OSDOPTION_VIDEO); }
95    int numscreens() const { return int_value(OSDOPTION_NUMSCREENS); }
96    bool window() const { return bool_value(OSDOPTION_WINDOW); }
97    bool maximize() const { return bool_value(OSDOPTION_MAXIMIZE); }
98    bool keep_aspect() const { return bool_value(OSDOPTION_KEEPASPECT); }
99    bool uneven_stretch() const { return bool_value(OSDOPTION_UNEVENSTRETCH); }
100    bool wait_vsync() const { return bool_value(OSDOPTION_WAITVSYNC); }
101    bool sync_refresh() const { return bool_value(OSDOPTION_SYNCREFRESH); }
89102
90   // per-window options
91   const char *screen() const { return value(OSDOPTION_SCREEN); }
92   const char *aspect() const { return value(OSDOPTION_ASPECT); }
93   const char *resolution() const { return value(OSDOPTION_RESOLUTION); }
94   const char *view() const { return value(OSDOPTION_VIEW); }
95   const char *screen(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_SCREEN, index)); }
96   const char *aspect(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_ASPECT, index)); }
97   const char *resolution(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_RESOLUTION, index)); }
98   const char *view(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_VIEW, index)); }
103    // per-window options
104    const char *screen() const { return value(OSDOPTION_SCREEN); }
105    const char *aspect() const { return value(OSDOPTION_ASPECT); }
106    const char *resolution() const { return value(OSDOPTION_RESOLUTION); }
107    const char *view() const { return value(OSDOPTION_VIEW); }
108    const char *screen(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_SCREEN, index)); }
109    const char *aspect(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_ASPECT, index)); }
110    const char *resolution(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_RESOLUTION, index)); }
111    const char *view(int index) const { astring temp; return value(temp.format("%s%d", OSDOPTION_VIEW, index)); }
99112
100   // full screen options
101   bool switch_res() const { return bool_value(OSDOPTION_SWITCHRES); }
113    // full screen options
114    bool switch_res() const { return bool_value(OSDOPTION_SWITCHRES); }
102115
103   // sound options
104   const char *sound() const { return value(OSDOPTION_SOUND); }
105   int audio_latency() const { return int_value(OSDOPTION_AUDIO_LATENCY); }
116    // sound options
117    const char *sound() const { return value(OSDOPTION_SOUND); }
118    int audio_latency() const { return int_value(OSDOPTION_AUDIO_LATENCY); }
106119
107   void add_osd_options();
120    void add_osd_options()
121    {
122        this->add_entries(s_option_entries);
123    }
108124private:
109   static const options_entry s_option_entries[];
125    static const options_entry s_option_entries[];
110126};
111127
112128
113// forward references
114class input_type_entry;
115class device_t;
116class osd_interface;
117class osd_sound_interface;
118class osd_debugger_interface;
119
129// FIXME: We can do better than this
120130typedef void *osd_font;
121131
122// a osd_sound_type is simply a pointer to its alloc function
123typedef osd_sound_interface *(*osd_sound_type)(const osd_interface &osd);
124
125// a osd_sound_type is simply a pointer to its alloc function
126typedef osd_debugger_interface *(*osd_debugger_type)(const osd_interface &osd);
127
128
129132// ======================> osd_interface
130133
131134// description of the currently-running machine
132135class osd_interface
133136{
134137public:
135   // construction/destruction
136   osd_interface();
137   virtual ~osd_interface();
138138
139   void register_options(osd_options &options);
140
141   // getters
142   running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
143
144139   // general overridables
145   virtual void init(running_machine &machine);
146   virtual void update(bool skip_redraw);
140   virtual void init(running_machine &machine) = 0;
141   virtual void update(bool skip_redraw) = 0;
147142
148143   // debugger overridables
149   void init_debugger();
150   void wait_for_debugger(device_t &device, bool firststop);
151   void debugger_update();
152   void debugger_exit();
153   virtual void debugger_register();
144   virtual void init_debugger() = 0;
145   virtual void wait_for_debugger(device_t &device, bool firststop) = 0;
154146
155147   // audio overridables
156   void update_audio_stream(const INT16 *buffer, int samples_this_frame);
157   void set_mastervolume(int attenuation);
148   virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame) = 0;
149   virtual void set_mastervolume(int attenuation) = 0;
150   virtual bool no_sound() = 0;
158151
152
159153   // input overridables
160   virtual void customize_input_type_list(simple_list<input_type_entry> &typelist);
154   virtual void customize_input_type_list(simple_list<input_type_entry> &typelist) = 0;
161155
162156   // font overridables
163   virtual osd_font font_open(const char *name, int &height);
164   virtual void font_close(osd_font font);
165   virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs);
157   virtual osd_font font_open(const char *name, int &height) = 0;
158   virtual void font_close(osd_font font) = 0;
159   virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs) = 0;
166160
167161   // video overridables
168   virtual void *get_slider_list();
162   virtual void *get_slider_list() = 0; // FIXME: returns slider_state *
169163
170164   // midi overridables
171   // FIXME: this should return a list of devices, not list them on stdout
172   virtual void list_midi_devices(void);
165   // FIXME: this should return a list of devices, not list them on stdout, even better
166   // move this to OSD_OPTIONS
167   virtual void list_midi_devices(void) = 0;
173168
174   // FIXME: everything below seems to be osd specific and not part of
175   //        this INTERFACE but part of the osd IMPLEMENTATION
169    virtual void list_network_adapters() = 0;
176170
177   void init_subsystems();
178
179   virtual bool video_init();
180   virtual void video_register();
181   virtual bool window_init();
182
183   bool sound_init();
184   virtual void sound_register();
185   bool no_sound();
186
187   virtual bool input_init();
188   virtual void input_pause();
189   virtual void input_resume();
190   virtual bool output_init();
191   virtual bool network_init();
192   virtual bool midi_init();
193
194   void exit_subsystems();
195   virtual void video_exit();
196   virtual void window_exit();
197   void sound_exit();
198   virtual void input_exit();
199   virtual void output_exit();
200   virtual void network_exit();
201   virtual void midi_exit();
202
203   virtual void osd_exit();
204
205   void video_options_add(const char *name, void *type);
206   void sound_options_add(const char *name, osd_sound_type type);
207   void debugger_options_add(const char *name, osd_debugger_type type);
208
209private:
210   // internal state
211   running_machine *   m_machine;
212
213   void update_option(osd_options &options, const char * key, dynamic_array<const char *> &values);
214
215protected:
216   osd_sound_interface* m_sound;
217   osd_debugger_interface* m_debugger;
218private:
219   //tagmap_t<osd_video_type>  m_video_options;
220   dynamic_array<const char *> m_video_names;
221   tagmap_t<osd_sound_type>  m_sound_options;
222   dynamic_array<const char *> m_sound_names;
223   tagmap_t<osd_debugger_type>  m_debugger_options;
224   dynamic_array<const char *> m_debugger_names;
225171};
226172
227class osd_sound_interface
228{
229public:
230   // construction/destruction
231   osd_sound_interface(const osd_interface &osd);
232   virtual ~osd_sound_interface();
233
234   virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame) = 0;
235   virtual void set_mastervolume(int attenuation) = 0;
236protected:
237   const osd_interface& m_osd;
238};
239
240// this template function creates a stub which constructs a sound subsystem
241template<class _DeviceClass>
242osd_sound_interface *osd_sound_creator(const osd_interface &osd)
243{
244   return global_alloc(_DeviceClass(osd));
245}
246
247class osd_debugger_interface
248{
249public:
250   // construction/destruction
251   osd_debugger_interface(const osd_interface &osd);
252   virtual ~osd_debugger_interface();
253
254   virtual void init_debugger() = 0;
255   virtual void wait_for_debugger(device_t &device, bool firststop) = 0;
256   virtual void debugger_update() = 0;
257   virtual void debugger_exit() = 0;
258
259protected:
260   const osd_interface& m_osd;
261};
262
263// this template function creates a stub which constructs a debugger
264template<class _DeviceClass>
265osd_debugger_interface *osd_debugger_creator(const osd_interface &osd)
266{
267   return global_alloc(_DeviceClass(osd));
268}
269
270173#endif  /* __OSDEPEND_H__ */
trunk/src/osd/sdl/osdsdl.h
r242864r242865
55
66#include "watchdog.h"
77#include "clifront.h"
8#include "modules/lib/osdobj_common.h"
89
910//============================================================
1011//  System dependent defines
r242864r242865
176177};
177178
178179
179class sdl_osd_interface : public osd_interface
180class sdl_osd_interface : public osd_common_t
180181{
181182public:
182183   // construction/destruction
r242864r242865
208209   #ifdef USE_NETWORK
209210   virtual bool network_init();
210211   #endif
212    //virtual bool midi_init();
211213
212214   virtual void video_exit();
213215   virtual void window_exit();
r242864r242865
216218   #ifdef USE_NETWORK
217219   virtual void network_exit();
218220   #endif
221    //virtual void midi_exit();
219222
220223private:
221224   virtual void osd_exit();
trunk/src/osd/sdl/output.c
r242864r242865
8686      output = fdopen(fildes, "w");
8787
8888      osd_printf_verbose("output: opened output notifier file %s\n", SDLMAME_OUTPUT);
89      fprintf(output, "MAME " PID_FMT " START %s\n", osd_getpid(), machine().system().name);
89      fprintf(output, "MAME " PID_FMT " START %s\n", osd_getpid(), this->machine().system().name);
9090      fflush(output);
9191   }
9292
trunk/src/osd/sdl/sdl.mak
r242864r242865
432432   $(SDLOBJ)/window.o \
433433   $(SDLOBJ)/output.o \
434434   $(SDLOBJ)/watchdog.o \
435   $(OSDOBJ)/modules/lib/osdobj_common.o  \
435436
436437ifdef NO_USE_MIDI
437438   OSDOBJS += $(OSDOBJ)/modules/midi/none.o
trunk/src/osd/sdl/sdlmain.c
r242864r242865
401401
402402void sdl_osd_interface::osd_exit()
403403{
404   osd_interface::osd_exit();
404   osd_common_t::osd_exit();
405405
406406   if (!SDLMAME_INIT_IN_WORKER_THREAD)
407407   {
r242864r242865
585585void sdl_osd_interface::init(running_machine &machine)
586586{
587587   // call our parent
588   osd_interface::init(machine);
588   osd_common_t::init(machine);
589589
590590   sdl_options &options = downcast<sdl_options &>(machine.options());
591591   const char *stemp;
r242864r242865
681681         exit(-1);
682682      }
683683
684   osd_interface::init_subsystems();
684   osd_common_t::init_subsystems();
685685
686686   if (options.oslog())
687687      machine.add_logerror_callback(output_oslog);
r242864r242865
14391439#endif
14401440#endif
14411441
1442//-------------------------------------------------
1443// FIXME: Doesn't belong here but there's no better
1444//        place currently.
1445//-------------------------------------------------
14461442
1447bool osd_interface::midi_init()
1448{
1449    // this should be done on the OS_level
1450    return osd_midi_init();
1451}
1452
1453//-------------------------------------------------
1454//  list_midi_devices - list available midi devices
1455//-------------------------------------------------
1456
1457void osd_interface::list_midi_devices(void)
1458{
1459    osd_list_midi_devices();
1460}
1461
1462void osd_interface::midi_exit()
1463{
1464    osd_midi_exit();
1465}
trunk/src/osd/windows/windows.mak
r242864r242865
378378   $(WINOBJ)/winmenu.o \
379379   $(WINOBJ)/winmain.o \
380380   $(OSDOBJ)/modules/midi/portmidi.o \
381   $(OSDOBJ)/modules/lib/osdobj_common.o  \
381382
382383ifdef USE_SDL
383384OSDOBJS += \
trunk/src/osd/windows/winmain.c
r242864r242865
572572void windows_osd_interface::init(running_machine &machine)
573573{
574574   // call our parent
575   osd_interface::init(machine);
575   osd_common_t::init(machine);
576576
577577   const char *stemp;
578578   windows_options &options = downcast<windows_options &>(machine.options());
r242864r242865
619619   }
620620
621621   // initialize the subsystems
622   osd_interface::init_subsystems();
622   osd_common_t::init_subsystems();
623623
624624   // notify listeners of screen configuration
625625   astring tempstring;
r242864r242865
680680   // cleanup sockets
681681   win_cleanup_sockets();
682682
683   osd_interface::osd_exit();
683   osd_common_t::osd_exit();
684684
685685   // take down the watchdog thread if it exists
686686   if (watchdog_thread != NULL)
r242864r242865
18241824      Sleep(1);
18251825   }
18261826}
1827
1828//-------------------------------------------------
1829// FIXME: Doesn't belong here but there's no better
1830//        place currently.
1831//-------------------------------------------------
1832
1833bool osd_interface::midi_init()
1834{
1835    // this should be done on the OS_level
1836    return osd_midi_init();
1837}
1838
1839//-------------------------------------------------
1840//  list_midi_devices - list available midi devices
1841//-------------------------------------------------
1842
1843void osd_interface::list_midi_devices(void)
1844{
1845    osd_list_midi_devices();
1846}
1847
1848void osd_interface::midi_exit()
1849{
1850    osd_midi_exit();
1851}
trunk/src/osd/windows/winmain.h
r242864r242865
88
99#include "clifront.h"
1010#include "osdepend.h"
11#include "modules/lib/osdobj_common.h"
1112
1213
1314//============================================================
r242864r242865
234235//  TYPE DEFINITIONS
235236//============================================================
236237
237class windows_osd_interface : public osd_interface
238class windows_osd_interface : public osd_common_t
238239{
239240public:
240241   // construction/destruction


Previous 199869 Revisions Next


© 1997-2024 The MAME Team