summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Vas Crabb <cuavas@users.noreply.github.com>2017-01-04 14:10:24 +1100
committer GitHub <noreply@github.com>2017-01-04 14:10:24 +1100
commit4714d165b31f124a676b6b7b79acfc9505da0bdf (patch)
treee95f0ae416ef1a253fd7091bcd736513bb9beee2 /src
parent54fd9a9627f82bb12d4cc8c192fc5cf9107a9f98 (diff)
parent39f56a0df7243cdca0f5cc5c2544182166f603c7 (diff)
Merge pull request #1914 from ajrhacker/service_mode_sw
Service mode DIP switch adjustments
Diffstat (limited to 'src')
-rw-r--r--src/emu/ioport.cpp27
-rw-r--r--src/emu/ioport.h2
-rw-r--r--src/frontend/mame/ui/info.cpp3
-rw-r--r--src/frontend/mame/ui/info.h2
-rw-r--r--src/frontend/mame/ui/ui.cpp10
5 files changed, 37 insertions, 7 deletions
diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp
index 6f751a28dad..4d106912d7b 100644
--- a/src/emu/ioport.cpp
+++ b/src/emu/ioport.cpp
@@ -634,6 +634,8 @@ ioport_field::ioport_field(ioport_port &port, ioport_type type, ioport_value def
if (device().subtag(def->tag) == fulltag && def->mask == m_mask)
m_defvalue = def->defvalue & m_mask;
}
+
+ m_flags |= FIELD_FLAG_TOGGLE;
}
}
@@ -707,6 +709,24 @@ const input_seq &ioport_field::defseq(input_seq_type seqtype) const
//-------------------------------------------------
+// set_defseq - dynamically alter the default
+// input sequence for the given input field
+//-------------------------------------------------
+
+void ioport_field::set_defseq(input_seq_type seqtype, const input_seq &newseq)
+{
+ const bool was_changed = seq(seqtype) != defseq(seqtype);
+
+ // set the new sequence
+ m_seq[seqtype] = newseq;
+
+ // also update live state unless previously customized
+ if (m_live != nullptr && !was_changed)
+ m_live->seq[seqtype] = newseq;
+}
+
+
+//-------------------------------------------------
// type_class - return the type class for this
// field
//-------------------------------------------------
@@ -3112,13 +3132,6 @@ ioport_configurer& ioport_configurer::onoff_alloc(const char *name, ioport_value
// allocate a field normally
field_alloc(IPT_DIPSWITCH, defval, mask, name);
- // special case service mode
- if (name == DEF_STR(Service_Mode))
- {
- field_set_toggle();
- m_curfield->m_seq[SEQ_TYPE_STANDARD].set(KEYCODE_F2);
- }
-
// expand the diplocation
if (diplocation != nullptr)
field_set_diplocation(diplocation);
diff --git a/src/emu/ioport.h b/src/emu/ioport.h
index a9a4d49b0c4..a5169e08c21 100644
--- a/src/emu/ioport.h
+++ b/src/emu/ioport.h
@@ -1058,6 +1058,8 @@ public:
const input_seq &seq(input_seq_type seqtype = SEQ_TYPE_STANDARD) const;
const input_seq &defseq(input_seq_type seqtype = SEQ_TYPE_STANDARD) const;
const input_seq &defseq_unresolved(input_seq_type seqtype = SEQ_TYPE_STANDARD) const { return m_seq[seqtype]; }
+ void set_defseq(const input_seq &newseq) { set_defseq(SEQ_TYPE_STANDARD, newseq); }
+ void set_defseq(input_seq_type seqtype, const input_seq &newseq);
bool has_dynamic_read() const { return !m_read.isnull(); }
bool has_dynamic_write() const { return !m_write.isnull(); }
diff --git a/src/frontend/mame/ui/info.cpp b/src/frontend/mame/ui/info.cpp
index 9de81cef6ec..18a2039e5d4 100644
--- a/src/frontend/mame/ui/info.cpp
+++ b/src/frontend/mame/ui/info.cpp
@@ -30,6 +30,7 @@ machine_info::machine_info(running_machine &machine)
m_has_dips = false;
m_has_bioses = false;
m_has_keyboard = false;
+ m_has_test_switch = false;
// scan the input port array to see what options we need to enable
for (auto &port : machine.ioport().ports())
@@ -43,6 +44,8 @@ machine_info::machine_info(running_machine &machine)
m_has_analog = true;
if (field.type() == IPT_KEYBOARD)
m_has_keyboard = true;
+ if (field.type() == IPT_SERVICE)
+ m_has_test_switch = true;
}
for (device_t &device : device_iterator(machine.root_device()))
diff --git a/src/frontend/mame/ui/info.h b/src/frontend/mame/ui/info.h
index 21d920e4131..b718c2acf64 100644
--- a/src/frontend/mame/ui/info.h
+++ b/src/frontend/mame/ui/info.h
@@ -29,6 +29,7 @@ public:
bool has_dips() const { return m_has_dips; }
bool has_bioses() const { return m_has_bioses; }
bool has_keyboard() const { return m_has_keyboard; }
+ bool has_test_switch() const { return m_has_test_switch; }
// text generators
std::string warnings_string();
@@ -46,6 +47,7 @@ private:
bool m_has_dips;
bool m_has_bioses;
bool m_has_keyboard;
+ bool m_has_test_switch;
};
class menu_game_info : public menu
diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp
index d7bf97a6562..bda9bdcf3be 100644
--- a/src/frontend/mame/ui/ui.cpp
+++ b/src/frontend/mame/ui/ui.cpp
@@ -256,6 +256,16 @@ void mame_ui_manager::initialize(running_machine &machine)
{
slider_current = nullptr;
}
+
+ // if no test switch found, assign its input sequence to a service mode DIP
+ if (!m_machine_info->has_test_switch() && m_machine_info->has_dips())
+ {
+ const char *const service_mode_dipname = ioport_configurer::string_from_token(DEF_STR(Service_Mode));
+ for (auto &port : machine.ioport().ports())
+ for (ioport_field &field : port.second->fields())
+ if (field.type() == IPT_DIPSWITCH && strcmp(field.name(), service_mode_dipname) == 0)
+ field.set_defseq(machine.ioport().type_seq(IPT_SERVICE));
+ }
}