mirror of
https://github.com/holub/mame
synced 2025-04-28 11:11:48 +03:00
Machine management cleanups
- Boolean parameter to running_machine::run is no longer firstrun (which is now a member variable of mame_machine_manager) but quiet, which disables logging and audio recording without explicitly checking the system name. - Sound recording is now turned on and off by explicit calls. The potential uses of this have not been explored. - Dependencies reduced on drivenum.h, where the declaration for GAME_NAME(___empty) has been moved to.
This commit is contained in:
parent
5a320aba4a
commit
ec2669cacf
@ -14,6 +14,13 @@
|
||||
#define __DRIVENUM_H__
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// GLOBAL VARIABLES
|
||||
//**************************************************************************
|
||||
|
||||
GAME_EXTERN(___empty);
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
@ -189,10 +189,4 @@ extern const game_driver GAME_NAME(NAME) = \
|
||||
};
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// GLOBAL VARIABLES
|
||||
//**************************************************************************
|
||||
|
||||
GAME_EXTERN(___empty);
|
||||
|
||||
#endif
|
||||
|
@ -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<emu_file>(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();
|
||||
|
@ -203,7 +203,7 @@ public:
|
||||
template<class _DeviceClass> 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();
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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); }
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "emuopts.h"
|
||||
#include "audit.h"
|
||||
#include "chd.h"
|
||||
#include "drivenum.h"
|
||||
#include "sound/samples.h"
|
||||
#include "softlist.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
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "info.h"
|
||||
#include "xmlfile.h"
|
||||
#include "config.h"
|
||||
#include "drivenum.h"
|
||||
#include "softlist.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -13,7 +13,7 @@
|
||||
#ifndef __INFO_H__
|
||||
#define __INFO_H__
|
||||
|
||||
#include "drivenum.h"
|
||||
class driver_enumerator;
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
|
@ -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 <time.h>
|
||||
#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<plugin_options>()),
|
||||
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; }
|
||||
|
@ -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
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "ui/menu.h"
|
||||
#include "audit.h"
|
||||
#include "ui/auditmenu.h"
|
||||
#include "drivenum.h"
|
||||
|
||||
extern const char UI_VERSION_TAG[];
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "ui/filesel.h"
|
||||
#include "ui/swlist.h"
|
||||
#include "zippath.h"
|
||||
#include "drivenum.h"
|
||||
#include "audit.h"
|
||||
#include "softlist.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 {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "ui/icorender.h"
|
||||
#include "ui/toolbar.h"
|
||||
#include "ui/miscmenu.h"
|
||||
#include "drivenum.h"
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "mame.h"
|
||||
#include "osdnet.h"
|
||||
#include "mameopts.h"
|
||||
#include "drivenum.h"
|
||||
|
||||
#include "uiinput.h"
|
||||
#include "ui/ui.h"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "ui/inputmap.h"
|
||||
#include "ui/miscmenu.h"
|
||||
#include "ui/optsmenu.h"
|
||||
#include "drivenum.h"
|
||||
#include "audit.h"
|
||||
#include <ctype.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);
|
||||
|
@ -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);
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user