diff --git a/src/emu/drivenum.h b/src/emu/drivenum.h index faaf685304a..e4f646d77f7 100644 --- a/src/emu/drivenum.h +++ b/src/emu/drivenum.h @@ -14,6 +14,13 @@ #define __DRIVENUM_H__ +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +GAME_EXTERN(___empty); + + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** diff --git a/src/emu/gamedrv.h b/src/emu/gamedrv.h index 070c69f6a85..d5b7f15f32c 100644 --- a/src/emu/gamedrv.h +++ b/src/emu/gamedrv.h @@ -189,10 +189,4 @@ extern const game_driver GAME_NAME(NAME) = \ }; -//************************************************************************** -// GLOBAL VARIABLES -//************************************************************************** - -GAME_EXTERN(___empty); - #endif diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index 5eb1e4f3037..27f6d0dd568 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -283,7 +283,7 @@ void running_machine::start() // run - execute the machine //------------------------------------------------- -int running_machine::run(bool firstrun) +int running_machine::run(bool quiet) { int error = EMU_ERR_NONE; @@ -294,7 +294,7 @@ int running_machine::run(bool firstrun) m_current_phase = MACHINE_PHASE_INIT; // if we have a logfile, set up the callback - if (options().log() && &system() != &GAME_NAME(___empty)) + if (options().log() && !quiet) { m_logfile = std::make_unique(OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); osd_file::error filerr = m_logfile->open("error.log"); @@ -315,10 +315,12 @@ int running_machine::run(bool firstrun) nvram_load(); sound().ui_mute(false); + if (!quiet) + sound().start_recording(); // initialize ui lists // display the startup screens - manager().ui_initialize(*this, firstrun); + manager().ui_initialize(*this); // perform a soft reset -- this takes us to the running phase soft_reset(); diff --git a/src/emu/machine.h b/src/emu/machine.h index 45001f406bb..02721c30718 100644 --- a/src/emu/machine.h +++ b/src/emu/machine.h @@ -203,7 +203,7 @@ public: template inline _DeviceClass *device(const char *tag) { return downcast<_DeviceClass *>(device(tag)); } // immediate operations - int run(bool firstrun); + int run(bool quiet); void pause(); void resume(); void toggle_pause(); diff --git a/src/emu/main.h b/src/emu/main.h index 5b4d0124fa4..0b0aa16121e 100644 --- a/src/emu/main.h +++ b/src/emu/main.h @@ -81,7 +81,7 @@ public: void set_machine(running_machine *machine) { m_machine = machine; } virtual ui_manager* create_ui(running_machine& machine) { return nullptr; } - virtual void ui_initialize(running_machine& machine,bool firstrun) { } + virtual void ui_initialize(running_machine& machine) { } virtual void update_machine() { } protected: diff --git a/src/emu/sound.cpp b/src/emu/sound.cpp index 194c98c7190..0983a5f0a22 100644 --- a/src/emu/sound.cpp +++ b/src/emu/sound.cpp @@ -834,15 +834,12 @@ sound_manager::sound_manager(running_machine &machine) VPRINTF(("total mixers = %d\n", iter.count())); #endif - // open the output WAV file if specified - if (wavfile[0] != 0 && &machine.system() != &GAME_NAME(___empty)) - m_wavfile = wav_open(wavfile, machine.sample_rate(), 2); - // register callbacks machine.configuration().config_register("mixer", config_saveload_delegate(FUNC(sound_manager::config_load), this), config_saveload_delegate(FUNC(sound_manager::config_save), this)); machine.add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(sound_manager::pause), this)); machine.add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(sound_manager::resume), this)); machine.add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(sound_manager::reset), this)); + machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(sound_manager::stop_recording), this)); // register global states machine.save().save_item(NAME(m_last_update)); @@ -861,6 +858,28 @@ sound_manager::sound_manager(running_machine &machine) //------------------------------------------------- sound_manager::~sound_manager() +{ +} + + +//------------------------------------------------- +// start_recording - begin audio recording +//------------------------------------------------- + +void sound_manager::start_recording() +{ + // open the output WAV file if specified + const char *wavfile = machine().options().wav_write(); + if (wavfile[0] != 0 && m_wavfile == nullptr) + m_wavfile = wav_open(wavfile, machine().sample_rate(), 2); +} + + +//------------------------------------------------- +// stop_recording - end audio recording +//------------------------------------------------- + +void sound_manager::stop_recording() { // close any open WAV file if (m_wavfile != nullptr) diff --git a/src/emu/sound.h b/src/emu/sound.h index 1776c07c756..8cafe52e069 100644 --- a/src/emu/sound.h +++ b/src/emu/sound.h @@ -207,6 +207,8 @@ public: sound_stream *stream_alloc(device_t &device, int inputs, int outputs, int sample_rate, stream_update_delegate callback = stream_update_delegate()); // global controls + void start_recording(); + void stop_recording(); void set_attenuation(int attenuation); void ui_mute(bool turn_off = true) { mute(turn_off, MUTE_REASON_UI); } void debugger_mute(bool turn_off = true) { mute(turn_off, MUTE_REASON_DEBUGGER); } diff --git a/src/frontend/mame/audit.cpp b/src/frontend/mame/audit.cpp index 60781ae7710..a2b534f6199 100644 --- a/src/frontend/mame/audit.cpp +++ b/src/frontend/mame/audit.cpp @@ -12,6 +12,7 @@ #include "emuopts.h" #include "audit.h" #include "chd.h" +#include "drivenum.h" #include "sound/samples.h" #include "softlist.h" diff --git a/src/frontend/mame/audit.h b/src/frontend/mame/audit.h index 83421f8cc6e..461a5bbce3c 100644 --- a/src/frontend/mame/audit.h +++ b/src/frontend/mame/audit.h @@ -13,7 +13,6 @@ #ifndef __AUDIT_H__ #define __AUDIT_H__ -#include "drivenum.h" #include "hash.h" @@ -33,6 +32,9 @@ //************************************************************************** +// forward declarations +class driver_enumerator; + // ======================> audit_record // holds the result of auditing a single item diff --git a/src/frontend/mame/info.cpp b/src/frontend/mame/info.cpp index ee77890d63b..6f5e65d10fb 100644 --- a/src/frontend/mame/info.cpp +++ b/src/frontend/mame/info.cpp @@ -17,6 +17,7 @@ #include "info.h" #include "xmlfile.h" #include "config.h" +#include "drivenum.h" #include "softlist.h" #include diff --git a/src/frontend/mame/info.h b/src/frontend/mame/info.h index 78082ec033b..4ba53f885ac 100644 --- a/src/frontend/mame/info.h +++ b/src/frontend/mame/info.h @@ -13,7 +13,7 @@ #ifndef __INFO_H__ #define __INFO_H__ -#include "drivenum.h" +class driver_enumerator; //************************************************************************** diff --git a/src/frontend/mame/mame.cpp b/src/frontend/mame/mame.cpp index 2be1ea0f615..ac6610a8ab8 100644 --- a/src/frontend/mame/mame.cpp +++ b/src/frontend/mame/mame.cpp @@ -5,68 +5,6 @@ mame.c Controls execution of the core MAME system. -**************************************************************************** - - Since there has been confusion in the past over the order of - initialization and other such things, here it is, all spelled out - as of January, 2008: - - main() - - does platform-specific init - - calls mame_execute() [mame.c] - - mame_execute() [mame.c] - - calls mame_validitychecks() [validity.c] to perform validity checks on all compiled drivers - - begins resource tracking (level 1) - - calls create_machine [mame.c] to initialize the running_machine structure - - calls init_machine() [mame.c] - - init_machine() [mame.c] - - calls fileio_init() [fileio.c] to initialize file I/O info - - calls config_init() [config.c] to initialize configuration system - - calls input_init() [input.c] to initialize the input system - - calls output_init() [output.c] to initialize the output system - - calls state_init() [state.c] to initialize save state system - - calls state_save_allow_registration() [state.c] to allow registrations - - calls palette_init() [palette.c] to initialize palette system - - calls render_init() [render.c] to initialize the rendering system - - calls ui_init() [ui.c] to initialize the user interface - - calls generic_machine_init() [machine/generic.c] to initialize generic machine structures - - calls generic_video_init() [video/generic.c] to initialize generic video structures - - calls generic_sound_init() [audio/generic.c] to initialize generic sound structures - - calls timer_init() [timer.c] to reset the timer system - - calls osd_init() [osdepend.h] to do platform-specific initialization - - calls input_port_init() [inptport.c] to set up the input ports - - calls rom_init() [romload.c] to load the game's ROMs - - calls memory_init() [memory.c] to process the game's memory maps - - calls watchdog_init() [watchdog.c] to initialize the watchdog system - - calls the driver's DRIVER_INIT callback - - calls device_list_start() [devintrf.c] to start any devices - - calls video_init() [video.c] to start the video system - - calls tilemap_init() [tilemap.c] to start the tilemap system - - calls crosshair_init() [crsshair.c] to configure the crosshairs - - calls sound_init() [sound.c] to start the audio system - - calls debugger_init() [debugger.c] to set up the debugger - - calls the driver's MACHINE_START, SOUND_START, and VIDEO_START callbacks - - calls cheat_init() [cheat.c] to initialize the cheat system - - calls image_init() [image.c] to initialize the image system - - - calls config_load_settings() [config.c] to load the configuration file - - calls nvram_load [machine/generic.c] to load NVRAM - - calls ui_display_startup_screens() [ui.c] to display the startup screens - - begins resource tracking (level 2) - - calls soft_reset() [mame.c] to reset all systems - - -------------------( at this point, we're up and running )---------------------- - - - calls scheduler->timeslice() [schedule.c] over and over until we exit - - ends resource tracking (level 2), freeing all auto_mallocs and timers - - calls the nvram_save() [machine/generic.c] to save NVRAM - - calls config_save_settings() [config.c] to save the game's configuration - - calls all registered exit routines [mame.c] - - ends resource tracking (level 1), freeing all auto_mallocs and timers - - - exits the program ***************************************************************************/ @@ -77,6 +15,7 @@ #include "osdepend.h" #include "validity.h" #include "clifront.h" +#include "drivenum.h" #include "luaengine.h" #include #include "ui/selgame.h" @@ -113,7 +52,8 @@ mame_machine_manager::mame_machine_manager(emu_options &options,osd_interface &o : machine_manager(options, osd), m_plugins(std::make_unique()), m_lua(global_alloc(lua_engine)), - m_new_driver_pending(nullptr) + m_new_driver_pending(nullptr), + m_firstrun(true) { } @@ -230,7 +170,6 @@ int mame_machine_manager::execute() bool started_empty = false; bool firstgame = true; - bool firstrun = true; // loop across multiple hard resets bool exit_pending = false; @@ -263,7 +202,8 @@ int mame_machine_manager::execute() } // otherwise, perform validity checks before anything else - if (system != nullptr) + bool is_empty = (system == &GAME_NAME(___empty)); + if (!is_empty) { validity_checker valid(m_options); valid.set_verbose(false); @@ -279,22 +219,22 @@ int mame_machine_manager::execute() set_machine(&machine); // run the machine - error = machine.run(firstrun); - firstrun = false; + error = machine.run(is_empty); + m_firstrun = false; // check the state of the machine if (m_new_driver_pending) { // set up new system name and adjust device options accordingly mame_options::set_system_name(m_options,m_new_driver_pending->name); - firstrun = true; + m_firstrun = true; } else { if (machine.exit_pending()) mame_options::set_system_name(m_options,""); } - if (machine.exit_pending() && (!started_empty || (system == &GAME_NAME(___empty)))) + if (machine.exit_pending() && (!started_empty || is_empty)) exit_pending = true; // machine will go away when we exit scope @@ -349,12 +289,12 @@ ui_manager* mame_machine_manager::create_ui(running_machine& machine) return m_ui.get(); } -void mame_machine_manager::ui_initialize(running_machine& machine,bool firstrun) +void mame_machine_manager::ui_initialize(running_machine& machine) { m_ui->initialize(machine); // display the startup screens - m_ui->display_startup_screens(firstrun); + m_ui->display_startup_screens(m_firstrun); } const char * emulator_info::get_bare_build_version() { return bare_build_version; } diff --git a/src/frontend/mame/mame.h b/src/frontend/mame/mame.h index 9b96982eae2..2de8f8d4876 100644 --- a/src/frontend/mame/mame.h +++ b/src/frontend/mame/mame.h @@ -9,10 +9,6 @@ #pragma once -#ifndef __EMU_H__ -#error Dont include this file directly; include emu.h instead. -#endif - #ifndef __MAME_H__ #define __MAME_H__ @@ -55,7 +51,7 @@ public: TIMER_CALLBACK_MEMBER(autoboot_callback); virtual ui_manager* create_ui(running_machine& machine) override; - virtual void ui_initialize(running_machine& machine,bool firstrun) override; + virtual void ui_initialize(running_machine& machine) override; /* execute as configured by the OPTION_SYSTEMNAME option on the specified options */ int execute(); @@ -71,6 +67,7 @@ private: lua_engine * m_lua; const game_driver * m_new_driver_pending; // pointer to the next pending driver + bool m_firstrun; static mame_machine_manager* m_manager; emu_timer *m_autoboot_timer; // autoboot timer diff --git a/src/frontend/mame/ui/auditmenu.cpp b/src/frontend/mame/ui/auditmenu.cpp index 3c1ddace6cf..43da259cdc7 100644 --- a/src/frontend/mame/ui/auditmenu.cpp +++ b/src/frontend/mame/ui/auditmenu.cpp @@ -13,6 +13,7 @@ #include "ui/menu.h" #include "audit.h" #include "ui/auditmenu.h" +#include "drivenum.h" extern const char UI_VERSION_TAG[]; diff --git a/src/frontend/mame/ui/imgcntrl.cpp b/src/frontend/mame/ui/imgcntrl.cpp index 78bbf1825a2..f06638a2fcb 100644 --- a/src/frontend/mame/ui/imgcntrl.cpp +++ b/src/frontend/mame/ui/imgcntrl.cpp @@ -16,6 +16,7 @@ #include "ui/filesel.h" #include "ui/swlist.h" #include "zippath.h" +#include "drivenum.h" #include "audit.h" #include "softlist.h" diff --git a/src/frontend/mame/ui/imgcntrl.h b/src/frontend/mame/ui/imgcntrl.h index 3d978ed617c..669098a4306 100644 --- a/src/frontend/mame/ui/imgcntrl.h +++ b/src/frontend/mame/ui/imgcntrl.h @@ -13,8 +13,6 @@ #ifndef __UI_IMGCNTRL_H__ #define __UI_IMGCNTRL_H__ -#include "drivenum.h" - // ======================> ui_menu_control_device_image class ui_menu_control_device_image : public ui_menu { diff --git a/src/frontend/mame/ui/inputmap.h b/src/frontend/mame/ui/inputmap.h index 32ad48092ea..f49df47b892 100644 --- a/src/frontend/mame/ui/inputmap.h +++ b/src/frontend/mame/ui/inputmap.h @@ -13,8 +13,6 @@ #ifndef __UI_INPUTMAP_H__ #define __UI_INPUTMAP_H__ -//#include "drivenum.h" - class ui_menu_input_groups : public ui_menu { public: ui_menu_input_groups(running_machine &machine, render_container *container); diff --git a/src/frontend/mame/ui/mainmenu.h b/src/frontend/mame/ui/mainmenu.h index cb12e6e1d1a..4333101e694 100644 --- a/src/frontend/mame/ui/mainmenu.h +++ b/src/frontend/mame/ui/mainmenu.h @@ -13,8 +13,6 @@ #ifndef __UI_MAINMENU_H__ #define __UI_MAINMENU_H__ -#include "drivenum.h" - class ui_menu_main : public ui_menu { public: ui_menu_main(running_machine &machine, render_container *container); diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp index 3c144228d7a..a10119e876a 100644 --- a/src/frontend/mame/ui/menu.cpp +++ b/src/frontend/mame/ui/menu.cpp @@ -25,6 +25,7 @@ #include "ui/icorender.h" #include "ui/toolbar.h" #include "ui/miscmenu.h" +#include "drivenum.h" /*************************************************************************** diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp index 8ec09c4dc17..1a89cd45fa1 100644 --- a/src/frontend/mame/ui/miscmenu.cpp +++ b/src/frontend/mame/ui/miscmenu.cpp @@ -12,6 +12,7 @@ #include "mame.h" #include "osdnet.h" #include "mameopts.h" +#include "drivenum.h" #include "uiinput.h" #include "ui/ui.h" diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp index 00fbd75108e..fee7b756c66 100644 --- a/src/frontend/mame/ui/selgame.cpp +++ b/src/frontend/mame/ui/selgame.cpp @@ -15,6 +15,7 @@ #include "uiinput.h" #include "ui/selgame.h" #include "ui/miscmenu.h" +#include "drivenum.h" #include "audit.h" #include "ui/datfile.h" #include "ui/inifile.h" diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp index b9aae4170f3..1d8a6483c5c 100644 --- a/src/frontend/mame/ui/selsoft.cpp +++ b/src/frontend/mame/ui/selsoft.cpp @@ -15,6 +15,7 @@ #include "ui/menu.h" #include "uiinput.h" #include "audit.h" +#include "drivenum.h" #include "ui/selsoft.h" #include "ui/datmenu.h" #include "ui/datfile.h" diff --git a/src/frontend/mame/ui/simpleselgame.cpp b/src/frontend/mame/ui/simpleselgame.cpp index 16818ea2c8c..cd8ac95c792 100644 --- a/src/frontend/mame/ui/simpleselgame.cpp +++ b/src/frontend/mame/ui/simpleselgame.cpp @@ -18,6 +18,7 @@ #include "ui/inputmap.h" #include "ui/miscmenu.h" #include "ui/optsmenu.h" +#include "drivenum.h" #include "audit.h" #include diff --git a/src/frontend/mame/ui/simpleselgame.h b/src/frontend/mame/ui/simpleselgame.h index 316e3747b2f..2106fc54638 100644 --- a/src/frontend/mame/ui/simpleselgame.h +++ b/src/frontend/mame/ui/simpleselgame.h @@ -13,9 +13,10 @@ #ifndef __UI_SIMPLESELGAME_H__ #define __UI_SIMPLESELGAME_H__ -#include "drivenum.h" #include "menu.h" +class driver_enumerator; + class ui_simple_menu_select_game : public ui_menu { public: ui_simple_menu_select_game(running_machine &machine, render_container *container, const char *gamename); diff --git a/src/frontend/mame/ui/slotopt.h b/src/frontend/mame/ui/slotopt.h index 8d7c4ab6b18..b297a5c7e9b 100644 --- a/src/frontend/mame/ui/slotopt.h +++ b/src/frontend/mame/ui/slotopt.h @@ -13,8 +13,6 @@ #ifndef __UI_SLOTOPT_H__ #define __UI_SLOTOPT_H__ -//#include "drivenum.h" - class ui_menu_slot_devices : public ui_menu { public: ui_menu_slot_devices(running_machine &machine, render_container *container); diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index 173eff6ad9c..a7d88ea0b31 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -14,6 +14,7 @@ #include "mameopts.h" #include "video/vector.h" #include "machine/laserdsc.h" +#include "drivenum.h" #include "render.h" #include "luaengine.h" #include "cheat.h"