Revert software-installed slot/image options when changing software

- Remove emu.h's stealth include of emuopts.h through mconfig.h; reduce dependency on emuopts.h in other headers and source files.
- MCFG_CPU_FORCE_NO_DRC is now a CPU configuration parameter rather than a global one; it still works to override the -drc option setting.
This commit is contained in:
AJR 2016-04-04 23:46:44 -04:00
parent 1046be89db
commit ee12b7d2f7
49 changed files with 106 additions and 78 deletions

View File

@ -7,7 +7,6 @@
***************************************************************************/
#include "emu.h"
#include "emuopts.h"
#include "a1bus.h"

View File

@ -71,7 +71,6 @@
***************************************************************************/
#include "emu.h"
#include "emuopts.h"
#include "a2bus.h"

View File

@ -9,7 +9,6 @@
***************************************************************************/
#include "emu.h"
#include "emuopts.h"
#include "a2eauxslot.h"

View File

@ -43,7 +43,6 @@
***************************************************************************/
#include "emu.h"
#include "emuopts.h"
#include "bml3bus.h"

View File

@ -10,7 +10,6 @@
#include "emu.h"
#include "cococart.h"
#include "emuopts.h"
/***************************************************************************
PARAMETERS

View File

@ -9,7 +9,6 @@
#include "emu.h"
#include "emuopts.h"
#include "cpcexp.h"

View File

@ -8,7 +8,6 @@
#include "emu.h"
#include "iq151.h"
#include "emuopts.h"
#define LOG 0

View File

@ -7,7 +7,6 @@
***************************************************************************/
#include "emu.h"
#include "emuopts.h"
#include "isa.h"

View File

@ -106,7 +106,6 @@
#include "emu.h"
#include "kc.h"
#include "emuopts.h"
#define LOG 0

View File

@ -9,7 +9,6 @@
***************************************************************************/
#include "emu.h"
#include "emuopts.h"
#include "macpds.h"

View File

@ -9,7 +9,6 @@
***************************************************************************/
#include "emu.h"
#include "emuopts.h"
#include "nubus.h"

View File

@ -14,7 +14,6 @@ The following basic program can be useful for identifying scancodes:
#include "emu.h"
#include "emuopts.h"
#include "pc_kbdc.h"

View File

@ -111,6 +111,7 @@
***************************************************************************/
#include "gromport.h"
#include "emuopts.h"
#include "image.h"
#include "softlist.h"

View File

@ -8,7 +8,6 @@
#include "emu.h"
#include "tvc.h"
#include "emuopts.h"
/***************************************************************************

View File

@ -5,7 +5,6 @@
*/
#include "emu.h"
#include "emuopts.h"
#include "x68kexp.h"
//**************************************************************************

View File

@ -10,7 +10,6 @@
#include "emu.h"
#include "z88.h"
#include "emuopts.h"
/***************************************************************************

View File

@ -169,6 +169,7 @@
#include <stddef.h>
#include "emu.h"
#include "debugger.h"
#include "emuopts.h"
#include "drcuml.h"
#include "drcbex64.h"

View File

@ -85,6 +85,7 @@
#include <stddef.h>
#include "emu.h"
#include "debugger.h"
#include "emuopts.h"
#include "drcuml.h"
#include "drcbex86.h"

View File

@ -35,6 +35,7 @@
***************************************************************************/
#include "emu.h"
#include "emuopts.h"
#include "drcuml.h"
#include "drcbec.h"
#include "drcbex86.h"

View File

