diff options
44 files changed, 770 insertions, 792 deletions
diff --git a/.gitattributes b/.gitattributes index ef5d5520282..5e5de617e3e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8972,7 +8972,6 @@ src/osd/osdmini/osdmini.h svneol=native#text/plain src/osd/osdmini/osdmini.mak svneol=native#text/plain src/osd/osdnet.c svneol=native#text/plain src/osd/osdnet.h svneol=native#text/plain -src/osd/portmedia/pmmidi.inc svneol=native#text/plain src/osd/sdl/README_SDL20.txt svneol=native#text/plain src/osd/sdl/SDL1211_opengl.h svneol=native#text/plain src/osd/sdl/SDLMain_tmpl.h svneol=native#text/plain @@ -8982,7 +8981,6 @@ src/osd/sdl/build.mak svneol=native#text/plain src/osd/sdl/debugosx.h svneol=native#text/plain src/osd/sdl/debugosx.m svneol=native#text/plain src/osd/sdl/debugqt.c svneol=native#text/plain -src/osd/sdl/debugqt.h svneol=native#text/plain src/osd/sdl/debugqtbreakpointswindow.c svneol=native#text/plain src/osd/sdl/debugqtbreakpointswindow.h svneol=native#text/plain src/osd/sdl/debugqtdasmwindow.c svneol=native#text/plain @@ -9027,7 +9025,6 @@ src/osd/sdl/man/mess.6 svneol=LF#text/plain eol=lf src/osd/sdl/man/romcmp.1 svneol=LF#text/plain eol=lf src/osd/sdl/man/testkeys.1 svneol=LF#text/plain eol=lf src/osd/sdl/netdev.c svneol=native#text/plain -src/osd/sdl/netdev.h svneol=native#text/plain src/osd/sdl/netdev_pcap.c svneol=native#text/plain src/osd/sdl/netdev_pcap.h svneol=native#text/plain src/osd/sdl/netdev_pcap_osx.c svneol=native#text/plain @@ -9046,7 +9043,6 @@ src/osd/sdl/sdlfile.c svneol=native#text/plain src/osd/sdl/sdlfile.h svneol=native#text/plain src/osd/sdl/sdlinc.h svneol=native#text/plain src/osd/sdl/sdlmain.c svneol=native#text/plain -src/osd/sdl/sdlmidi.c svneol=native#text/plain src/osd/sdl/sdlmisc_os2.c svneol=native#text/plain src/osd/sdl/sdlmisc_unix.c svneol=native#text/plain src/osd/sdl/sdlmisc_win32.c svneol=native#text/plain @@ -9102,7 +9098,6 @@ src/osd/windows/d3dhlsl.c svneol=native#text/plain src/osd/windows/d3dhlsl.h svneol=native#text/plain src/osd/windows/d3dintf.h svneol=native#text/plain src/osd/windows/debugwin.c svneol=native#text/plain -src/osd/windows/debugwin.h svneol=native#text/plain src/osd/windows/drawd3d.c svneol=native#text/plain src/osd/windows/drawd3d.h svneol=native#text/plain src/osd/windows/drawdd.c svneol=native#text/plain @@ -9118,7 +9113,6 @@ src/osd/windows/mame.ico -text svneol=unset#image/x-icon src/osd/windows/mame.man svneol=CRLF#text/plain eol=crlf src/osd/windows/mame.rc svneol=CRLF#text/plain eol=crlf src/osd/windows/netdev.c svneol=native#text/plain -src/osd/windows/netdev.h svneol=native#text/plain src/osd/windows/netdev_pcap.c svneol=native#text/plain src/osd/windows/netdev_pcap.h svneol=native#text/plain src/osd/windows/osinline.h svneol=native#text/plain @@ -9141,7 +9135,6 @@ src/osd/windows/winfile.h svneol=native#text/plain src/osd/windows/winmain.c svneol=native#text/plain src/osd/windows/winmain.h svneol=native#text/plain src/osd/windows/winmenu.c svneol=native#text/plain -src/osd/windows/winmidi.c svneol=native#text/plain src/osd/windows/winmisc.c svneol=native#text/plain src/osd/windows/winprefix.h svneol=native#text/plain src/osd/windows/winptty.c svneol=native#text/plain @@ -366,6 +366,10 @@ PREFIXSDL = sdl endif endif +ifeq ($(OSD),osdmini) +PREFIXSDL = mini +endif + # 64-bit builds get a '64' suffix ifeq ($(PTR64),1) SUFFIX64 = 64 diff --git a/src/emu/machine.c b/src/emu/machine.c index fb5de58bef5..1a16abded52 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -110,7 +110,7 @@ static char giant_string_buffer[65536] = { 0 }; // running_machine - constructor //------------------------------------------------- -running_machine::running_machine(const machine_config &_config, osd_interface &osd, bool exit_to_game_select) +running_machine::running_machine(const machine_config &_config, osd_interface &osd) : firstcpu(NULL), primary_screen(NULL), debug_flags(0), @@ -125,8 +125,6 @@ running_machine::running_machine(const machine_config &_config, osd_interface &o m_paused(false), m_hard_reset_pending(false), m_exit_pending(false), - m_exit_to_game_select(exit_to_game_select), - m_new_driver_pending(NULL), m_soft_reset_timer(NULL), m_rand_seed(0x9d14abd7), m_ui_active(_config.options().ui_active()), @@ -447,16 +445,7 @@ int running_machine::run(bool firstrun) void running_machine::schedule_exit() { - // if we are in-game but we started with the select game menu, return to that instead - if (m_exit_to_game_select && options().system_name()[0] != 0) - { - options().set_system_name(""); - ui_menu_select_game::force_game_select(*this, &render().ui_container()); - } - - // otherwise, exit for real - else - m_exit_pending = true; + m_exit_pending = true; // if we're executing, abort out immediately m_scheduler.eat_all_cycles(); @@ -499,21 +488,6 @@ void running_machine::schedule_soft_reset() //------------------------------------------------- -// schedule_new_driver - schedule a new game to -// be loaded -//------------------------------------------------- - -void running_machine::schedule_new_driver(const game_driver &driver) -{ - m_hard_reset_pending = true; - m_new_driver_pending = &driver; - - // if we're executing, abort out immediately - m_scheduler.eat_all_cycles(); -} - - -//------------------------------------------------- // get_statename - allow to specify a subfolder of // the state directory for state loading/saving, // very useful for MESS and consoles or computers diff --git a/src/emu/machine.h b/src/emu/machine.h index d474ae08392..5188c262fad 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -150,7 +150,7 @@ class running_machine public: // construction/destruction - running_machine(const machine_config &config, osd_interface &osd, bool exit_to_game_select = false); + running_machine(const machine_config &config, osd_interface &osd); ~running_machine(); // getters @@ -176,8 +176,6 @@ public: machine_phase phase() const { return m_current_phase; } bool paused() const { return m_paused || (m_current_phase != MACHINE_PHASE_RUNNING); } bool exit_pending() const { return m_exit_pending; } - bool new_driver_pending() const { return (m_new_driver_pending != NULL); } - const char *new_driver_name() const { return m_new_driver_pending->name; } bool ui_active() const { return m_ui_active; } const char *basename() const { return m_basename; } int sample_rate() const { return m_sample_rate; } @@ -295,8 +293,6 @@ private: bool m_paused; // paused? bool m_hard_reset_pending; // is a hard reset pending? bool m_exit_pending; // is an exit pending? - bool m_exit_to_game_select; // when we exit, go we go back to the game select? - const game_driver * m_new_driver_pending; // pointer to the next pending driver emu_timer * m_soft_reset_timer; // timer used to schedule a soft reset // watchdog state diff --git a/src/emu/mame.c b/src/emu/mame.c index 72430034ed9..e6d33f45c90 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -98,6 +98,19 @@ static bool started_empty; static running_machine *global_machine; +const game_driver * new_driver_pending = NULL; // pointer to the next pending driver + +//------------------------------------------------- +// mame_schedule_new_driver - schedule a new game to +// be loaded +//------------------------------------------------- + +void mame_schedule_new_driver(const game_driver &driver) +{ + new_driver_pending = &driver; +} + + /*************************************************************************** CORE IMPLEMENTATION @@ -120,6 +133,8 @@ int mame_execute(emu_options &options, osd_interface &osd) while (error == MAMERR_NONE && !exit_pending) { + new_driver_pending = NULL; + // if no driver, use the internal empty driver const game_driver *system = options.system(); if (system == NULL) @@ -150,7 +165,7 @@ int mame_execute(emu_options &options, osd_interface &osd) machine_config config(*system, options); // create the machine structure and driver - running_machine machine(config, osd, started_empty); + running_machine machine(config, osd); // looooong term: remove this global_machine = &machine; @@ -163,12 +178,17 @@ int mame_execute(emu_options &options, osd_interface &osd) firstrun = false; // check the state of the machine - if (machine.new_driver_pending()) + if (new_driver_pending) { - options.set_system_name(machine.new_driver_name()); + options.set_system_name(new_driver_pending->name); firstrun = true; + } + else + { + options.set_system_name(""); } - if (machine.exit_pending()) + + if (machine.exit_pending() && (!started_empty || (system == &GAME_NAME(___empty)))) exit_pending = true; // machine will go away when we exit scope diff --git a/src/emu/mame.h b/src/emu/mame.h index b7cdb7941d4..588b56d2044 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -93,7 +93,7 @@ extern const char build_version[]; /* execute as configured by the OPTION_SYSTEMNAME option on the specified options */ int mame_execute(emu_options &options, osd_interface &osd); - +void mame_schedule_new_driver(const game_driver &driver); /* ----- miscellaneous bits & pieces ----- */ // pop-up a user visible message diff --git a/src/emu/ui/selgame.c b/src/emu/ui/selgame.c index 97dc05663ee..f98fadc329e 100644 --- a/src/emu/ui/selgame.c +++ b/src/emu/ui/selgame.c @@ -158,7 +158,8 @@ void ui_menu_select_game::inkey_select(const ui_menu_event *menu_event) // if everything looks good, schedule the new driver if (summary == media_auditor::CORRECT || summary == media_auditor::BEST_AVAILABLE) { - machine().schedule_new_driver(*driver); + mame_schedule_new_driver(*driver); + machine().schedule_hard_reset(); ui_menu::stack_reset(machine()); } diff --git a/src/osd/osdcore.c b/src/osd/osdcore.c index 4d299a48e4a..b81073e7649 100644 --- a/src/osd/osdcore.c +++ b/src/osd/osdcore.c @@ -1,5 +1,6 @@ #include "emucore.h" #include "osdcore.h" +#include "portmidi/portmidi.h" bool g_print_verbose = false; @@ -165,3 +166,404 @@ void CLIB_DECL osd_printf_log(const char *format, ...) } #endif +static const int RX_EVENT_BUF_SIZE = 512; + +#define MIDI_SYSEX 0xf0 +#define MIDI_EOX 0xf7 + +struct osd_midi_device +{ + #ifndef DISABLE_MIDI + PortMidiStream *pmStream; + PmEvent rx_evBuf[RX_EVENT_BUF_SIZE]; + #endif + UINT8 xmit_in[4]; // Pm_Messages mean we can at most have 3 residue bytes + int xmit_cnt; + UINT8 last_status; + bool rx_sysex; +}; + +void osd_list_midi_devices(void) +{ + #ifndef DISABLE_MIDI + int num_devs = Pm_CountDevices(); + const PmDeviceInfo *pmInfo; + + printf("\n"); + + if (num_devs == 0) + { + printf("No MIDI ports were found\n"); + return; + } + + printf("MIDI input ports:\n"); + for (int i = 0; i < num_devs; i++) + { + pmInfo = Pm_GetDeviceInfo(i); + + if (pmInfo->input) + { + printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultInputDeviceID()) ? "(default)" : ""); + } + } + + printf("\nMIDI output ports:\n"); + for (int i = 0; i < num_devs; i++) + { + pmInfo = Pm_GetDeviceInfo(i); + + if (pmInfo->output) + { + printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultOutputDeviceID()) ? "(default)" : ""); + } + } + #else + printf("\nMIDI is not supported in this build\n"); + #endif +} + +osd_midi_device *osd_open_midi_input(const char *devname) +{ + #ifndef DISABLE_MIDI + int num_devs = Pm_CountDevices(); + int found_dev = -1; + const PmDeviceInfo *pmInfo; + PortMidiStream *stm; + osd_midi_device *ret; + + for (int i = 0; i < num_devs; i++) + { + pmInfo = Pm_GetDeviceInfo(i); + + if (pmInfo->input) + { + if (!strcmp(devname, pmInfo->name)) + { + found_dev = i; + break; + } + } + } + + if (found_dev >= 0) + { + if (Pm_OpenInput(&stm, found_dev, NULL, RX_EVENT_BUF_SIZE, NULL, NULL) == pmNoError) + { + ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); + memset(ret, 0, sizeof(osd_midi_device)); + ret->pmStream = stm; + return ret; + } + else + { + printf("Couldn't open PM device\n"); + return NULL; + } + } + else + { + return NULL; + } + #else + return NULL; + #endif +} + +osd_midi_device *osd_open_midi_output(const char *devname) +{ + #ifndef DISABLE_MIDI + int num_devs = Pm_CountDevices(); + int found_dev = -1; + const PmDeviceInfo *pmInfo; + PortMidiStream *stm; + osd_midi_device *ret; + + for (int i = 0; i < num_devs; i++) + { + pmInfo = Pm_GetDeviceInfo(i); + + if (pmInfo->output) + { + if (!strcmp(devname, pmInfo->name)) + { + found_dev = i; + break; + } + } + } + + if (found_dev >= 0) + { + if (Pm_OpenOutput(&stm, found_dev, NULL, 100, NULL, NULL, 0) == pmNoError) + { + ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); + memset(ret, 0, sizeof(osd_midi_device)); + ret->pmStream = stm; + return ret; + } + else + { + printf("Couldn't open PM device\n"); + return NULL; + } + } + else + { + return NULL; + } + #endif + return NULL; +} + +void osd_close_midi_channel(osd_midi_device *dev) +{ + #ifndef DISABLE_MIDI + Pm_Close(dev->pmStream); + osd_free(dev); + #endif +} + +bool osd_poll_midi_channel(osd_midi_device *dev) +{ + #ifndef DISABLE_MIDI + PmError chk = Pm_Poll(dev->pmStream); + + return (chk == pmGotData) ? true : false; + #else + return false; + #endif +} + +int osd_read_midi_channel(osd_midi_device *dev, UINT8 *pOut) +{ + #ifndef DISABLE_MIDI + int msgsRead = Pm_Read(dev->pmStream, dev->rx_evBuf, RX_EVENT_BUF_SIZE); + int bytesOut = 0; + + if (msgsRead <= 0) + { + return 0; + } + + for (int msg = 0; msg < msgsRead; msg++) + { + UINT8 status = Pm_MessageStatus(dev->rx_evBuf[msg].message); + + if (dev->rx_sysex) + { + if (status & 0x80) // sys real-time imposing on us? + { + if ((status == 0xf2) || (status == 0xf3)) + { + *pOut++ = status; + *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); + *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); + bytesOut += 3; + } + else + { + *pOut++ = status; + bytesOut++; + if (status == MIDI_EOX) + { + dev->rx_sysex = false; + } + } + } + else // shift out the sysex bytes + { + for (int i = 0; i < 4; i++) + { + UINT8 byte = dev->rx_evBuf[msg].message & 0xff; + *pOut++ = byte; + bytesOut++; + if (byte == MIDI_EOX) + { + dev->rx_sysex = false; + break; + } + dev->rx_evBuf[msg].message >>= 8; + } + } + } + else + { + switch ((status>>4) & 0xf) + { + case 0xc: // 2-byte messages + case 0xd: + *pOut++ = status; + *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); + bytesOut += 2; + break; + + case 0xf: // system common + switch (status & 0xf) + { + case 0: // System Exclusive + { + *pOut++ = status; // this should be OK: the shortest legal sysex is F0 tt dd F7, I believe + *pOut++ = (dev->rx_evBuf[msg].message>>8) & 0xff; + *pOut++ = (dev->rx_evBuf[msg].message>>16) & 0xff; + UINT8 last = *pOut++ = (dev->rx_evBuf[msg].message>>24) & 0xff; + bytesOut += 4; + dev->rx_sysex = (last != MIDI_EOX); + break; + } + + case 7: // End of System Exclusive + *pOut++ = status; + bytesOut += 1; + dev->rx_sysex = false; + break; + + case 2: // song pos + case 3: // song select + *pOut++ = status; + *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); + *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); + bytesOut += 3; + break; + + default: // all other defined Fx messages are 1 byte + break; + } + break; + + default: + *pOut++ = status; + *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); + *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); + bytesOut += 3; + break; + } + } + } + + return bytesOut; + #else + return 0; + #endif +} + +void osd_write_midi_channel(osd_midi_device *dev, UINT8 data) +{ + #ifndef DISABLE_MIDI + int bytes_needed = 0; + PmEvent ev; + ev.timestamp = 0; // use the current time + +// printf("write: %02x (%d)\n", data, dev->xmit_cnt); + + if (dev->xmit_cnt >= 4) + { + printf("MIDI out: packet assembly overflow, contact MAMEdev!\n"); + return; + } + + // handle sysex + if (dev->last_status == MIDI_SYSEX) + { +// printf("sysex: %02x (%d)\n", data, dev->xmit_cnt); + + // if we get a status that isn't sysex, assume it's system common + if ((data & 0x80) && (data != MIDI_EOX)) + { +// printf("common during sysex!\n"); + ev.message = Pm_Message(data, 0, 0); + Pm_Write(dev->pmStream, &ev, 1); + return; + } + + dev->xmit_in[dev->xmit_cnt++] = data; + + // if EOX or 4 bytes filled, transmit 4 bytes + if ((dev->xmit_cnt == 4) || (data == MIDI_EOX)) + { + ev.message = dev->xmit_in[0] | (dev->xmit_in[1]<<8) | (dev->xmit_in[2]<<16) | (dev->xmit_in[3]<<24); + Pm_Write(dev->pmStream, &ev, 1); + dev->xmit_in[0] = dev->xmit_in[1] = dev->xmit_in[2] = dev->xmit_in[3] = 0; + dev->xmit_cnt = 0; + +// printf("SysEx packet: %08x\n", ev.message); + + // if this is EOX, kill the running status + if (data == MIDI_EOX) + { + dev->last_status = 0; + } + } + + return; + } + + // handle running status. don't allow system real-time messages to be considered as running status. + if ((dev->xmit_cnt == 0) && (data & 0x80) && (data < 0xf8)) + { + dev->last_status = data; + } + + if ((dev->xmit_cnt == 0) && !(data & 0x80)) + { + dev->xmit_in[dev->xmit_cnt++] = dev->last_status; + dev->xmit_in[dev->xmit_cnt++] = data; +// printf("\trunning status: [%d] = %02x, [%d] = %02x, last_status = %02x\n", dev->xmit_cnt-2, dev->last_status, dev->xmit_cnt-1, data, dev->last_status); + } + else + { + dev->xmit_in[dev->xmit_cnt++] = data; +// printf("\tNRS: [%d] = %02x\n", dev->xmit_cnt-1, data); + } + + if ((dev->xmit_cnt == 1) && (dev->xmit_in[0] == MIDI_SYSEX)) + { +// printf("Start SysEx!\n"); + dev->last_status = MIDI_SYSEX; + return; + } + + // are we there yet? +// printf("status check: %02x\n", dev->xmit_in[0]); + switch ((dev->xmit_in[0]>>4) & 0xf) + { + case 0xc: // 2-byte messages + case 0xd: + bytes_needed = 2; + break; + + case 0xf: // system common + switch (dev->xmit_in[0] & 0xf) + { + case 0: // System Exclusive is handled above + break; + + case 7: // End of System Exclusive + bytes_needed = 1; + break; + + case 2: // song pos + case 3: // song select + bytes_needed = 3; + break; + + default: // all other defined Fx messages are 1 byte + bytes_needed = 1; + break; + } + break; + + default: + bytes_needed = 3; + break; + } + + if (dev->xmit_cnt == bytes_needed) + { + ev.message = Pm_Message(dev->xmit_in[0], dev->xmit_in[1], dev->xmit_in[2]); + Pm_Write(dev->pmStream, &ev, 1); + dev->xmit_cnt = 0; + } + + #endif +} diff --git a/src/osd/osdcore.h b/src/osd/osdcore.h index 3ebe10d8483..34d514c2d18 100644 --- a/src/osd/osdcore.h +++ b/src/osd/osdcore.h @@ -874,8 +874,6 @@ file_error osd_get_full_path(char **dst, const char *path); ***************************************************************************/ struct osd_midi_device; -void osd_init_midi(void); -void osd_shutdown_midi(void); void osd_list_midi_devices(void); // free result with osd_close_midi_channel() osd_midi_device *osd_open_midi_input(const char *devname); diff --git a/src/osd/osdepend.c b/src/osd/osdepend.c index 7eb47c70549..c62ad1967c0 100644 --- a/src/osd/osdepend.c +++ b/src/osd/osdepend.c @@ -12,6 +12,7 @@ #include "emu.h" #include "emuopts.h" #include "osdepend.h" +#include "portmidi/portmidi.h" extern bool g_print_verbose; @@ -76,7 +77,9 @@ void osd_interface::init(running_machine &machine) // extract the verbose printing option if (options.verbose()) g_print_verbose = true; - + + // ensure we get called on the way out + machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_interface::osd_exit), this)); } @@ -127,6 +130,9 @@ void osd_interface::wait_for_debugger(device_t &device, bool firststop) // } +void osd_interface::debugger_update() +{ +} //------------------------------------------------- // update_audio_stream - update the stereo audio @@ -221,3 +227,118 @@ void *osd_interface::get_slider_list() { return NULL; } + +void osd_interface::init_subsystems() +{ + if (!video_init()) + { + video_exit(); + osd_printf_error("video_init: Initialization failed!\n\n\n"); + fflush(stderr); + fflush(stdout); + exit(-1); + } + sound_init(); + input_init(); + // we need pause callbacks + machine().add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(osd_interface::input_pause), this)); + machine().add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(osd_interface::input_resume), this)); + + output_init(); +#ifdef USE_NETWORK + network_init(); +#endif + midi_init(); +} + +bool osd_interface::video_init() +{ + return true; +} + +bool osd_interface::sound_init() +{ + return true; +} + +bool osd_interface::input_init() +{ + return true; +} + +void osd_interface::input_pause() +{ +} + +void osd_interface::input_resume() +{ +} + +bool osd_interface::output_init() +{ + return true; +} + +bool osd_interface::network_init() +{ + return true; +} + +bool osd_interface::midi_init() +{ + #ifndef DISABLE_MIDI + Pm_Initialize(); + #endif + return true; +} + + +void osd_interface::exit_subsystems() +{ + video_exit(); + sound_exit(); + input_exit(); + output_exit(); + #ifdef USE_NETWORK + network_exit(); + #endif + midi_exit(); + debugger_exit(); +} + +void osd_interface::video_exit() +{ +} + +void osd_interface::sound_exit() +{ +} + +void osd_interface::input_exit() +{ +} + +void osd_interface::output_exit() +{ +} + +void osd_interface::network_exit() +{ +} + +void osd_interface::midi_exit() +{ + #ifndef DISABLE_MIDI + Pm_Terminate(); + #endif +} + +void osd_interface::debugger_exit() +{ +} + +void osd_interface::osd_exit() +{ + exit_subsystems(); +} + diff --git a/src/osd/osdepend.h b/src/osd/osdepend.h index 7949079a523..82d61a10f42 100644 --- a/src/osd/osdepend.h +++ b/src/osd/osdepend.h @@ -48,6 +48,8 @@ public: // debugger overridables virtual void init_debugger(); virtual void wait_for_debugger(device_t &device, bool firststop); + virtual void debugger_update(); + virtual void debugger_exit(); // audio overridables virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); @@ -64,6 +66,25 @@ public: // video overridables virtual void *get_slider_list(); + void init_subsystems(); + virtual bool video_init(); + virtual bool sound_init(); + virtual bool input_init(); + virtual void input_pause(); + virtual void input_resume(); + virtual bool output_init(); + virtual bool network_init(); + virtual bool midi_init(); + + void exit_subsystems(); + virtual void video_exit(); + virtual void sound_exit(); + virtual void input_exit(); + virtual void output_exit(); + virtual void network_exit(); + virtual void midi_exit(); + + virtual void osd_exit(); private: // internal state running_machine * m_machine; diff --git a/src/osd/osdmini/minifile.c b/src/osd/osdmini/minifile.c index e4c74241290..7633e155313 100644 --- a/src/osd/osdmini/minifile.c +++ b/src/osd/osdmini/minifile.c @@ -171,7 +171,14 @@ file_error osd_get_full_path(char **dst, const char *path) { // derive the full path of the file in an allocated string // for now just fake it since we don't presume any underlying file system - *dst = core_strdup(path); + *dst = NULL; + if (path != NULL) + { + *dst = (char *)osd_malloc_array(strlen(path) + 1); + if (*dst != NULL) + strcpy(*dst, path); + } + return FILERR_NONE; } diff --git a/src/osd/osdmini/minimain.c b/src/osd/osdmini/minimain.c index 9e45e6d785e..9eec9b97515 100644 --- a/src/osd/osdmini/minimain.c +++ b/src/osd/osdmini/minimain.c @@ -154,41 +154,6 @@ void mini_osd_interface::update(bool skip_redraw) //============================================================ -// update_audio_stream -//============================================================ - -void mini_osd_interface::update_audio_stream(const INT16 *buffer, int samples_this_frame) -{ - // if we had actual sound output, we would copy the - // interleaved stereo samples to our sound stream -} - - -//============================================================ -// set_mastervolume -//============================================================ - -void mini_osd_interface::set_mastervolume(int attenuation) -{ - // if we had actual sound output, we would adjust the global - // volume in response to this function -} - - -//============================================================ -// customize_input_type_list -//============================================================ - -void mini_osd_interface::customize_input_type_list(simple_list<input_type_entry> &typelist) -{ - // This function is called on startup, before reading the - // configuration from disk. Scan the list, and change the - // default control mappings you want. It is quite possible - // you won't need to change a thing. -} - - -//============================================================ // keyboard_get_state //============================================================ diff --git a/src/osd/osdmini/osdmini.h b/src/osd/osdmini/osdmini.h index a76c070323c..35db06c881c 100644 --- a/src/osd/osdmini/osdmini.h +++ b/src/osd/osdmini/osdmini.h @@ -24,20 +24,6 @@ public: // general overridables virtual void init(running_machine &machine); virtual void update(bool skip_redraw); - - // debugger overridables -// virtual void init_debugger(); -// virtual void wait_for_debugger(device_t &device, bool firststop); - - // audio overridables - virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); - virtual void set_mastervolume(int attenuation); - - // input overridables - virtual void customize_input_type_list(simple_list<input_type_entry> &typelist); - -private: - static void osd_exit(running_machine &machine); }; diff --git a/src/osd/osdmini/osdmini.mak b/src/osd/osdmini/osdmini.mak index 6a491130bd2..108cba77ae4 100644 --- a/src/osd/osdmini/osdmini.mak +++ b/src/osd/osdmini/osdmini.mak @@ -71,7 +71,11 @@ OSDOBJS = \ $(MINIOBJ)/minimain.o +$(MINIOBJ)/minimidi.o: $(SRC)/osd/portmedia/pmmidi.inc +ifeq ($(OS),Windows_NT) +LIBS += -lwinmm -lwsock32 +endif #------------------------------------------------- # rules for building the libaries #------------------------------------------------- diff --git a/src/osd/portmedia/pmmidi.inc b/src/osd/portmedia/pmmidi.inc deleted file mode 100644 index cd7cc4ab754..00000000000 --- a/src/osd/portmedia/pmmidi.inc +++ /dev/null @@ -1,427 +0,0 @@ -//============================================================ -// -// pmmidi.inc - OSD interface for PortMidi -// -// Copyright (c) 1996-2013, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#include "portmidi/portmidi.h" -#include "osdcore.h" - -static const int RX_EVENT_BUF_SIZE = 512; - -#define MIDI_SYSEX 0xf0 -#define MIDI_EOX 0xf7 - -struct osd_midi_device -{ - #ifndef DISABLE_MIDI - PortMidiStream *pmStream; - PmEvent rx_evBuf[RX_EVENT_BUF_SIZE]; - #endif - UINT8 xmit_in[4]; // Pm_Messages mean we can at most have 3 residue bytes - int xmit_cnt; - UINT8 last_status; - bool rx_sysex; -}; - -void osd_list_midi_devices(void) -{ - #ifndef DISABLE_MIDI - int num_devs = Pm_CountDevices(); - const PmDeviceInfo *pmInfo; - - printf("\n"); - - if (num_devs == 0) - { - printf("No MIDI ports were found\n"); - return; - } - - printf("MIDI input ports:\n"); - for (int i = 0; i < num_devs; i++) - { - pmInfo = Pm_GetDeviceInfo(i); - - if (pmInfo->input) - { - printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultInputDeviceID()) ? "(default)" : ""); - } - } - - printf("\nMIDI output ports:\n"); - for (int i = 0; i < num_devs; i++) - { - pmInfo = Pm_GetDeviceInfo(i); - - if (pmInfo->output) - { - printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultOutputDeviceID()) ? "(default)" : ""); - } - } - #else - printf("\nMIDI is not supported in this build\n"); - #endif -} - -osd_midi_device *osd_open_midi_input(const char *devname) -{ - #ifndef DISABLE_MIDI - int num_devs = Pm_CountDevices(); - int found_dev = -1; - const PmDeviceInfo *pmInfo; - PortMidiStream *stm; - osd_midi_device *ret; - - for (int i = 0; i < num_devs; i++) - { - pmInfo = Pm_GetDeviceInfo(i); - - if (pmInfo->input) - { - if (!strcmp(devname, pmInfo->name)) - { - found_dev = i; - break; - } - } - } - - if (found_dev >= 0) - { - if (Pm_OpenInput(&stm, found_dev, NULL, RX_EVENT_BUF_SIZE, NULL, NULL) == pmNoError) - { - ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); - memset(ret, 0, sizeof(osd_midi_device)); - ret->pmStream = stm; - return ret; - } - else - { - printf("Couldn't open PM device\n"); - return NULL; - } - } - else - { - return NULL; - } - #else - return NULL; - #endif -} - -osd_midi_device *osd_open_midi_output(const char *devname) -{ - #ifndef DISABLE_MIDI - int num_devs = Pm_CountDevices(); - int found_dev = -1; - const PmDeviceInfo *pmInfo; - PortMidiStream *stm; - osd_midi_device *ret; - - for (int i = 0; i < num_devs; i++) - { - pmInfo = Pm_GetDeviceInfo(i); - - if (pmInfo->output) - { - if (!strcmp(devname, pmInfo->name)) - { - found_dev = i; - break; - } - } - } - - if (found_dev >= 0) - { - if (Pm_OpenOutput(&stm, found_dev, NULL, 100, NULL, NULL, 0) == pmNoError) - { - ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device)); - memset(ret, 0, sizeof(osd_midi_device)); - ret->pmStream = stm; - return ret; - } - else - { - printf("Couldn't open PM device\n"); - return NULL; - } - } - else - { - return NULL; - } - #endif - return NULL; -} - -void osd_close_midi_channel(osd_midi_device *dev) -{ - #ifndef DISABLE_MIDI - Pm_Close(dev->pmStream); - osd_free(dev); - #endif -} - -bool osd_poll_midi_channel(osd_midi_device *dev) -{ - #ifndef DISABLE_MIDI - PmError chk = Pm_Poll(dev->pmStream); - - return (chk == pmGotData) ? true : false; - #else - return false; - #endif -} - -int osd_read_midi_channel(osd_midi_device *dev, UINT8 *pOut) -{ - #ifndef DISABLE_MIDI - int msgsRead = Pm_Read(dev->pmStream, dev->rx_evBuf, RX_EVENT_BUF_SIZE); - int bytesOut = 0; - - if (msgsRead <= 0) - { - return 0; - } - - for (int msg = 0; msg < msgsRead; msg++) - { - UINT8 status = Pm_MessageStatus(dev->rx_evBuf[msg].message); - - if (dev->rx_sysex) - { - if (status & 0x80) // sys real-time imposing on us? - { - if ((status == 0xf2) || (status == 0xf3)) - { - *pOut++ = status; - *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); - *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); - bytesOut += 3; - } - else - { - *pOut++ = status; - bytesOut++; - if (status == MIDI_EOX) - { - dev->rx_sysex = false; - } - } - } - else // shift out the sysex bytes - { - for (int i = 0; i < 4; i++) - { - UINT8 byte = dev->rx_evBuf[msg].message & 0xff; - *pOut++ = byte; - bytesOut++; - if (byte == MIDI_EOX) - { - dev->rx_sysex = false; - break; - } - dev->rx_evBuf[msg].message >>= 8; - } - } - } - else - { - switch ((status>>4) & 0xf) - { - case 0xc: // 2-byte messages - case 0xd: - *pOut++ = status; - *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); - bytesOut += 2; - break; - - case 0xf: // system common - switch (status & 0xf) - { - case 0: // System Exclusive - { - *pOut++ = status; // this should be OK: the shortest legal sysex is F0 tt dd F7, I believe - *pOut++ = (dev->rx_evBuf[msg].message>>8) & 0xff; - *pOut++ = (dev->rx_evBuf[msg].message>>16) & 0xff; - UINT8 last = *pOut++ = (dev->rx_evBuf[msg].message>>24) & 0xff; - bytesOut += 4; - dev->rx_sysex = (last != MIDI_EOX); - break; - } - - case 7: // End of System Exclusive - *pOut++ = status; - bytesOut += 1; - dev->rx_sysex = false; - break; - - case 2: // song pos - case 3: // song select - *pOut++ = status; - *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); - *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); - bytesOut += 3; - break; - - default: // all other defined Fx messages are 1 byte - break; - } - break; - - default: - *pOut++ = status; - *pOut++ = Pm_MessageData1(dev->rx_evBuf[msg].message); - *pOut++ = Pm_MessageData2(dev->rx_evBuf[msg].message); - bytesOut += 3; - break; - } - } - } - - return bytesOut; - #else - return 0; - #endif -} - -void osd_write_midi_channel(osd_midi_device *dev, UINT8 data) -{ - #ifndef DISABLE_MIDI - int bytes_needed = 0; - PmEvent ev; - ev.timestamp = 0; // use the current time - -// printf("write: %02x (%d)\n", data, dev->xmit_cnt); - - if (dev->xmit_cnt >= 4) - { - printf("MIDI out: packet assembly overflow, contact MAMEdev!\n"); - return; - } - - // handle sysex - if (dev->last_status == MIDI_SYSEX) - { -// printf("sysex: %02x (%d)\n", data, dev->xmit_cnt); - - // if we get a status that isn't sysex, assume it's system common - if ((data & 0x80) && (data != MIDI_EOX)) - { -// printf("common during sysex!\n"); - ev.message = Pm_Message(data, 0, 0); - Pm_Write(dev->pmStream, &ev, 1); - return; - } - - dev->xmit_in[dev->xmit_cnt++] = data; - - // if EOX or 4 bytes filled, transmit 4 bytes - if ((dev->xmit_cnt == 4) || (data == MIDI_EOX)) - { - ev.message = dev->xmit_in[0] | (dev->xmit_in[1]<<8) | (dev->xmit_in[2]<<16) | (dev->xmit_in[3]<<24); - Pm_Write(dev->pmStream, &ev, 1); - dev->xmit_in[0] = dev->xmit_in[1] = dev->xmit_in[2] = dev->xmit_in[3] = 0; - dev->xmit_cnt = 0; - -// printf("SysEx packet: %08x\n", ev.message); - - // if this is EOX, kill the running status - if (data == MIDI_EOX) - { - dev->last_status = 0; - } - } - - return; - } - - // handle running status. don't allow system real-time messages to be considered as running status. - if ((dev->xmit_cnt == 0) && (data & 0x80) && (data < 0xf8)) - { - dev->last_status = data; - } - - if ((dev->xmit_cnt == 0) && !(data & 0x80)) - { - dev->xmit_in[dev->xmit_cnt++] = dev->last_status; - dev->xmit_in[dev->xmit_cnt++] = data; -// printf("\trunning status: [%d] = %02x, [%d] = %02x, last_status = %02x\n", dev->xmit_cnt-2, dev->last_status, dev->xmit_cnt-1, data, dev->last_status); - } - else - { - dev->xmit_in[dev->xmit_cnt++] = data; -// printf("\tNRS: [%d] = %02x\n", dev->xmit_cnt-1, data); - } - - if ((dev->xmit_cnt == 1) && (dev->xmit_in[0] == MIDI_SYSEX)) - { -// printf("Start SysEx!\n"); - dev->last_status = MIDI_SYSEX; - return; - } - - // are we there yet? -// printf("status check: %02x\n", dev->xmit_in[0]); - switch ((dev->xmit_in[0]>>4) & 0xf) - { - case 0xc: // 2-byte messages - case 0xd: - bytes_needed = 2; - break; - - case 0xf: // system common - switch (dev->xmit_in[0] & 0xf) - { - case 0: // System Exclusive is handled above - break; - - case 7: // End of System Exclusive - bytes_needed = 1; - break; - - case 2: // song pos - case 3: // song select - bytes_needed = 3; - break; - - default: // all other defined Fx messages are 1 byte - bytes_needed = 1; - break; - } - break; - - default: - bytes_needed = 3; - break; - } - - if (dev->xmit_cnt == bytes_needed) - { - ev.message = Pm_Message(dev->xmit_in[0], dev->xmit_in[1], dev->xmit_in[2]); - Pm_Write(dev->pmStream, &ev, 1); - dev->xmit_cnt = 0; - } - - #endif -} - -void osd_init_midi(void) -{ - #ifndef DISABLE_MIDI - Pm_Initialize(); - #endif -} - -void osd_shutdown_midi(void) -{ - #ifndef DISABLE_MIDI - Pm_Terminate(); - #endif -} diff --git a/src/osd/sdl/debugosx.h b/src/osd/sdl/debugosx.h index 6b6e331bac6..314cf23cd59 100644 --- a/src/osd/sdl/debugosx.h +++ b/src/osd/sdl/debugosx.h @@ -366,13 +366,4 @@ typedef float CGFloat; #endif // __OBJC__ - - -//============================================================ -// PROTOTYPES -//============================================================ - -void debugwin_update_during_game(running_machine &machine); - - #endif // __SDL_DEBUGOSX__ diff --git a/src/osd/sdl/debugosx.m b/src/osd/sdl/debugosx.m index a0eafd0053c..a96810c94ee 100644 --- a/src/osd/sdl/debugosx.m +++ b/src/osd/sdl/debugosx.m @@ -110,13 +110,20 @@ void sdl_osd_interface::wait_for_debugger(device_t &device, bool firststop) //============================================================ -// debugwin_update_during_game +// debugger_update //============================================================ -void debugwin_update_during_game(running_machine &machine) +void sdl_osd_interface::debugger_update() { } +//============================================================ +// debugger_exit +//============================================================ + +void sdl_osd_interface::debugger_exit() +{ +} //============================================================ // debugwin_view_update diff --git a/src/osd/sdl/debugqt.c b/src/osd/sdl/debugqt.c index adf00a2bbcb..a718253d7ec 100644 --- a/src/osd/sdl/debugqt.c +++ b/src/osd/sdl/debugqt.c @@ -35,9 +35,6 @@ #include "debugqtmemorywindow.h" #include "debugqtbreakpointswindow.h" -#include "debugqt.h" - - //============================================================ // "Global" variables to make QT happy //============================================================ @@ -323,11 +320,14 @@ void xxx_osd_interface::wait_for_debugger(device_t &device, bool firststop) // Available for video.* //============================================================ -void debugwin_update_during_game(running_machine &machine) +void xxx_osd_interface::debugger_update() { qApp->processEvents(QEventLoop::AllEvents, 1); } +void xxx_osd_interface::debugger_exit() +{ +} #else @@ -340,7 +340,6 @@ void debugwin_update_during_game(running_machine &machine) #include "osdepend.h" #include "osdsdl.h" -// win32 stubs for linking void sdl_osd_interface::init_debugger() { } @@ -349,8 +348,11 @@ void sdl_osd_interface::wait_for_debugger(device_t &device, bool firststop) { } -// win32 stubs for linking -void debugwin_update_during_game(running_machine &machine) +void sdl_osd_interface::debugger_update() +{ +} + +void sdl_osd_interface::debugger_exit() { } diff --git a/src/osd/sdl/debugqt.h b/src/osd/sdl/debugqt.h deleted file mode 100644 index bbe1545aaeb..00000000000 --- a/src/osd/sdl/debugqt.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _DEBUGQT_H_ -#define _DEBUGQT_H_ - -void debugwin_update_during_game(running_machine &machine); - -#endif diff --git a/src/osd/sdl/debugwin.c b/src/osd/sdl/debugwin.c index 3306c7097be..c6f7468ffa0 100644 --- a/src/osd/sdl/debugwin.c +++ b/src/osd/sdl/debugwin.c @@ -27,7 +27,11 @@ void sdl_osd_interface::wait_for_debugger(device_t &device, bool firststop) } // win32 stubs for linking -void debugwin_update_during_game(running_machine &machine) +void sdl_osd_interface::debugger_update() +{ +} + +void sdl_osd_interface::debugger_exit() { } diff --git a/src/osd/sdl/input.c b/src/osd/sdl/input.c index 39dee7ccae5..bf31541a641 100644 --- a/src/osd/sdl/input.c +++ b/src/osd/sdl/input.c @@ -213,10 +213,6 @@ static int sixaxis_mode; // PROTOTYPES //============================================================ -static void sdlinput_pause(running_machine &machine); -static void sdlinput_resume(running_machine &machine); -static void sdlinput_exit(running_machine &machine); - // deivce list management static void device_list_reset_devices(device_info *devlist_head); static void device_list_free_devices(device_info **devlist_head); @@ -1389,7 +1385,7 @@ static void sdlinput_register_keyboards(running_machine &machine) // sdlinput_init //============================================================ -void sdlinput_init(running_machine &machine) +bool sdl_osd_interface::input_init() { keyboard_list = NULL; joystick_list = NULL; @@ -1398,37 +1394,32 @@ void sdlinput_init(running_machine &machine) app_has_mouse_focus = 1; - // we need pause and exit callbacks - machine.add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(sdlinput_pause), &machine)); - machine.add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(sdlinput_resume), &machine)); - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(sdlinput_exit), &machine)); - // allocate a lock for input synchronizations input_lock = osd_lock_alloc(); assert_always(input_lock != NULL, "Failed to allocate input_lock"); // register the keyboards - sdlinput_register_keyboards(machine); + sdlinput_register_keyboards(machine()); // register the mice - sdlinput_register_mice(machine); + sdlinput_register_mice(machine()); #if (USE_XINPUT) // register the lightguns - sdlinput_register_lightguns(machine); + sdlinput_register_lightguns(machine()); #endif - if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) + if (machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) { osd_printf_warning("Debug Build: Disabling input grab for -debug\n"); mouse_enabled = 0; } // get Sixaxis special mode info - sixaxis_mode = downcast<sdl_options &>(machine.options()).sixaxis(); + sixaxis_mode = downcast<sdl_options &>(machine().options()).sixaxis(); // register the joysticks - sdlinput_register_joysticks(machine); + sdlinput_register_joysticks(machine()); // now reset all devices device_list_reset_devices(keyboard_list); @@ -1437,6 +1428,7 @@ void sdlinput_init(running_machine &machine) #if (USE_XINPUT) device_list_reset_devices(lightgun_list); #endif + return true; } @@ -1444,13 +1436,13 @@ void sdlinput_init(running_machine &machine) // sdlinput_pause //============================================================ -static void sdlinput_pause(running_machine &machine) +void sdl_osd_interface::input_pause() { // keep track of the paused state input_paused = true; } -static void sdlinput_resume(running_machine &machine) +void sdl_osd_interface::input_resume() { // keep track of the paused state input_paused = false; @@ -1461,14 +1453,14 @@ static void sdlinput_resume(running_machine &machine) // sdlinput_exit //============================================================ -static void sdlinput_exit(running_machine &machine) +void sdl_osd_interface::input_exit() { // free the lock osd_lock_free(input_lock); // deregister - sdlinput_deregister_joysticks(machine); + sdlinput_deregister_joysticks(machine()); // free all devices device_list_free_devices(&keyboard_list); diff --git a/src/osd/sdl/netdev.c b/src/osd/sdl/netdev.c index f42a8da32f1..ff09c3ea9ae 100644 --- a/src/osd/sdl/netdev.c +++ b/src/osd/sdl/netdev.c @@ -1,8 +1,9 @@ #include "emu.h" #include "netdev_tap.h" #include "netdev_pcap.h" +#include "osdsdl.h" -void sdlnetdev_init(running_machine &machine) +bool sdl_osd_interface::network_init() { #ifdef SDLMAME_NET_TAPTUN init_tap(); @@ -10,9 +11,10 @@ void sdlnetdev_init(running_machine &machine) #ifdef SDLMAME_NET_PCAP init_pcap(); #endif + return true; } -void sdlnetdev_deinit(running_machine &machine) +void sdl_osd_interface::network_exit() { #ifdef SDLMAME_NET_TAPTUN deinit_tap(); diff --git a/src/osd/sdl/netdev.h b/src/osd/sdl/netdev.h deleted file mode 100644 index 4a3ae6c8de2..00000000000 --- a/src/osd/sdl/netdev.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __NETDEV_H__ -#define __NETDEV_H__ - -void sdlnetdev_init(running_machine &machine); -void sdlnetdev_deinit(running_machine &machine); - -#endif diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index 6f1ee81492d..ca91d8d1f3b 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -238,6 +238,8 @@ public: // debugger overridables virtual void init_debugger(); virtual void wait_for_debugger(device_t &device, bool firststop); + virtual void debugger_update(); + virtual void debugger_exit(); // audio overridables virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); @@ -251,8 +253,26 @@ public: virtual void font_close(osd_font font); virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); + virtual bool video_init(); + virtual bool sound_init(); + virtual bool input_init(); + virtual void input_pause(); + virtual void input_resume(); + virtual bool output_init(); + #ifdef USE_NETWORK + virtual bool network_init(); + #endif + + virtual void video_exit(); + virtual void sound_exit(); + virtual void input_exit(); + virtual void output_exit(); + #ifdef USE_NETWORK + virtual void network_exit(); + #endif + private: - static void osd_exit(running_machine &machine); + virtual void osd_exit(); watchdog *m_watchdog; diff --git a/src/osd/sdl/output.c b/src/osd/sdl/output.c index 3f6b75372d9..59d66307f5e 100644 --- a/src/osd/sdl/output.c +++ b/src/osd/sdl/output.c @@ -71,12 +71,10 @@ PID_CAST osd_getpid(void) // sdloutput_init //============================================================ -void sdloutput_init(running_machine &machine) +bool sdl_osd_interface::output_init() { int fildes; - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(sdloutput_exit), &machine)); - fildes = open(SDLMAME_OUTPUT, O_RDWR | O_NONBLOCK); if (fildes < 0) @@ -89,11 +87,12 @@ void sdloutput_init(running_machine &machine) output = fdopen(fildes, "w"); osd_printf_verbose("output: opened output notifier file %s\n", SDLMAME_OUTPUT); - fprintf(output, "MAME " PID_FMT " START %s\n", osd_getpid(), machine.system().name); + fprintf(output, "MAME " PID_FMT " START %s\n", osd_getpid(), machine().system().name); fflush(output); } output_set_notifier(NULL, notifier_callback, NULL); + return true; } @@ -101,11 +100,11 @@ void sdloutput_init(running_machine &machine) // winoutput_exit //============================================================ -static void sdloutput_exit(running_machine &machine) +void sdl_osd_interface::output_exit() { if (output != NULL) { - fprintf(output, "MAME " PID_FMT " STOP %s\n", osd_getpid(), machine.system().name); + fprintf(output, "MAME " PID_FMT " STOP %s\n", osd_getpid(), machine().system().name); fflush(output); fclose(output); output = NULL; @@ -128,13 +127,20 @@ static void notifier_callback(const char *outname, INT32 value, void *param) #else /* SDLMAME_WIN32 */ +#include "emu.h" +#include "osdsdl.h" #include "emucore.h" //============================================================ // Stub for win32 //============================================================ -void sdloutput_init(running_machine &machine) +bool sdl_osd_interface::output_init() +{ + return true; +} + +void sdl_osd_interface::output_exit() { } diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak index 9d92061ab3a..4bbe10d372f 100644 --- a/src/osd/sdl/sdl.mak +++ b/src/osd/sdl/sdl.mak @@ -397,7 +397,6 @@ OSDOBJS = \ $(SDLOBJ)/window.o \ $(SDLOBJ)/output.o \ $(SDLOBJ)/watchdog.o \ - $(SDLOBJ)/sdlmidi.o ifdef NO_USE_MIDI DEFS += -DDISABLE_MIDI=1 diff --git a/src/osd/sdl/sdlmain.c b/src/osd/sdl/sdlmain.c index 4c91d17abd4..c3a7e68c572 100644 --- a/src/osd/sdl/sdlmain.c +++ b/src/osd/sdl/sdlmain.c @@ -50,7 +50,6 @@ #include "output.h" #include "osdsdl.h" #include "sdlos.h" -#include "netdev.h" // we override SDL's normal startup on Win32 // please see sdlprefix.h as well @@ -370,8 +369,6 @@ int main(int argc, char *argv[]) } #endif - osd_init_midi(); // this is a blues riff in B, watch me for the changes and try to keep up... - { sdl_osd_interface osd; sdl_options options; @@ -401,8 +398,6 @@ int main(int argc, char *argv[]) #endif #endif - osd_shutdown_midi(); - exit(res); return res; @@ -444,11 +439,10 @@ sdl_osd_interface::~sdl_osd_interface() // osd_exit //============================================================ -void sdl_osd_interface::osd_exit(running_machine &machine) +void sdl_osd_interface::osd_exit() { - #ifdef SDLMAME_NETWORK - sdlnetdev_deinit(machine); - #endif + + osd_interface::exit_subsystems(); if (!SDLMAME_INIT_IN_WORKER_THREAD) { @@ -667,8 +661,6 @@ void sdl_osd_interface::init(running_machine &machine) } osd_sdl_info(); } - // must be before sdlvideo_init! - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_exit), &machine)); defines_verbose(); @@ -676,26 +668,11 @@ void sdl_osd_interface::init(running_machine &machine) if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) { osd_printf_error("sdlmame: -debug not supported on X11-less builds\n\n"); - osd_exit(machine); + osd_exit(); exit(-1); } - if (sdlvideo_init(machine)) - { - osd_exit(machine); - osd_printf_error("sdlvideo_init: Initialization failed!\n\n\n"); - fflush(stderr); - fflush(stdout); - exit(-1); - } - - sdlinput_init(machine); - sdlaudio_init(machine); - sdloutput_init(machine); - -#ifdef SDLMAME_NETWORK - sdlnetdev_init(machine); -#endif + osd_interface::init_subsystems(); if (options.oslog()) machine.add_logerror_callback(output_oslog); diff --git a/src/osd/sdl/sdlmidi.c b/src/osd/sdl/sdlmidi.c deleted file mode 100644 index 15438c6dff4..00000000000 --- a/src/osd/sdl/sdlmidi.c +++ /dev/null @@ -1 +0,0 @@ -#include "../portmedia/pmmidi.inc" diff --git a/src/osd/sdl/sound.c b/src/osd/sdl/sound.c index e8138536217..2abca395d7d 100644 --- a/src/osd/sdl/sound.c +++ b/src/osd/sdl/sound.c @@ -73,7 +73,6 @@ static int sdl_init(running_machine &machine); static void sdl_kill(running_machine &machine); static int sdl_create_buffers(void); static void sdl_destroy_buffers(void); -static void sdl_cleanup_audio(running_machine &machine); static void SDLCALL sdl_callback(void *userdata, Uint8 *stream, int len); @@ -81,23 +80,27 @@ static void SDLCALL sdl_callback(void *userdata, Uint8 *stream, int len) //============================================================ // osd_start_audio_stream //============================================================ -void sdlaudio_init(running_machine &machine) +bool sdl_osd_interface::sound_init() { if (LOG_SOUND) sound_log = fopen(SDLMAME_SOUND_LOG, "w"); // skip if sound disabled - if (machine.sample_rate() != 0) + if (machine().sample_rate() != 0) { + if (initialized_audio) + { + sound_exit(); + } + // attempt to initialize SDL - if (sdl_init(machine)) - return; + if (sdl_init(machine())) + return false; - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(sdl_cleanup_audio), &machine)); // set the startup volume - machine.osd().set_mastervolume(attenuation); + machine().osd().set_mastervolume(attenuation); } - return; + return true; } @@ -106,14 +109,14 @@ void sdlaudio_init(running_machine &machine) // osd_stop_audio_stream //============================================================ -static void sdl_cleanup_audio(running_machine &machine) +void sdl_osd_interface::sound_exit() { // if nothing to do, don't do it - if (machine.sample_rate() == 0) + if (machine().sample_rate() == 0) return; // kill the buffers and dsound - sdl_kill(machine); + sdl_kill(machine()); sdl_destroy_buffers(); // print out over/underflow stats @@ -426,11 +429,6 @@ static int sdl_init(running_machine &machine) SDL_AudioSpec aspec, obtained; char audio_driver[16] = ""; - if (initialized_audio) - { - sdl_cleanup_audio(machine); - } - osd_printf_verbose("Audio: Start initialization\n"); #if (SDLMAME_SDL2) strncpy(audio_driver, SDL_GetCurrentAudioDriver(), sizeof(audio_driver)); diff --git a/src/osd/sdl/video.c b/src/osd/sdl/video.c index b4e020631b8..50ea2ffc15c 100644 --- a/src/osd/sdl/video.c +++ b/src/osd/sdl/video.c @@ -49,11 +49,6 @@ #include "video.h" #include "window.h" #include "input.h" - -#if !defined(NO_DEBUGGER) -#include "debugqt.h" -#endif - #include "osdsdl.h" #include "sdlos.h" @@ -85,7 +80,6 @@ static sdl_monitor_info *sdl_monitor_list; // PROTOTYPES //============================================================ -static void video_exit(running_machine &machine); static void init_monitors(void); static sdl_monitor_info *pick_monitor(sdl_options &options, int index); @@ -101,38 +95,35 @@ static void get_resolution(const char *defdata, const char *data, sdl_window_con // sdlvideo_init //============================================================ -int sdlvideo_init(running_machine &machine) +bool sdl_osd_interface::video_init() { int index; // extract data from the options - extract_video_config(machine); - - // ensure we get called on the way out - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(video_exit), &machine)); + extract_video_config(machine()); // set up monitors first init_monitors(); // we need the beam width in a float, contrary to what the core does. - video_config.beamwidth = machine.options().beam(); + video_config.beamwidth = machine().options().beam(); // initialize the window system so we can make windows - if (sdlwindow_init(machine)) - return 1; + if (sdlwindow_init(machine())) + return false; // create the windows - sdl_options &options = downcast<sdl_options &>(machine.options()); + sdl_options &options = downcast<sdl_options &>(machine().options()); for (index = 0; index < video_config.numscreens; index++) { sdl_window_config conf; memset(&conf, 0, sizeof(conf)); - extract_window_config(machine, index, &conf); - if (sdlwindow_video_window_create(machine, index, pick_monitor(options, index), &conf)) - return 1; + extract_window_config(machine(), index, &conf); + if (sdlwindow_video_window_create(machine(), index, pick_monitor(options, index), &conf)) + return false; } - return 0; + return true; } @@ -140,7 +131,7 @@ int sdlvideo_init(running_machine &machine) // video_exit //============================================================ -static void video_exit(running_machine &machine) +void sdl_osd_interface::video_exit() { // free all of our monitor information while (sdl_monitor_list != NULL) @@ -341,10 +332,8 @@ void sdl_osd_interface::update(bool skip_redraw) sdlinput_poll(machine()); check_osd_inputs(machine()); -#if !defined(NO_DEBUGGER) if ((machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) != 0) - debugwin_update_during_game(machine()); -#endif + debugger_update(); } diff --git a/src/osd/windows/debugwin.c b/src/osd/windows/debugwin.c index 91158575199..d8758bd3a49 100644 --- a/src/osd/windows/debugwin.c +++ b/src/osd/windows/debugwin.c @@ -30,7 +30,6 @@ #include "debug/debugcpu.h" // MAMEOS headers -#include "debugwin.h" #include "winmain.h" #include "window.h" #include "video.h" @@ -436,9 +435,6 @@ void windows_osd_interface::init_debugger() // get other metrics hscroll_height = GetSystemMetrics(SM_CYHSCROLL); vscroll_width = GetSystemMetrics(SM_CXVSCROLL); - - // ensure we get called on the way out - machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debugwin_destroy_windows), &machine())); } @@ -447,7 +443,7 @@ void windows_osd_interface::init_debugger() // debugwin_destroy_windows //============================================================ -void debugwin_destroy_windows(running_machine &machine) +void windows_osd_interface::debugger_exit() { // loop over windows and free them while (window_list != NULL) @@ -463,21 +459,21 @@ void debugwin_destroy_windows(running_machine &machine) //============================================================ -// debugwin_update_during_game +// debugger_update //============================================================ -void debugwin_update_during_game(running_machine &machine) +void windows_osd_interface::debugger_update() { // if we're running live, do some checks - if (!winwindow_has_focus() && !debug_cpu_is_stopped(machine) && machine.phase() == MACHINE_PHASE_RUNNING) + if (!winwindow_has_focus() && !debug_cpu_is_stopped(machine()) && machine().phase() == MACHINE_PHASE_RUNNING) { // see if the interrupt key is pressed and break if it is - if (debugwin_seq_pressed(machine)) + if (debugwin_seq_pressed(machine())) { HWND focuswnd = GetFocus(); debugwin_info *info; - debug_cpu_get_visible_cpu(machine)->debug()->halt_on_next_instruction("User-initiated break\n"); + debug_cpu_get_visible_cpu(machine())->debug()->halt_on_next_instruction("User-initiated break\n"); // if we were focused on some window's edit box, reset it to default for (info = window_list; info != NULL; info = info->next) diff --git a/src/osd/windows/debugwin.h b/src/osd/windows/debugwin.h deleted file mode 100644 index 81ca10c98d2..00000000000 --- a/src/osd/windows/debugwin.h +++ /dev/null @@ -1,28 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Aaron Giles -//============================================================ -// -// debugwin.h - Win32 debug window handling -// -//============================================================ - -#ifndef __WIN_DEBUGWIN__ -#define __WIN_DEBUGWIN__ - - -//============================================================ -// GLOBAL VARIABLES -//============================================================ - -// windows - - - -//============================================================ -// PROTOTYPES -//============================================================ - -void debugwin_destroy_windows(running_machine &machine); -void debugwin_update_during_game(running_machine &machine); - -#endif diff --git a/src/osd/windows/input.c b/src/osd/windows/input.c index 05563f7abce..ab2221ec554 100644 --- a/src/osd/windows/input.c +++ b/src/osd/windows/input.c @@ -34,7 +34,6 @@ #include "winmain.h" #include "window.h" #include "input.h" -#include "debugwin.h" #include "video.h" #include "strconv.h" #include "config.h" @@ -213,10 +212,6 @@ static const TCHAR *const default_axis_name[] = // PROTOTYPES //============================================================ -static void wininput_pause(running_machine &machine); -static void wininput_resume(running_machine &machine); -static void wininput_exit(running_machine &machine); - // device list management static void device_list_poll_devices(device_info *devlist_head); static void device_list_reset_devices(device_info *devlist_head); @@ -463,31 +458,27 @@ INLINE INT32 normalize_absolute_axis(INT32 raw, INT32 rawmin, INT32 rawmax) //============================================================ -// wininput_init +// input_init //============================================================ -void wininput_init(running_machine &machine) +bool windows_osd_interface::input_init() { - // we need pause and exit callbacks - machine.add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(wininput_pause), &machine)); - machine.add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(wininput_resume), &machine)); - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(wininput_exit), &machine)); - // allocate a lock for input synchronizations, since messages sometimes come from another thread input_lock = osd_lock_alloc(); assert_always(input_lock != NULL, "Failed to allocate input_lock"); // decode the options - lightgun_shared_axis_mode = downcast<windows_options &>(machine.options()).dual_lightgun(); + lightgun_shared_axis_mode = downcast<windows_options &>(machine().options()).dual_lightgun(); // initialize RawInput and DirectInput (RawInput first so we can fall back) - rawinput_init(machine); - dinput_init(machine); - win32_init(machine); + rawinput_init(machine()); + dinput_init(machine()); + win32_init(machine()); // poll once to get the initial states input_enabled = true; - wininput_poll(machine); + wininput_poll(machine()); + return true; } @@ -495,13 +486,13 @@ void wininput_init(running_machine &machine) // wininput_pause //============================================================ -static void wininput_pause(running_machine &machine) +void windows_osd_interface::input_pause() { // keep track of the paused state input_paused = true; } -static void wininput_resume(running_machine &machine) +void windows_osd_interface::input_resume() { // keep track of the paused state input_paused = false; @@ -512,7 +503,7 @@ static void wininput_resume(running_machine &machine) // wininput_exit //============================================================ -static void wininput_exit(running_machine &machine) +void windows_osd_interface::input_exit() { // acquire the lock and turn off input (this ensures everyone is done) osd_lock_acquire(input_lock); diff --git a/src/osd/windows/netdev.c b/src/osd/windows/netdev.c index 29bb4a17696..4702a67912e 100644 --- a/src/osd/windows/netdev.c +++ b/src/osd/windows/netdev.c @@ -1,12 +1,14 @@ #include "emu.h" +#include "winmain.h" #include "netdev_pcap.h" -void winnetdev_init(running_machine &machine) +bool windows_osd_interface::network_init() { init_pcap(); + return true; } -void winnetdev_deinit(running_machine &machine) +void windows_osd_interface::network_exit() { deinit_pcap(); } diff --git a/src/osd/windows/netdev.h b/src/osd/windows/netdev.h deleted file mode 100644 index 3a05d4530c7..00000000000 --- a/src/osd/windows/netdev.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __NETDEV_H -#define __NETDEV_H - -void winnetdev_init(running_machine &machine); -void winnetdev_deinit(running_machine &machine); - -#endif diff --git a/src/osd/windows/output.c b/src/osd/windows/output.c index 689c02cc6e4..d8df2a36c5d 100644 --- a/src/osd/windows/output.c +++ b/src/osd/windows/output.c @@ -13,7 +13,7 @@ // MAME headers #include "emu.h" #include "osdepend.h" - +#include "winmain.h" // MAMEOS headers #include "output.h" @@ -66,7 +66,6 @@ static UINT om_mame_get_id_string; // FUNCTION PROTOTYPES //============================================================ -static void winoutput_exit(running_machine &machine); static int create_window_class(void); static LRESULT CALLBACK output_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam); static LRESULT register_client(HWND hwnd, LPARAM id); @@ -77,16 +76,13 @@ static void notifier_callback(const char *outname, INT32 value, void *param); //============================================================ -// winoutput_init +// output_init //============================================================ -void winoutput_init(running_machine &machine) +bool windows_osd_interface::output_init() { int result; - // ensure we get cleaned up - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(winoutput_exit), &machine)); - // reset globals clientlist = NULL; @@ -110,7 +106,7 @@ void winoutput_init(running_machine &machine) assert(output_hwnd != NULL); // set a pointer to the running machine - SetWindowLongPtr(output_hwnd, GWLP_USERDATA, (LONG_PTR)&machine); + SetWindowLongPtr(output_hwnd, GWLP_USERDATA, (LONG_PTR)&machine()); // allocate message ids om_mame_start = RegisterWindowMessage(OM_MAME_START); @@ -132,14 +128,16 @@ void winoutput_init(running_machine &machine) // register a notifier for output changes output_set_notifier(NULL, notifier_callback, NULL); + + return true; } //============================================================ -// winoutput_exit +// output_exit //============================================================ -static void winoutput_exit(running_machine &machine) +void windows_osd_interface::output_exit() { // free all the clients while (clientlist != NULL) diff --git a/src/osd/windows/sound.c b/src/osd/windows/sound.c index b1aaf26a4fb..5daf9d07feb 100644 --- a/src/osd/windows/sound.c +++ b/src/osd/windows/sound.c @@ -67,7 +67,6 @@ static int buffer_overflows; // PROTOTYPES //============================================================ -static void sound_exit(running_machine &machine); static HRESULT dsound_init(running_machine &machine); static void dsound_kill(void); static HRESULT dsound_create_buffers(void); @@ -76,21 +75,19 @@ static void dsound_destroy_buffers(void); //============================================================ -// winsound_init +// sound_init //============================================================ -void winsound_init(running_machine &machine) +bool windows_osd_interface::sound_init() { // if no sound, don't create anything - if (!machine.options().sound()) - return; - - // ensure we get called on the way out - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(sound_exit), &machine)); + if (!machine().options().sound()) + return true; // attempt to initialize directsound // don't make it fatal if we can't -- we'll just run without sound - dsound_init(machine); + dsound_init(machine()); + return true; } @@ -98,7 +95,7 @@ void winsound_init(running_machine &machine) // sound_exit //============================================================ -static void sound_exit(running_machine &machine) +void windows_osd_interface::sound_exit() { // kill the buffers and dsound dsound_destroy_buffers(); diff --git a/src/osd/windows/video.c b/src/osd/windows/video.c index 1409b00f4d1..8fc99dae78d 100644 --- a/src/osd/windows/video.c +++ b/src/osd/windows/video.c @@ -25,7 +25,6 @@ #include "video.h" #include "window.h" #include "input.h" -#include "debugwin.h" #include "strconv.h" #include "config.h" @@ -51,7 +50,6 @@ static win_monitor_info *primary_monitor; // PROTOTYPES //============================================================ -static void winvideo_exit(running_machine &machine); static void init_monitors(void); static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data); static win_monitor_info *pick_monitor(windows_options &options, int index); @@ -65,43 +63,38 @@ static void get_resolution(const char *defdata, const char *data, win_window_con //============================================================ -// winvideo_init +// video_init //============================================================ -void winvideo_init(running_machine &machine) +bool windows_osd_interface::video_init() { int index; - // ensure we get called on the way out - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(winvideo_exit), &machine)); - // extract data from the options - extract_video_config(machine); + extract_video_config(machine()); // set up monitors first init_monitors(); // initialize the window system so we can make windows - winwindow_init(machine); + winwindow_init(machine()); // create the windows - windows_options &options = downcast<windows_options &>(machine.options()); + windows_options &options = downcast<windows_options &>(machine().options()); for (index = 0; index < video_config.numscreens; index++) - winwindow_video_window_create(machine, index, pick_monitor(options, index), &video_config.window[index]); + winwindow_video_window_create(machine(), index, pick_monitor(options, index), &video_config.window[index]); if (video_config.mode != VIDEO_MODE_NONE) SetForegroundWindow(win_window_list->hwnd); - // possibly create the debug window, but don't show it yet - if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) - machine.osd().init_debugger(); + return true; } //============================================================ -// winvideo_exit +// video_exit //============================================================ -static void winvideo_exit(running_machine &machine) +void windows_osd_interface::video_exit() { // free all of our monitor information while (win_monitor_list != NULL) @@ -186,6 +179,9 @@ void windows_osd_interface::update(bool skip_redraw) winwindow_process_events(machine(), TRUE, FALSE); wininput_poll(machine()); check_osd_inputs(machine()); + // if we're running, disable some parts of the debugger + if ((machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) != 0) + debugger_update(); } diff --git a/src/osd/windows/window.c b/src/osd/windows/window.c index 74a0bbc2222..f3516ade783 100644 --- a/src/osd/windows/window.c +++ b/src/osd/windows/window.c @@ -31,7 +31,6 @@ #include "window.h" #include "video.h" #include "input.h" -#include "debugwin.h" #include "strconv.h" #include "config.h" #include "winutf8.h" @@ -344,10 +343,6 @@ void winwindow_process_events(running_machine &machine, int ingame, bool nodispa assert(GetCurrentThreadId() == main_threadid); - // if we're running, disable some parts of the debugger - if (ingame && (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) != 0) - debugwin_update_during_game(machine); - // remember the last time we did this last_event_check = GetTickCount(); diff --git a/src/osd/windows/windows.mak b/src/osd/windows/windows.mak index cc488a77eb8..07283be259f 100644 --- a/src/osd/windows/windows.mak +++ b/src/osd/windows/windows.mak @@ -317,7 +317,6 @@ OSDCOREOBJS = \ $(WINOBJ)/winsocket.o \ $(WINOBJ)/winwork.o \ $(WINOBJ)/winptty.o \ - $(WINOBJ)/winmidi.o #------------------------------------------------- diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index 0305dcf3157..8dbcdbec3b2 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -39,9 +39,6 @@ #include "winutil.h" #include "debugger.h" #include "winfile.h" -#ifdef USE_NETWORK -#include "netdev.h" -#endif #define DEBUG_SLOW_LOCKS 0 @@ -466,8 +463,6 @@ int main(int argc, char *argv[]) FreeConsole(); } - osd_init_midi(); - // parse config and cmdline options DWORD result = 0; { @@ -476,9 +471,6 @@ int main(int argc, char *argv[]) cli_frontend frontend(options, osd); result = frontend.execute(argc, argv); } - - osd_shutdown_midi(); - // free symbols symbols = NULL; return result; @@ -617,9 +609,6 @@ void windows_osd_interface::init(running_machine &machine) if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)) SetThreadPriority(GetCurrentThread(), options.priority()); - // ensure we get called on the way out - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_exit), &machine)); - // get number of processors stemp = options.numprocessors(); @@ -636,13 +625,8 @@ void windows_osd_interface::init(running_machine &machine) } // initialize the subsystems - winvideo_init(machine); - winsound_init(machine); - wininput_init(machine); - winoutput_init(machine); -#ifdef USE_NETWORK - winnetdev_init(machine); -#endif + osd_interface::init_subsystems(); + // notify listeners of screen configuration astring tempstring; for (win_window_info *info = win_window_list; info != NULL; info = info->next) @@ -698,7 +682,7 @@ void windows_osd_interface::init(running_machine &machine) // osd_exit //============================================================ -void windows_osd_interface::osd_exit(running_machine &machine) +void windows_osd_interface::osd_exit() { // no longer have a machine g_current_machine = NULL; @@ -706,10 +690,8 @@ void windows_osd_interface::osd_exit(running_machine &machine) // cleanup sockets win_cleanup_sockets(); - #ifdef USE_NETWORK - winnetdev_deinit(machine); - #endif - + osd_interface::exit_subsystems(); + // take down the watchdog thread if it exists if (watchdog_thread != NULL) { @@ -740,7 +722,7 @@ void windows_osd_interface::osd_exit(running_machine &machine) timeEndPeriod(caps.wPeriodMin); // one last pass at events - winwindow_process_events(machine, 0, 0); + winwindow_process_events(machine(), 0, 0); } diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index 2e1a0c6b5b7..105c72586da 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -298,6 +298,8 @@ public: // debugger overridables virtual void init_debugger(); virtual void wait_for_debugger(device_t &device, bool firststop); + virtual void debugger_update(); + virtual void debugger_exit(); // audio overridables virtual void update_audio_stream(const INT16 *buffer, int samples_this_frame); @@ -314,8 +316,26 @@ public: virtual void font_close(osd_font font); virtual bool font_get_bitmap(osd_font font, unicode_char chnum, bitmap_argb32 &bitmap, INT32 &width, INT32 &xoffs, INT32 &yoffs); + virtual bool video_init(); + virtual bool sound_init(); + virtual bool input_init(); + virtual void input_pause(); + virtual void input_resume(); + virtual bool output_init(); + #ifdef USE_NETWORK + virtual bool network_init(); + #endif + + virtual void video_exit(); + virtual void sound_exit(); + virtual void input_exit(); + virtual void output_exit(); + #ifdef USE_NETWORK + virtual void network_exit(); + #endif + private: - static void osd_exit(running_machine &machine); + void osd_exit(); static const int DEFAULT_FONT_HEIGHT = 200; }; diff --git a/src/osd/windows/winmidi.c b/src/osd/windows/winmidi.c deleted file mode 100644 index 15438c6dff4..00000000000 --- a/src/osd/windows/winmidi.c +++ /dev/null @@ -1 +0,0 @@ -#include "../portmedia/pmmidi.inc" |