trunk/src/osd/modules/lib/osdobj_common.c
| r0 | r242865 | |
| 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 | |
| 18 | extern bool g_print_verbose; |
| 19 | |
| 20 | |
| 21 | //------------------------------------------------- |
| 22 | // osd_interface - constructor |
| 23 | //------------------------------------------------- |
| 24 | |
| 25 | osd_common_t::osd_common_t() |
| 26 | : m_machine(NULL), |
| 27 | m_sound(NULL), |
| 28 | m_debugger(NULL) |
| 29 | |
| 30 | { |
| 31 | } |
| 32 | |
| 33 | void 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 | |
| 53 | void 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 | |
| 77 | osd_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 | |
| 97 | void 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 | |
| 145 | void 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 | |
| 163 | void 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 | |
| 187 | void 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 | |
| 198 | void osd_common_t::debugger_update() |
| 199 | { |
| 200 | if (m_debugger) m_debugger->debugger_update(); |
| 201 | } |
| 202 | |
| 203 | void 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 | |
| 218 | void 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 | |
| 233 | void 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 | |
| 251 | void 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 | |
| 271 | osd_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 | |
| 282 | void 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 | |
| 295 | bool 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 | //------------------------------------------------- |
| 304 | void *osd_common_t::get_slider_list() |
| 305 | { |
| 306 | return NULL; |
| 307 | } |
| 308 | |
| 309 | void 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 | |
| 333 | bool osd_common_t::video_init() |
| 334 | { |
| 335 | return true; |
| 336 | } |
| 337 | |
| 338 | bool osd_common_t::window_init() |
| 339 | { |
| 340 | return true; |
| 341 | } |
| 342 | |
| 343 | bool 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 | |
| 355 | bool osd_common_t::no_sound() |
| 356 | { |
| 357 | return (strcmp(machine().options().sound(),"none")==0) ? true : false; |
| 358 | } |
| 359 | |
| 360 | void osd_common_t::video_register() |
| 361 | { |
| 362 | } |
| 363 | |
| 364 | void osd_common_t::sound_register() |
| 365 | { |
| 366 | } |
| 367 | |
| 368 | void osd_common_t::debugger_register() |
| 369 | { |
| 370 | } |
| 371 | |
| 372 | bool osd_common_t::input_init() |
| 373 | { |
| 374 | return true; |
| 375 | } |
| 376 | |
| 377 | void osd_common_t::input_pause() |
| 378 | { |
| 379 | } |
| 380 | |
| 381 | void osd_common_t::input_resume() |
| 382 | { |
| 383 | } |
| 384 | |
| 385 | bool osd_common_t::output_init() |
| 386 | { |
| 387 | return true; |
| 388 | } |
| 389 | |
| 390 | bool osd_common_t::network_init() |
| 391 | { |
| 392 | return true; |
| 393 | } |
| 394 | |
| 395 | void 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 | |
| 408 | void osd_common_t::video_exit() |
| 409 | { |
| 410 | } |
| 411 | |
| 412 | void osd_common_t::window_exit() |
| 413 | { |
| 414 | } |
| 415 | |
| 416 | void osd_common_t::sound_exit() |
| 417 | { |
| 418 | global_free(m_sound); |
| 419 | } |
| 420 | |
| 421 | void osd_common_t::input_exit() |
| 422 | { |
| 423 | } |
| 424 | |
| 425 | void osd_common_t::output_exit() |
| 426 | { |
| 427 | } |
| 428 | |
| 429 | void osd_common_t::network_exit() |
| 430 | { |
| 431 | } |
| 432 | |
| 433 | void osd_common_t::osd_exit() |
| 434 | { |
| 435 | exit_subsystems(); |
| 436 | } |
| 437 | |
| 438 | void 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 | |
| 444 | void 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 | |
| 450 | void 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 | |
| 456 | bool 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 | |
| 466 | void osd_common_t::list_midi_devices(void) |
| 467 | { |
| 468 | osd_list_midi_devices(); |
| 469 | } |
| 470 | |
| 471 | void osd_common_t::midi_exit() |
| 472 | { |
| 473 | osd_midi_exit(); |
| 474 | } |
| 475 | |
| 476 | //------------------------------------------------- |
| 477 | // osd_sound_interface - constructor |
| 478 | //------------------------------------------------- |
| 479 | |
| 480 | osd_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 | |
| 489 | osd_sound_interface::~osd_sound_interface() |
| 490 | { |
| 491 | } |
| 492 | |
| 493 | //------------------------------------------------- |
| 494 | // osd_debugger_interface - constructor |
| 495 | //------------------------------------------------- |
| 496 | |
| 497 | osd_debugger_interface::osd_debugger_interface(const osd_interface &osd) |
| 498 | : m_osd(osd) |
| 499 | { |
| 500 | } |
| 501 | |
| 502 | //------------------------------------------------- |
| 503 | // osd_debugger_interface - destructor |
| 504 | //------------------------------------------------- |
| 505 | |
| 506 | osd_debugger_interface::~osd_debugger_interface() |
| 507 | { |
| 508 | } |
| 509 | |
trunk/src/osd/modules/lib/osdobj_common.h
| r0 | r242865 | |
| 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 |
| 22 | class input_type_entry; |
| 23 | class device_t; |
| 24 | #endif |
| 25 | |
| 26 | class osd_sound_interface; |
| 27 | class osd_debugger_interface; |
| 28 | |
| 29 | // a osd_sound_type is simply a pointer to its alloc function |
| 30 | typedef 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 |
| 33 | typedef osd_debugger_interface *(*osd_debugger_type)(const osd_interface &osd); |
| 34 | |
| 35 | |
| 36 | // ======================> osd_interface |
| 37 | |
| 38 | // description of the currently-running machine |
| 39 | class osd_common_t : public osd_interface |
| 40 | { |
| 41 | public: |
| 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 | |
| 126 | private: |
| 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 | |
| 132 | protected: |
| 133 | osd_sound_interface* m_sound; |
| 134 | osd_debugger_interface* m_debugger; |
| 135 | private: |
| 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 | |
| 145 | class osd_sound_interface |
| 146 | { |
| 147 | public: |
| 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; |
| 154 | protected: |
| 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 |
| 160 | template<class _DeviceClass> |
| 161 | osd_sound_interface *osd_sound_creator(const osd_interface &osd, running_machine &machine) |
| 162 | { |
| 163 | return global_alloc(_DeviceClass(osd, machine)); |
| 164 | } |
| 165 | |
| 166 | class osd_debugger_interface |
| 167 | { |
| 168 | public: |
| 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 | |
| 178 | protected: |
| 179 | const osd_interface& m_osd; |
| 180 | }; |
| 181 | |
| 182 | // this template function creates a stub which constructs a debugger |
| 183 | template<class _DeviceClass> |
| 184 | osd_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/osdepend.c
| r242864 | r242865 | |
| 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 | 1 | #include "osdepend.h" |
| 14 | | #include "modules/sound/none.h" |
| 15 | | #include "modules/debugger/none.h" |
| 16 | | #include "modules/debugger/debugint.h" |
| 17 | 2 | |
| 18 | | extern bool g_print_verbose; |
| 19 | | |
| 20 | 3 | const options_entry osd_options::s_option_entries[] = |
| 21 | 4 | { |
| 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" }, |
| 30 | 13 | |
| 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" }, |
| 38 | 21 | // 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" }, |
| 47 | 30 | |
| 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" }, |
| 54 | 37 | |
| 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" }, |
| 59 | 42 | |
| 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" }, |
| 64 | 47 | |
| 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" }, |
| 69 | 52 | |
| 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" }, |
| 74 | 57 | |
| 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" }, |
| 78 | 61 | |
| 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)" }, |
| 83 | 66 | |
| 84 | | // End of list |
| 85 | | { NULL } |
| 67 | // End of list |
| 68 | { NULL } |
| 86 | 69 | }; |
| 87 | | |
| 88 | | //============================================================ |
| 89 | | // osd_options |
| 90 | | //============================================================ |
| 91 | | |
| 92 | | osd_options::osd_options() |
| 93 | | { |
| 94 | | } |
| 95 | | |
| 96 | | |
| 97 | | void osd_options::add_osd_options() |
| 98 | | { |
| 99 | | add_entries(s_option_entries); |
| 100 | | } |
| 101 | | |
| 102 | | //------------------------------------------------- |
| 103 | | // osd_interface - constructor |
| 104 | | //------------------------------------------------- |
| 105 | | |
| 106 | | osd_interface::osd_interface() |
| 107 | | : m_machine(NULL), |
| 108 | | m_sound(NULL), |
| 109 | | m_debugger(NULL) |
| 110 | | |
| 111 | | { |
| 112 | | } |
| 113 | | |
| 114 | | void 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 | | |
| 134 | | void 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 | | |
| 158 | | osd_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 | | |
| 178 | | void 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 | | |
| 226 | | void 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 | | |
| 244 | | void 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 | | |
| 268 | | void 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 | | |
| 279 | | void osd_interface::debugger_update() |
| 280 | | { |
| 281 | | if (m_debugger) m_debugger->debugger_update(); |
| 282 | | } |
| 283 | | |
| 284 | | void 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 | | |
| 299 | | void 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 | | |
| 314 | | void 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 | | |
| 332 | | void 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 | | |
| 352 | | osd_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 | | |
| 363 | | void 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 | | |
| 376 | | bool 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 | | //------------------------------------------------- |
| 385 | | void *osd_interface::get_slider_list() |
| 386 | | { |
| 387 | | return NULL; |
| 388 | | } |
| 389 | | |
| 390 | | void 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 | | |
| 414 | | bool osd_interface::video_init() |
| 415 | | { |
| 416 | | return true; |
| 417 | | } |
| 418 | | |
| 419 | | bool osd_interface::window_init() |
| 420 | | { |
| 421 | | return true; |
| 422 | | } |
| 423 | | |
| 424 | | bool 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 | | |
| 436 | | bool osd_interface::no_sound() |
| 437 | | { |
| 438 | | return (strcmp(machine().options().sound(),"none")==0) ? true : false; |
| 439 | | } |
| 440 | | |
| 441 | | void osd_interface::video_register() |
| 442 | | { |
| 443 | | } |
| 444 | | |
| 445 | | void osd_interface::sound_register() |
| 446 | | { |
| 447 | | } |
| 448 | | |
| 449 | | void osd_interface::debugger_register() |
| 450 | | { |
| 451 | | } |
| 452 | | |
| 453 | | bool osd_interface::input_init() |
| 454 | | { |
| 455 | | return true; |
| 456 | | } |
| 457 | | |
| 458 | | void osd_interface::input_pause() |
| 459 | | { |
| 460 | | } |
| 461 | | |
| 462 | | void osd_interface::input_resume() |
| 463 | | { |
| 464 | | } |
| 465 | | |
| 466 | | bool osd_interface::output_init() |
| 467 | | { |
| 468 | | return true; |
| 469 | | } |
| 470 | | |
| 471 | | bool osd_interface::network_init() |
| 472 | | { |
| 473 | | return true; |
| 474 | | } |
| 475 | | |
| 476 | | void 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 | | |
| 489 | | void osd_interface::video_exit() |
| 490 | | { |
| 491 | | } |
| 492 | | |
| 493 | | void osd_interface::window_exit() |
| 494 | | { |
| 495 | | } |
| 496 | | |
| 497 | | void osd_interface::sound_exit() |
| 498 | | { |
| 499 | | global_free(m_sound); |
| 500 | | } |
| 501 | | |
| 502 | | void osd_interface::input_exit() |
| 503 | | { |
| 504 | | } |
| 505 | | |
| 506 | | void osd_interface::output_exit() |
| 507 | | { |
| 508 | | } |
| 509 | | |
| 510 | | void osd_interface::network_exit() |
| 511 | | { |
| 512 | | } |
| 513 | | |
| 514 | | void osd_interface::osd_exit() |
| 515 | | { |
| 516 | | exit_subsystems(); |
| 517 | | } |
| 518 | | |
| 519 | | void 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 | | |
| 525 | | void 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 | | |
| 531 | | void 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 | | |
| 540 | | osd_sound_interface::osd_sound_interface(const osd_interface &osd) |
| 541 | | : m_osd(osd) |
| 542 | | { |
| 543 | | } |
| 544 | | |
| 545 | | //------------------------------------------------- |
| 546 | | // osd_sound_interface - destructor |
| 547 | | //------------------------------------------------- |
| 548 | | |
| 549 | | osd_sound_interface::~osd_sound_interface() |
| 550 | | { |
| 551 | | } |
| 552 | | |
| 553 | | //------------------------------------------------- |
| 554 | | // osd_debugger_interface - constructor |
| 555 | | //------------------------------------------------- |
| 556 | | |
| 557 | | osd_debugger_interface::osd_debugger_interface(const osd_interface &osd) |
| 558 | | : m_osd(osd) |
| 559 | | { |
| 560 | | } |
| 561 | | |
| 562 | | //------------------------------------------------- |
| 563 | | // osd_debugger_interface - destructor |
| 564 | | //------------------------------------------------- |
| 565 | | |
| 566 | | osd_debugger_interface::~osd_debugger_interface() |
| 567 | | { |
| 568 | | } |
trunk/src/osd/osdepend.h
| r242864 | r242865 | |
| 16 | 16 | #include "emucore.h" |
| 17 | 17 | #include "osdcore.h" |
| 18 | 18 | #include "unicode.h" |
| 19 | | #include "options.h" |
| 20 | 19 | |
| 20 | // forward references |
| 21 | class input_type_entry; // FIXME: including emu.h does not work because emu.h includes osdepend.h |
| 22 | |
| 21 | 23 | //============================================================ |
| 22 | 24 | // Defines |
| 23 | 25 | //============================================================ |
| 24 | 26 | |
| 27 | /* FIXME: void cli_frontend::listnetworkadapters should be |
| 28 | * moved here. |
| 29 | */ |
| 30 | #include "options.h" |
| 31 | |
| 25 | 32 | #define OSDOPTION_LOG "log" |
| 26 | 33 | #define OSDOPTION_VERBOSE "verbose" |
| 27 | 34 | #define OSDOPTION_DEBUG "debug" |
| r242864 | r242865 | |
| 58 | 65 | // TYPE DEFINITIONS |
| 59 | 66 | //============================================================ |
| 60 | 67 | |
| 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 | |
| 61 | 74 | class osd_options : public core_options |
| 62 | 75 | { |
| 63 | 76 | public: |
| 64 | | // construction/destruction |
| 65 | | osd_options(); |
| 77 | // construction/destruction |
| 78 | osd_options() : core_options() {}; |
| 66 | 79 | |
| 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); } |
| 74 | 87 | |
| 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); } |
| 79 | 92 | |
| 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); } |
| 89 | 102 | |
| 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)); } |
| 99 | 112 | |
| 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); } |
| 102 | 115 | |
| 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); } |
| 106 | 119 | |
| 107 | | void add_osd_options(); |
| 120 | void add_osd_options() |
| 121 | { |
| 122 | this->add_entries(s_option_entries); |
| 123 | } |
| 108 | 124 | private: |
| 109 | | static const options_entry s_option_entries[]; |
| 125 | static const options_entry s_option_entries[]; |
| 110 | 126 | }; |
| 111 | 127 | |
| 112 | 128 | |
| 113 | | // forward references |
| 114 | | class input_type_entry; |
| 115 | | class device_t; |
| 116 | | class osd_interface; |
| 117 | | class osd_sound_interface; |
| 118 | | class osd_debugger_interface; |
| 119 | | |
| 129 | // FIXME: We can do better than this |
| 120 | 130 | typedef void *osd_font; |
| 121 | 131 | |
| 122 | | // a osd_sound_type is simply a pointer to its alloc function |
| 123 | | typedef osd_sound_interface *(*osd_sound_type)(const osd_interface &osd); |
| 124 | | |
| 125 | | // a osd_sound_type is simply a pointer to its alloc function |
| 126 | | typedef osd_debugger_interface *(*osd_debugger_type)(const osd_interface &osd); |
| 127 | | |
| 128 | | |
| 129 | 132 | // ======================> osd_interface |
| 130 | 133 | |
| 131 | 134 | // description of the currently-running machine |
| 132 | 135 | class osd_interface |
| 133 | 136 | { |
| 134 | 137 | public: |
| 135 | | // construction/destruction |
| 136 | | osd_interface(); |
| 137 | | virtual ~osd_interface(); |
| 138 | 138 | |
| 139 | | void register_options(osd_options &options); |
| 140 | | |
| 141 | | // getters |
| 142 | | running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } |
| 143 | | |
| 144 | 139 | // 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; |
| 147 | 142 | |
| 148 | 143 | // 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; |
| 154 | 146 | |
| 155 | 147 | // 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; |
| 158 | 151 | |
| 152 | |
| 159 | 153 | // 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; |
| 161 | 155 | |
| 162 | 156 | // 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; |
| 166 | 160 | |
| 167 | 161 | // video overridables |
| 168 | | virtual void *get_slider_list(); |
| 162 | virtual void *get_slider_list() = 0; // FIXME: returns slider_state * |
| 169 | 163 | |
| 170 | 164 | // 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; |
| 173 | 168 | |
| 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; |
| 176 | 170 | |
| 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 | | |
| 209 | | private: |
| 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 | | |
| 215 | | protected: |
| 216 | | osd_sound_interface* m_sound; |
| 217 | | osd_debugger_interface* m_debugger; |
| 218 | | private: |
| 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; |
| 225 | 171 | }; |
| 226 | 172 | |
| 227 | | class osd_sound_interface |
| 228 | | { |
| 229 | | public: |
| 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; |
| 236 | | protected: |
| 237 | | const osd_interface& m_osd; |
| 238 | | }; |
| 239 | | |
| 240 | | // this template function creates a stub which constructs a sound subsystem |
| 241 | | template<class _DeviceClass> |
| 242 | | osd_sound_interface *osd_sound_creator(const osd_interface &osd) |
| 243 | | { |
| 244 | | return global_alloc(_DeviceClass(osd)); |
| 245 | | } |
| 246 | | |
| 247 | | class osd_debugger_interface |
| 248 | | { |
| 249 | | public: |
| 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 | | |
| 259 | | protected: |
| 260 | | const osd_interface& m_osd; |
| 261 | | }; |
| 262 | | |
| 263 | | // this template function creates a stub which constructs a debugger |
| 264 | | template<class _DeviceClass> |
| 265 | | osd_debugger_interface *osd_debugger_creator(const osd_interface &osd) |
| 266 | | { |
| 267 | | return global_alloc(_DeviceClass(osd)); |
| 268 | | } |
| 269 | | |
| 270 | 173 | #endif /* __OSDEPEND_H__ */ |