@ -316,7 +316,7 @@ void mips3_device::check_irqs()
void mips3_device::device_start()
{
m_isdrc = (mconfig().options().drc() && !mconfig().m_force_no_drc) ? true : false;
m_isdrc = allow_drc();
/* allocate the implementation-specific state from the full cache */
m_core = (internal_mips3_state *)m_cache.alloc_near(sizeof(internal_mips3_state));

View File

@ -150,7 +150,7 @@ inline void mips3_device::save_fast_iregs(drcuml_block *block)
void mips3_device::mips3drc_set_options(UINT32 options)
{
if (!(mconfig().options().drc() && !mconfig().m_force_no_drc)) return;
if (!allow_drc()) return;
m_drcoptions = options;
}
@ -196,7 +196,7 @@ void mips3_device::add_fastram(offs_t start, offs_t end, UINT8 readonly, void *b
void mips3_device::mips3drc_add_hotspot(offs_t pc, UINT32 opcode, UINT32 cycles)
{
if (!(mconfig().options().drc() && !mconfig().m_force_no_drc)) return;
if (!allow_drc()) return;
if (m_hotspot_select < ARRAY_LENGTH(m_hotspot))
{
m_hotspot[m_hotspot_select].pc = pc;

View File

@ -361,7 +361,7 @@ void rsp_device::resolve_cb()
void rsp_device::device_start()
{
m_isdrc = (mconfig().options().drc() && !mconfig().m_force_no_drc) ? true : false;
m_isdrc = allow_drc();
m_rsp_state = (internal_rsp_state *)m_cache.alloc_near(sizeof(internal_rsp_state));
if (LOG_INSTRUCTION_EXECUTION)

View File

@ -183,7 +183,7 @@ static void cfunc_write32(void *param)
void rsp_device::rspdrc_set_options(UINT32 options)
{
if (!(mconfig().options().drc() && !mconfig().m_force_no_drc)) return;
if (!allow_drc()) return;
m_drcoptions = options;
}
@ -307,7 +307,7 @@ void rsp_device::execute_run_drc()
void rsp_device::rspdrc_flush_drc_cache()
{
if (!(mconfig().options().drc() && !mconfig().m_force_no_drc)) return;
if (!allow_drc()) return;
m_cache_dirty = TRUE;
}

View File

@ -193,7 +193,7 @@ sh2_device::sh2_device(const machine_config &mconfig, const char *tag, device_t
, m_out_of_cycles(nullptr)
, m_debugger_temp(0)
{
m_isdrc = (mconfig.options().drc() && !mconfig.m_force_no_drc) ? true : false;
m_isdrc = allow_drc();
}
@ -225,7 +225,7 @@ sh2_device::sh2_device(const machine_config &mconfig, device_type type, const ch
, m_nocode(nullptr)
, m_out_of_cycles(nullptr)
{
m_isdrc = (mconfig.options().drc() && !mconfig.m_force_no_drc) ? true : false;
m_isdrc = allow_drc();
}
sh2a_device::sh2a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)

View File

@ -11,7 +11,6 @@
#include "debugger.h"
#include "sh2.h"
#include "sh2comn.h"
#include "mconfig.h"
extern unsigned DasmSH2(char *buffer, unsigned pc, UINT16 opcode);
@ -2946,7 +2945,7 @@ int sh2_device::generate_group_12(drcuml_block *block, compiler_state *compiler,
void sh2_device::sh2drc_set_options(UINT32 options)
{
if (!(mconfig().options().drc() && !mconfig().m_force_no_drc)) return;
if (!allow_drc()) return;
m_drcoptions = options;
}
@ -2958,7 +2957,7 @@ void sh2_device::sh2drc_set_options(UINT32 options)
void sh2_device::sh2drc_add_pcflush(offs_t address)
{
if (!(mconfig().options().drc() && !mconfig().m_force_no_drc)) return;
if (!allow_drc()) return;
if (m_pcfsel < ARRAY_LENGTH(m_pcflushes))
m_pcflushes[m_pcfsel++] = address;

View File

@ -9,6 +9,7 @@
***************************************************************************/
#include "emu.h"
#include "emuopts.h"
#include <ctype.h>
@ -25,7 +26,8 @@ cpu_device::cpu_device(const machine_config &mconfig, device_type type, const ch
device_execute_interface(mconfig, *this),
device_memory_interface(mconfig, *this),
device_state_interface(mconfig, *this),
device_disasm_interface(mconfig, *this)
device_disasm_interface(mconfig, *this),
m_force_no_drc(false)
{
}
@ -37,3 +39,24 @@ cpu_device::cpu_device(const machine_config &mconfig, device_type type, const ch
cpu_device::~cpu_device()
{
}
//-------------------------------------------------
// static_set_force_no_drc - configuration helper
// to disable DRC
//-------------------------------------------------
void cpu_device::static_set_force_no_drc(device_t &device, bool value)
{
downcast<cpu_device &>(device).m_force_no_drc = value;
}
//-------------------------------------------------
// allow_drc - return true if DRC is allowed
//-------------------------------------------------
bool cpu_device::allow_drc() const
{
return mconfig().options().drc() && !m_force_no_drc;
}

View File

@ -42,6 +42,11 @@
#define MCFG_CPU_PERIODIC_INT_REMOVE MCFG_DEVICE_PERIODIC_INT_REMOVE
#define MCFG_CPU_IRQ_ACKNOWLEDGE_REMOVE MCFG_DEVICE_IRQ_ACKNOWLEDGE_REMOVE
// recompilation parameters
#define MCFG_CPU_FORCE_NO_DRC() \
cpu_device::static_set_force_no_drc(*device, true);
//**************************************************************************
// MACROS
@ -66,10 +71,19 @@ class cpu_device : public device_t,
{
friend resource_pool_object<cpu_device>::~resource_pool_object();
public:
// configuration helpers
static void static_set_force_no_drc(device_t &device, bool value);
bool allow_drc() const;
protected:
// construction/destruction
cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
virtual ~cpu_device();
private:
// configured state
bool m_force_no_drc; // whether or not to force DRC off
};

View File

@ -9,6 +9,7 @@
**************************************************************************/
#include "emu.h"
#include "emuopts.h"
#include "render.h"
#include "ui/selgame.h"
#include "ui/simpleselgame.h"

View File

@ -255,24 +255,16 @@ bool emu_options::add_slot_options(const software_part *swpart)
if (slot->fixed())
continue;
// first device? add the header as to be pretty
if (m_slot_options++ == 0)
add_entry(nullptr, "SLOT DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE);
// retrieve info about the device instance
const char *name = slot->device().tag() + 1;
if (!exists(name))
{
// first device? add the header as to be pretty
if (m_slot_options++ == 0)
add_entry(nullptr, "SLOT DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE);
// add the option
UINT32 flags = OPTION_STRING | OPTION_FLAG_DEVICE;
const char *defvalue = slot->default_option();
if (defvalue != nullptr)
{
const device_slot_option *option = slot->option(defvalue);
if (option != nullptr && !option->selectable())
flags |= OPTION_FLAG_INTERNAL;
}
add_entry(name, nullptr, flags, defvalue, true);
add_entry(name, nullptr, OPTION_STRING | OPTION_FLAG_DEVICE, slot->default_option(), true);
}
// allow software lists to supply their own defaults
@ -314,12 +306,21 @@ void emu_options::update_slot_options(const software_part *swpart)
if (exists(name) && !slot->option_list().empty())
{
std::string defvalue = slot->get_default_card_software();
if (defvalue.length() > 0)
if (defvalue.empty())
{
set_default_value(name, defvalue.c_str());
const device_slot_option *option = slot->option(defvalue.c_str());
set_flag(name, ~OPTION_FLAG_INTERNAL, (option != nullptr && !option->selectable()) ? OPTION_FLAG_INTERNAL : 0);
// keep any non-default setting
if (priority(name) > OPTION_PRIORITY_DEFAULT)
continue;
// reinstate the actual default value as configured
if (slot->default_option() != nullptr)
defvalue.assign(slot->default_option());
}
// set the value and hide the option if not selectable
set_default_value(name, defvalue.c_str());
const device_slot_option *option = slot->option(defvalue.c_str());
set_flag(name, ~OPTION_FLAG_INTERNAL, (option != nullptr && !option->selectable()) ? OPTION_FLAG_INTERNAL : 0);
}
}
while (add_slot_options(swpart)) { }
@ -344,10 +345,6 @@ void emu_options::add_device_options()
image_interface_iterator iter(config.root_device());
for (const device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{
// first device? add the header as to be pretty
if (m_device_options++ == 0)
add_entry(nullptr, "IMAGE DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE);
// retrieve info about the device instance
std::ostringstream option_name;
util::stream_format(option_name, "%s;%s", image->instance_name(), image->brief_instance_name());
@ -356,7 +353,14 @@ void emu_options::add_device_options()
// add the option
if (!exists(image->instance_name()))
{
// first device? add the header as to be pretty
if (m_device_options++ == 0)
add_entry(nullptr, "IMAGE DEVICES", OPTION_HEADER | OPTION_FLAG_DEVICE);
// add the option
add_entry(option_name.str().c_str(), nullptr, OPTION_STRING | OPTION_FLAG_DEVICE, nullptr, true);
}
}
}
@ -401,12 +405,10 @@ bool emu_options::parse_slot_devices(int argc, char *argv[], std::string &error_
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
// keep adding slot options until we stop seeing new stuff
m_slot_options = 0;
while (add_slot_options(swpart))
core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);
// add device options and reparse
m_device_options = 0;
add_device_options();
if (name != nullptr && exists(name))
set_value(name, value, OPTION_PRIORITY_SUBCMD, error_string);
@ -560,6 +562,11 @@ void emu_options::set_system_name(const char *name)
// remove any existing device options
remove_device_options();
}
else
{
// revert device options set for the old software
revert(OPTION_PRIORITY_SUBCMD, OPTION_PRIORITY_SUBCMD);
}
// get the new system
const game_driver *cursystem = system();

View File

@ -9,6 +9,7 @@
***************************************************************************/
#include "emu.h"
#include "emuopts.h"
static std::unordered_map<std::string, std::string> g_translation;

View File

@ -16,6 +16,7 @@
#include "emu.h"
#include "cheat.h"
#include "drivenum.h"
#include "emuopts.h"
#include "ui/ui.h"
#include "luaengine.h"
#include <mutex>

View File

@ -25,7 +25,6 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
: m_minimum_quantum(attotime::zero),
m_watchdog_vblank_count(0),
m_watchdog_time(attotime::zero),
m_force_no_drc(false),
m_default_layout(nullptr),
m_gamedrv(gamedrv),
m_options(options)

View File

@ -18,8 +18,6 @@
#ifndef __MCONFIG_H__
#define __MCONFIG_H__
#include "emuopts.h"
//**************************************************************************
// CONSTANTS
//**************************************************************************
@ -72,7 +70,6 @@ public:
std::string m_perfect_cpu_quantum; // tag of CPU to use for "perfect" scheduling
INT32 m_watchdog_vblank_count; // number of VBLANKs until the watchdog kills us
attotime m_watchdog_time; // length of time until the watchdog kills us
bool m_force_no_drc; // whether or not to force DRC off
// other parameters
const internal_layout * m_default_layout; // default layout for this machine
@ -202,10 +199,6 @@ References an external machine config.
#define MCFG_QUANTUM_PERFECT_CPU(_cputag) \
config.m_perfect_cpu_quantum = owner->subtag(_cputag);
// recompilation parameters
#define MCFG_FORCE_NO_DRC() \
config.m_force_no_drc = true;
// watchdog configuration
#define MCFG_WATCHDOG_VBLANK_INIT(_count) \
config.m_watchdog_vblank_count = _count;

View File

@ -174,6 +174,7 @@
#include <map>
#include "emu.h"
#include "emuopts.h"
#include "debug/debugcpu.h"

View File

@ -9,6 +9,7 @@
*********************************************************************/
#include "emu.h"
#include "emuopts.h"
#include "ui/ui.h"
#include "ui/menu.h"
#include "ui/ctrlmenu.h"

View File

@ -9,6 +9,7 @@
***************************************************************************/
#include "emu.h"
#include "emuopts.h"
#include "ui/ui.h"
#include "ui/menu.h"
#include "ui/imgcntrl.h"

View File

@ -9,7 +9,7 @@
*********************************************************************/
#include "emu.h"
#include "emuopts.h"
#include "ui/ui.h"
#include "ui/menu.h"
#include "ui/slotopt.h"

View File

@ -12,6 +12,7 @@
#ifndef __UI_SUBMENU_H__
#define __UI_SUBMENU_H__
#include "emuopts.h"
#include "ui/menu.h"
//-------------------------------------------------

View File

@ -146,13 +146,13 @@ void core_options::entry::set_flag(UINT32 mask, UINT32 flag)
//-------------------------------------------------
// revert - revert back to our default if we are
// at or below the given priority
// within the given priority range
//-------------------------------------------------
void core_options::entry::revert(int priority)
void core_options::entry::revert(int priority_hi, int priority_lo)
{
// if our priority is low enough, revert to the default
if (m_priority <= priority)
// if our priority is within the range, revert to the default
if (m_priority <= priority_hi && m_priority >= priority_lo)
{
m_data = m_defdata;
m_priority = OPTION_PRIORITY_DEFAULT;
@ -465,11 +465,11 @@ bool core_options::parse_ini_file(util::core_file &inifile, int priority, int ig
// priority back to their defaults
//-------------------------------------------------
void core_options::revert(int priority)
void core_options::revert(int priority_hi, int priority_lo)
{
// iterate over options and revert to defaults if below the given priority
for (entry &curentry : m_entrylist)
curentry.revert(priority);
curentry.revert(priority_hi, priority_lo);
}

View File

@ -97,7 +97,7 @@ public:
void set_description(const char *description);
void set_flag(UINT32 mask, UINT32 flag);
void mark_changed() { m_changed = true; }
void revert(int priority);
void revert(int priority_hi, int priority_lo);
private:
// internal state
@ -151,7 +151,7 @@ public:
bool parse_ini_file(util::core_file &inifile, int priority, int ignore_priority, std::string &error_string);
// reverting
void revert(int priority = OPTION_PRIORITY_MAXIMUM);
void revert(int priority_hi = OPTION_PRIORITY_MAXIMUM, int priority_lo = OPTION_PRIORITY_DEFAULT);
// output
std::string output_ini(const core_options *diff = nullptr) const;

View File

@ -845,6 +845,7 @@ static MACHINE_CONFIG_START( aleck64, aleck64_state )
MCFG_MIPS3_DCACHE_SIZE(8192)
MCFG_MIPS3_SYSTEM_CLOCK(62500000)
MCFG_CPU_PROGRAM_MAP(n64_map)
MCFG_CPU_FORCE_NO_DRC()
MCFG_CPU_ADD("rsp", RSP, 62500000)
MCFG_RSP_DP_REG_R_CB(DEVREAD32("rcp",n64_periphs, dp_reg_r))
@ -853,6 +854,7 @@ static MACHINE_CONFIG_START( aleck64, aleck64_state )
MCFG_RSP_SP_REG_W_CB(DEVWRITE32("rcp",n64_periphs, sp_reg_w))
MCFG_RSP_SP_SET_STATUS_CB(DEVWRITE32("rcp",n64_periphs, sp_set_status))
MCFG_CPU_PROGRAM_MAP(rsp_map)
MCFG_CPU_FORCE_NO_DRC()
MCFG_SCREEN_ADD("screen", RASTER)
MCFG_SCREEN_REFRESH_RATE(60)
@ -872,8 +874,6 @@ static MACHINE_CONFIG_START( aleck64, aleck64_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
MCFG_N64_PERIPHS_ADD("rcp");
MCFG_FORCE_NO_DRC()
MACHINE_CONFIG_END
UINT32 aleck64_state::screen_update_e90(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)

View File

@ -339,7 +339,6 @@ Notes:
#include "machine/vt83c461.h"
#include "sound/dac.h"
#include "includes/jaguar.h"
#include "emuopts.h"
#include "imagedev/snapquik.h"
#include "sound/dac.h"
#include "machine/eepromser.h"

View File

@ -418,12 +418,13 @@ static MACHINE_CONFIG_START( n64, n64_mess_state )
/* basic machine hardware */
MCFG_CPU_ADD("maincpu", VR4300BE, 93750000)
MCFG_FORCE_NO_DRC()
MCFG_CPU_FORCE_NO_DRC()
MCFG_CPU_CONFIG(config)
MCFG_CPU_PROGRAM_MAP(n64_map)
MCFG_CPU_VBLANK_INT_DRIVER("screen", n64_mess_state, n64_reset_poll)
MCFG_CPU_ADD("rsp", RSP, 62500000)
MCFG_CPU_FORCE_NO_DRC()
MCFG_RSP_DP_REG_R_CB(DEVREAD32("rcp",n64_periphs, dp_reg_r))
MCFG_RSP_DP_REG_W_CB(DEVWRITE32("rcp",n64_periphs, dp_reg_w))
MCFG_RSP_SP_REG_R_CB(DEVREAD32("rcp",n64_periphs, sp_reg_r))
@ -464,8 +465,6 @@ static MACHINE_CONFIG_START( n64, n64_mess_state )
/* software lists */
MCFG_SOFTWARE_LIST_ADD("cart_list", "n64")
MCFG_FORCE_NO_DRC()
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( n64dd, n64 )

View File

@ -96,7 +96,6 @@
******************************************************************************/
#include "emu.h"
#include "emuopts.h"
#include "cpu/z80/z80.h"
#include "includes/nc.h"
#include "machine/mc146818.h" /* for NC200 real time clock */

View File

@ -19,7 +19,6 @@
/* Core includes */
#include "emu.h"
#include "emuopts.h"
#include "sound/speaker.h"
/* Components */

View File

@ -51,6 +51,8 @@ Notes:
JP8 - Jumper, set to 1-2 (selects CLOCK SOURCE)
*/
#include "emu.h"
#include "emuopts.h"
#include "machine/m1comm.h"
#define Z80_TAG "m1commcpu"

View File

@ -7,7 +7,6 @@
#define __M1COMM_SIMULATION__
#include "emu.h"
#include "cpu/z80/z80.h"
#define MCFG_M1COMM_ADD(_tag ) \

View File

@ -66,6 +66,8 @@ Sega System Multi32 Comm PCB 837-8792-91
15033.17 OutRunners, Stadium Cross
*/
#include "emu.h"
#include "emuopts.h"
#include "machine/s32comm.h"
//#define __S32COMM_VERBOSE__

View File

@ -7,8 +7,6 @@
#define __S32COMM_SIMULATION__
#include "emu.h"
#define MCFG_S32COMM_ADD(_tag ) \
MCFG_DEVICE_ADD(_tag, S32COMM, 0)