diff options
author | 2016-03-02 21:49:49 +0100 | |
---|---|---|
committer | 2016-03-02 21:49:49 +0100 | |
commit | 9fe9f6d93e672bcd926f9e7461774bc9cc22e094 (patch) | |
tree | 3911b611dd010a4108b90fb8b8c82116eec21117 /src/emu/machine.cpp | |
parent | dbdf21ee465acadf3e643d62d6bedfcc297ada85 (diff) | |
parent | 1914702e6fae052668df5b068a502bca57c9a3b0 (diff) |
Merge remote-tracking branch 'refs/remotes/mamedev/master'
# Resolved Conflicts:
# src/osd/modules/render/d3d/d3dhlsl.cpp
# src/osd/windows/winmain.cpp
Diffstat (limited to 'src/emu/machine.cpp')
-rw-r--r-- | src/emu/machine.cpp | 214 |
1 files changed, 73 insertions, 141 deletions
diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index 5119dec397c..70c3f2f1569 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -2,69 +2,69 @@ // copyright-holders:Aaron Giles /*************************************************************************** - machine.c + machine.c - Controls execution of the core MAME system. + 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 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 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 + 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 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 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 ***************************************************************************/ @@ -95,15 +95,6 @@ void js_set_main_loop(running_machine * machine); //************************************************************************** -// GLOBAL VARIABLES -//************************************************************************** - -// a giant string buffer for temporary strings -static char giant_string_buffer[65536] = { 0 }; - - - -//************************************************************************** // RUNNING MACHINE //************************************************************************** @@ -190,7 +181,7 @@ const char *running_machine::describe_context() if (cpu != nullptr) { address_space &prg = cpu->space(AS_PROGRAM); - strprintf(m_context, "'%s' (%s)", cpu->tag(), core_i64_format(cpu->pc(), prg.logaddrchars(), prg.is_octal())); + m_context = string_format(prg.is_octal() ? "'%s' (%0*o)" : "'%s' (%0*X)", cpu->tag(), prg.logaddrchars(), cpu->pc()); } } else @@ -773,69 +764,6 @@ void running_machine::add_logerror_callback(logerror_callback callback) m_logerror_list.push_back(std::make_unique<logerror_callback_item>(callback)); } -/*------------------------------------------------- - popmessage - pop up a user-visible message --------------------------------------------------*/ - -void running_machine::popmessage(const char *format, ...) const -{ - // if the format is NULL, it is a signal to clear the popmessage - if (format == nullptr) - ui().popup_time(0, " "); - - // otherwise, generate the buffer and call the UI to display the message - else - { - std::string temp; - va_list arg; - - // dump to the buffer - va_start(arg, format); - strvprintf(temp,format, arg); - va_end(arg); - - // pop it in the UI - ui().popup_time(temp.length() / 40 + 2, "%s", temp.c_str()); - } -} - - -/*------------------------------------------------- - logerror - log to the debugger and any other - OSD-defined output streams --------------------------------------------------*/ - -void running_machine::logerror(const char *format, ...) const -{ - va_list arg; - va_start(arg, format); - vlogerror(format, arg); - va_end(arg); -} - - -//------------------------------------------------- -// vlogerror - vprintf-style error logging -//------------------------------------------------- - -void running_machine::vlogerror(const char *format, va_list args) const -{ - // process only if there is a target - if (!m_logerror_list.empty()) - { - g_profiler.start(PROFILER_LOGERROR); - - // dump to the buffer - vsnprintf(giant_string_buffer, ARRAY_LENGTH(giant_string_buffer), format, args); - - // log to all callbacks - for (auto& cb : m_logerror_list) - (cb->m_func)(*this, giant_string_buffer); - - g_profiler.stop(); - } -} - //------------------------------------------------- // base_datetime - retrieve the time of the host @@ -1081,7 +1009,10 @@ void running_machine::watchdog_vblank(screen_device &screen, bool vblank_state) void running_machine::logfile_callback(const running_machine &machine, const char *buffer) { if (machine.m_logfile != nullptr) + { machine.m_logfile->puts(buffer); + machine.m_logfile->flush(); + } } @@ -1199,9 +1130,10 @@ void running_machine::postload_all_devices() std::string running_machine::nvram_filename(device_t &device) const { // start with either basename or basename_biosnum - std::string result(basename()); + std::ostringstream result; + result << basename(); if (root_device().system_bios() != 0 && root_device().default_bios() != root_device().system_bios()) - strcatprintf(result, "_%d", root_device().system_bios() - 1); + util::stream_format(result, "_%d", root_device().system_bios() - 1); // device-based NVRAM gets its own name in a subdirectory if (device.owner() != nullptr) @@ -1218,14 +1150,14 @@ std::string running_machine::nvram_filename(device_t &device) const } } if (software != nullptr && *software != '\0') - result.append(PATH_SEPARATOR).append(software); + result << PATH_SEPARATOR << software; std::string tag(device.tag()); tag.erase(0, 1); strreplacechr(tag,':', '_'); - result.append(PATH_SEPARATOR).append(tag); + result << PATH_SEPARATOR << tag; } - return result; + return result.str(); } /*------------------------------------------------- @@ -1326,12 +1258,12 @@ void system_time::full_time::set(struct tm &t) { second = t.tm_sec; minute = t.tm_min; - hour = t.tm_hour; - mday = t.tm_mday; + hour = t.tm_hour; + mday = t.tm_mday; month = t.tm_mon; - year = t.tm_year + 1900; + year = t.tm_year + 1900; weekday = t.tm_wday; - day = t.tm_yday; + day = t.tm_yday; is_dst = t.tm_isdst; } |