summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2019-12-13 20:08:31 +1100
committer Vas Crabb <vas@vastheman.com>2019-12-13 20:08:31 +1100
commit6f5d2ad3268b28eab6f1984b03a914f9312ca9c4 (patch)
tree396215cbfa51db7290412e49d2db99ee4a8b5859
parenta02617900c256c047ca651f13fd9ee1c98c22c78 (diff)
Save states should not be break when changing output. Also get rid of a few dozen output().set_value(...) calls in favour of output finders. (nw)
This has the detrimental effect that outputs used in layouts will get the default value from the last element in the last view that uses them _after_ devices are started. If drivers/devices set initial output values on start rather than reset this could cause a problem.
-rw-r--r--src/emu/machine.cpp4
-rw-r--r--src/emu/output.cpp26
-rw-r--r--src/emu/rendlay.cpp13
-rw-r--r--src/mame/drivers/guab.cpp110
-rw-r--r--src/mame/drivers/intellec4.cpp53
-rw-r--r--src/mame/drivers/midxunit.cpp1
-rw-r--r--src/mame/drivers/mmd1.cpp71
-rw-r--r--src/mame/includes/midxunit.h6
-rw-r--r--src/mame/machine/midxunit.cpp22
9 files changed, 181 insertions, 125 deletions
diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp
index dbb34fc3a31..e6ef063a0ac 100644
--- a/src/emu/machine.cpp
+++ b/src/emu/machine.cpp
@@ -249,8 +249,6 @@ void running_machine::start()
m_debugger = std::make_unique<debugger_manager>(*this);
}
- m_render->resolve_tags();
-
manager().create_custom(*this);
// resolve objects that are created by memory maps
@@ -267,6 +265,8 @@ void running_machine::start()
// save outputs created before start time
output().register_save();
+ m_render->resolve_tags();
+
// load cheat files
manager().load_cheatfiles(*this);
diff --git a/src/emu/output.cpp b/src/emu/output.cpp
index 44130c80768..d9e6b1a0198 100644
--- a/src/emu/output.cpp
+++ b/src/emu/output.cpp
@@ -15,7 +15,7 @@
#include <algorithm>
-#define OUTPUT_VERBOSE 0
+#define OUTPUT_VERBOSE 0
@@ -107,6 +107,9 @@ void output_manager::register_save()
// register the reserved space for saving
machine().save().save_pointer(nullptr, "output", nullptr, 0, NAME(m_save_data), m_itemtable.size());
+ if (OUTPUT_VERBOSE)
+ osd_printf_verbose("Registered %u outputs for save states\n", m_itemtable.size());
+
}
@@ -114,7 +117,7 @@ void output_manager::register_save()
find_item - find an item based on a string
-------------------------------------------------*/
-output_manager::output_item* output_manager::find_item(const char *string)
+output_manager::output_item *output_manager::find_item(char const *string)
{
auto item = m_itemtable.find(std::string(string));
if (item != m_itemtable.end())
@@ -128,8 +131,11 @@ output_manager::output_item* output_manager::find_item(const char *string)
create_new_item - create a new item
-------------------------------------------------*/
-output_manager::output_item &output_manager::create_new_item(const char *outname, s32 value)
+output_manager::output_item &output_manager::create_new_item(char const *outname, s32 value)
{
+ if (OUTPUT_VERBOSE)
+ osd_printf_verbose("Creating output %s = %d%s\n", outname, value, m_save_data ? " (will not be saved)" : "");
+
auto const ins(m_itemtable.emplace(
std::piecewise_construct,
std::forward_as_tuple(outname),
@@ -138,7 +144,7 @@ output_manager::output_item &output_manager::create_new_item(const char *outname
return ins.first->second;
}
-output_manager::output_item &output_manager::find_or_create_item(const char *outname, s32 value)
+output_manager::output_item &output_manager::find_or_create_item(char const *outname, s32 value)
{
output_item *const item = find_item(outname);
return item ? *item : create_new_item(outname, value);
@@ -186,7 +192,7 @@ void output_manager::postload()
output_set_value - set the value of an output
-------------------------------------------------*/
-void output_manager::set_value(const char *outname, s32 value)
+void output_manager::set_value(char const *outname, s32 value)
{
output_item *const item = find_item(outname);
@@ -203,7 +209,7 @@ void output_manager::set_value(const char *outname, s32 value)
output
-------------------------------------------------*/
-s32 output_manager::get_value(const char *outname)
+s32 output_manager::get_value(char const *outname)
{
output_item const *const item = find_item(outname);
@@ -218,7 +224,7 @@ s32 output_manager::get_value(const char *outname)
if nullptr is specified
-------------------------------------------------*/
-void output_manager::set_notifier(const char *outname, notifier_func callback, void *param)
+void output_manager::set_notifier(char const *outname, notifier_func callback, void *param)
{
// if an item is specified, find/create it
if (outname)
@@ -238,7 +244,7 @@ void output_manager::set_notifier(const char *outname, notifier_func callback, v
a given name
-------------------------------------------------*/
-u32 output_manager::name_to_id(const char *outname)
+u32 output_manager::name_to_id(char const *outname)
{
// if no item, ID is 0
output_item const *const item = find_item(outname);
@@ -251,12 +257,12 @@ u32 output_manager::name_to_id(const char *outname)
to a given unique ID
-------------------------------------------------*/
-const char *output_manager::id_to_name(u32 id)
+char const *output_manager::id_to_name(u32 id)
{
for (auto &item : m_itemtable)
if (item.second.id() == id)
return item.second.name().c_str();
- /* nothing found, return nullptr */
+ // nothing found, return nullptr
return nullptr;
}
diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp
index 3df68232710..f13d8aff77b 100644
--- a/src/emu/rendlay.cpp
+++ b/src/emu/rendlay.cpp
@@ -3315,18 +3315,12 @@ layout_view::item::item(
, m_color(render_color_multiply(env.parse_color(itemnode.get_child("color")), color))
, m_blend_mode(get_blend_mode(env, itemnode))
{
- // outputs need resolving
- if (m_have_output)
- m_output.resolve();
-
// fetch common data
int index = env.get_attribute_int(itemnode, "index", -1);
if (index != -1)
m_screen = screen_device_iterator(env.machine().root_device()).byindex(index);
for (u32 mask = m_input_mask; (mask != 0) && (~mask & 1); mask >>= 1)
m_input_shift++;
- if (m_have_output && m_element)
- m_output = m_element->default_state();
// sanity checks
if (strcmp(itemnode.get_name(), "screen") == 0)
@@ -3411,6 +3405,13 @@ int layout_view::item::state() const
void layout_view::item::resolve_tags()
{
+ if (m_have_output)
+ {
+ m_output.resolve();
+ if (m_element)
+ m_output = m_element->default_state();
+ }
+
if (!m_input_tag.empty())
{
m_input_port = m_element->machine().root_device().ioport(m_input_tag.c_str());
diff --git a/src/mame/drivers/guab.cpp b/src/mame/drivers/guab.cpp
index 928d34ed4ee..76cafe36e3d 100644
--- a/src/mame/drivers/guab.cpp
+++ b/src/mame/drivers/guab.cpp
@@ -80,13 +80,18 @@ public:
m_fdc(*this, "fdc"),
m_floppy(*this, "fdc:0"),
m_palette(*this, "palette"),
- m_sound_buffer(0), m_sound_latch(false)
+ m_leds(*this, "led_%u", 0U),
+ m_sound_buffer(0),
+ m_sound_latch(false)
{ }
void guab(machine_config &config);
DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
+protected:
+ virtual void machine_start() override;
+
private:
EF9369_COLOR_UPDATE(ef9369_color_update);
DECLARE_WRITE16_MEMBER(tms34061_w);
@@ -110,9 +115,6 @@ private:
void guab_map(address_map &map);
- virtual void machine_start() override;
-
-
required_device<cpu_device> m_maincpu;
required_device<tms34061_device> m_tms34061;
required_device<sn76489_device> m_sn;
@@ -120,6 +122,8 @@ private:
required_device<floppy_connector> m_floppy;
required_device<palette_device> m_palette;
+ output_finder<48> m_leds;
+
uint8_t m_sound_buffer;
bool m_sound_latch;
};
@@ -304,6 +308,8 @@ uint32_t guab_state::screen_update_guab(screen_device &screen, bitmap_ind16 &bit
void guab_state::machine_start()
{
+ m_leds.resolve();
+
m_fdc->set_floppy(m_floppy->get_device());
}
@@ -359,74 +365,74 @@ INPUT_CHANGED_MEMBER( guab_state::coin_inserted )
WRITE8_MEMBER( guab_state::output1_w )
{
- output().set_value("led_0", BIT(data, 0)); // cash in (ten up: cash in)
- output().set_value("led_1", BIT(data, 1)); // cash out (ten up: cash out)
- output().set_value("led_2", BIT(data, 2));
- output().set_value("led_3", BIT(data, 3));
- output().set_value("led_4", BIT(data, 4));
- output().set_value("led_5", BIT(data, 5));
- output().set_value("led_6", BIT(data, 6)); // (ten up: 10p/100p drive)
- output().set_value("led_7", BIT(data, 7));
+ m_leds[0] = BIT(data, 0); // cash in (ten up: cash in)
+ m_leds[1] = BIT(data, 1); // cash out (ten up: cash out)
+ m_leds[2] = BIT(data, 2);
+ m_leds[3] = BIT(data, 3);
+ m_leds[4] = BIT(data, 4);
+ m_leds[5] = BIT(data, 5);
+ m_leds[6] = BIT(data, 6); // (ten up: 10p/100p drive)
+ m_leds[7] = BIT(data, 7);
}
WRITE8_MEMBER( guab_state::output2_w )
{
- output().set_value("led_8", BIT(data, 0));
- output().set_value("led_9", BIT(data, 1));
- output().set_value("led_10", BIT(data, 2)); // start (ten up: start)
- output().set_value("led_11", BIT(data, 3)); // (ten up: feature 6)
- output().set_value("led_12", BIT(data, 4)); // (ten up: feature 11)
- output().set_value("led_13", BIT(data, 5)); // (ten up: feature 13)
- output().set_value("led_14", BIT(data, 6)); // lamp a (ten up: feature 12)
- output().set_value("led_15", BIT(data, 7)); // lamp b (ten up: pass)
+ m_leds[8] = BIT(data, 0);
+ m_leds[9] = BIT(data, 1);
+ m_leds[10] = BIT(data, 2); // start (ten up: start)
+ m_leds[11] = BIT(data, 3); // (ten up: feature 6)
+ m_leds[12] = BIT(data, 4); // (ten up: feature 11)
+ m_leds[13] = BIT(data, 5); // (ten up: feature 13)
+ m_leds[14] = BIT(data, 6); // lamp a (ten up: feature 12)
+ m_leds[15] = BIT(data, 7); // lamp b (ten up: pass)
}
WRITE8_MEMBER( guab_state::output3_w )
{
- output().set_value("led_16", BIT(data, 0)); // select (ten up: collect)
- output().set_value("led_17", BIT(data, 1)); // (ten up: feature 14)
- output().set_value("led_18", BIT(data, 2)); // (ten up: feature 9)
- output().set_value("led_19", BIT(data, 3)); // (ten up: lamp a)
- output().set_value("led_20", BIT(data, 4)); // lamp c (ten up: lamp b)
- output().set_value("led_21", BIT(data, 5)); // lamp d (ten up: lamp c)
- output().set_value("led_22", BIT(data, 6));
- output().set_value("led_23", BIT(data, 7));
+ m_leds[16] = BIT(data, 0); // select (ten up: collect)
+ m_leds[17] = BIT(data, 1); // (ten up: feature 14)
+ m_leds[18] = BIT(data, 2); // (ten up: feature 9)
+ m_leds[19] = BIT(data, 3); // (ten up: lamp a)
+ m_leds[20] = BIT(data, 4); // lamp c (ten up: lamp b)
+ m_leds[21] = BIT(data, 5); // lamp d (ten up: lamp c)
+ m_leds[22] = BIT(data, 6);
+ m_leds[23] = BIT(data, 7);
}
WRITE8_MEMBER( guab_state::output4_w )
{
- output().set_value("led_24", BIT(data, 0)); // feature 1 (ten up: feature 1)
- output().set_value("led_25", BIT(data, 1)); // feature 2 (ten up: feature 10)
- output().set_value("led_26", BIT(data, 2)); // feature 3 (ten up: feature 7)
- output().set_value("led_27", BIT(data, 3)); // feature 4 (ten up: feature 2)
- output().set_value("led_28", BIT(data, 4)); // feature 5 (ten up: feature 8)
- output().set_value("led_29", BIT(data, 5)); // feature 6 (ten up: feature 3)
- output().set_value("led_30", BIT(data, 6)); // feature 7 (ten up: feature 4)
- output().set_value("led_31", BIT(data, 7)); // feature 8 (ten up: feature 5)
+ m_leds[24] = BIT(data, 0); // feature 1 (ten up: feature 1)
+ m_leds[25] = BIT(data, 1); // feature 2 (ten up: feature 10)
+ m_leds[26] = BIT(data, 2); // feature 3 (ten up: feature 7)
+ m_leds[27] = BIT(data, 3); // feature 4 (ten up: feature 2)
+ m_leds[28] = BIT(data, 4); // feature 5 (ten up: feature 8)
+ m_leds[29] = BIT(data, 5); // feature 6 (ten up: feature 3)
+ m_leds[30] = BIT(data, 6); // feature 7 (ten up: feature 4)
+ m_leds[31] = BIT(data, 7); // feature 8 (ten up: feature 5)
}
WRITE8_MEMBER( guab_state::output5_w )
{
- output().set_value("led_32", BIT(data, 0));
- output().set_value("led_33", BIT(data, 1));
- output().set_value("led_34", BIT(data, 2));
- output().set_value("led_35", BIT(data, 3));
- output().set_value("led_36", BIT(data, 4));
- output().set_value("led_37", BIT(data, 5));
- output().set_value("led_38", BIT(data, 6));
- output().set_value("led_39", BIT(data, 7)); // mech lamp (ten up: mech lamp)
+ m_leds[32] = BIT(data, 0);
+ m_leds[33] = BIT(data, 1);
+ m_leds[34] = BIT(data, 2);
+ m_leds[35] = BIT(data, 3);
+ m_leds[36] = BIT(data, 4);
+ m_leds[37] = BIT(data, 5);
+ m_leds[38] = BIT(data, 6);
+ m_leds[39] = BIT(data, 7); // mech lamp (ten up: mech lamp)
}
WRITE8_MEMBER( guab_state::output6_w )
{
- output().set_value("led_40", BIT(data, 0));
- output().set_value("led_41", BIT(data, 1));
- output().set_value("led_42", BIT(data, 2));
- output().set_value("led_43", BIT(data, 3));
- output().set_value("led_44", BIT(data, 4)); // 50p drive (ten up: 10p drive)
- output().set_value("led_45", BIT(data, 5)); // 100p drive (ten up: 100p drive)
- output().set_value("led_46", BIT(data, 6));
- output().set_value("led_47", BIT(data, 7));
+ m_leds[40] = BIT(data, 0);
+ m_leds[41] = BIT(data, 1);
+ m_leds[42] = BIT(data, 2);
+ m_leds[43] = BIT(data, 3);
+ m_leds[44] = BIT(data, 4); // 50p drive (ten up: 10p drive)
+ m_leds[45] = BIT(data, 5); // 100p drive (ten up: 100p drive)
+ m_leds[46] = BIT(data, 6);
+ m_leds[47] = BIT(data, 7);
}
static DEVICE_INPUT_DEFAULTS_START( acia_1_rs232_defaults )
diff --git a/src/mame/drivers/intellec4.cpp b/src/mame/drivers/intellec4.cpp
index 8ea1f468107..77d295931c9 100644
--- a/src/mame/drivers/intellec4.cpp
+++ b/src/mame/drivers/intellec4.cpp
@@ -121,6 +121,11 @@ protected:
, m_led_active_bank(*this, "led_active_bank_%u", 0U)
, m_led_execution(*this, "led_execution_x%u_%u", 2U, 0U)
, m_led_last_ptr(*this, "led_last_ptr_x%u_%u", 2U, 0U)
+ , m_led_status_ptr_valid(*this, "led_status_ptr_valid")
+ , m_led_status_search(*this, "led_status_search")
+ , m_led_mode_mon(*this, "led_mode_mon")
+ , m_led_mode_ram(*this, "led_mode_ram")
+ , m_led_mode_prom(*this, "led_mode_prom")
{
}
@@ -199,6 +204,11 @@ private:
output_finder<4> m_led_active_bank;
output_finder<2, 4> m_led_execution;
output_finder<2, 4> m_led_last_ptr;
+ output_finder<> m_led_status_ptr_valid;
+ output_finder<> m_led_status_search;
+ output_finder<> m_led_mode_mon;
+ output_finder<> m_led_mode_ram;
+ output_finder<> m_led_mode_prom;
emu_timer *m_reset_timer = nullptr;
@@ -339,7 +349,7 @@ void intellec4_state::bus_cycle(mcs40_cpu_device_base::phase step, u8 sync, u8 d
break;
case mcs40_cpu_device_base::phase::X3:
if (m_search_complete != m_adr_cmp_latch)
- machine().output().set_value("led_status_search", m_search_complete = m_adr_cmp_latch);
+ m_led_status_search = m_search_complete = m_adr_cmp_latch;
if (!m_search_complete && !m_cma_enable)
{
display_execution(data, 0x0fU);
@@ -347,7 +357,7 @@ void intellec4_state::bus_cycle(mcs40_cpu_device_base::phase step, u8 sync, u8 d
{
display_pointer(data, 0x0fU);
if (!m_panel_reset && !m_pointer_valid)
- machine().output().set_value("led_status_ptr_valid", m_pointer_valid = true);
+ m_led_status_ptr_valid = m_pointer_valid = true;
}
}
if (!m_panel_reset && !m_adr_cmp_latch)
@@ -355,7 +365,7 @@ void intellec4_state::bus_cycle(mcs40_cpu_device_base::phase step, u8 sync, u8 d
if (!m_search_complete && !m_panel_reset && !m_cma_enable && !m_sw_run && (m_latched_addr == m_display_addr))
m_pass_counter = (m_pass_counter + 1U) & 0x0fU;
if (m_adr_cmp_latch && !m_next_inst && !m_search_complete)
- machine().output().set_value("led_status_search", m_search_complete = true);
+ m_led_status_search = m_search_complete = true;
if (!m_cpu_reset && !m_cma_enable && !m_sw_run)
m_panel_reset = false;
break;
@@ -525,10 +535,11 @@ INPUT_CHANGED_MEMBER(intellec4_state::sw_reset_mode)
template <unsigned N> INPUT_CHANGED_MEMBER(intellec4_state::sw_prg_mode)
{
- static constexpr char const *const mode_leds[3] = { "led_mode_mon", "led_mode_ram", "led_mode_prom" };
static constexpr int prg_banks[3] = { BANK_PRG_MON, BANK_PRG_RAM, BANK_PRG_PROM };
static constexpr int io_banks[3] = { BANK_IO_MON, BANK_IO_NEITHER, BANK_IO_PROM };
+ std::tuple<output_finder<> &, output_finder<> &, output_finder<> &> mode_leds(m_led_mode_mon, m_led_mode_ram, m_led_mode_prom);
+
if (oldval && !newval)
{
if (((0U == N) || !m_sw_prg_mode[0]) && ((1U == N) || !m_sw_prg_mode[1]) && ((2U == N) || !m_sw_prg_mode[2]))
@@ -537,7 +548,7 @@ template <unsigned N> INPUT_CHANGED_MEMBER(intellec4_state::sw_prg_mode)
{
m_program_banks->set_bank(prg_banks[N]);
m_rom_port_banks->set_bank(io_banks[N]);
- machine().output().set_value(mode_leds[N], m_ff_prg_mode[N] = true);
+ std::get<N>(mode_leds) = m_ff_prg_mode[N] = true;
}
trigger_reset();
}
@@ -547,11 +558,11 @@ template <unsigned N> INPUT_CHANGED_MEMBER(intellec4_state::sw_prg_mode)
m_rom_port_banks->set_bank(BANK_IO_NEITHER);
}
if ((0U != N) && m_ff_prg_mode[0])
- machine().output().set_value(mode_leds[0], m_ff_prg_mode[0] = false);
+ std::get<0>(mode_leds) = m_ff_prg_mode[0] = false;
if ((1U != N) && m_ff_prg_mode[1])
- machine().output().set_value(mode_leds[1], m_ff_prg_mode[1] = false);
+ std::get<1>(mode_leds) = m_ff_prg_mode[1] = false;
if ((2U != N) && m_ff_prg_mode[2])
- machine().output().set_value(mode_leds[2], m_ff_prg_mode[2] = false);
+ std::get<2>(mode_leds) = m_ff_prg_mode[2] = false;
}
m_sw_prg_mode[N] = !bool(newval);
}
@@ -635,6 +646,11 @@ void intellec4_state::driver_start()
m_led_active_bank.resolve();
m_led_execution.resolve();
m_led_last_ptr.resolve();
+ m_led_status_ptr_valid.resolve();
+ m_led_status_search.resolve();
+ m_led_mode_mon.resolve();
+ m_led_mode_ram.resolve();
+ m_led_mode_prom.resolve();
save_item(NAME(m_ram_page));
save_item(NAME(m_ram_data));
@@ -714,11 +730,11 @@ void intellec4_state::driver_reset()
m_prom_programmer->prgm_prom_pwr(BIT(sw_prom_prgm, BIT_SW_PRGM_PWR));
// set front panel LEDs
- machine().output().set_value("led_status_ptr_valid", m_pointer_valid);
- machine().output().set_value("led_status_search", m_search_complete);
- machine().output().set_value("led_mode_mon", m_ff_prg_mode[0]);
- machine().output().set_value("led_mode_ram", m_ff_prg_mode[1]);
- machine().output().set_value("led_mode_prom", m_ff_prg_mode[2]);
+ m_led_status_ptr_valid = m_pointer_valid;
+ m_led_status_search = m_search_complete;
+ m_led_mode_mon = m_ff_prg_mode[0];
+ m_led_mode_ram = m_ff_prg_mode[1];
+ m_led_mode_prom = m_ff_prg_mode[2];
}
@@ -1001,9 +1017,9 @@ void intellec4_state::reset_panel()
m_panel_reset = true;
m_adr_cmp_latch = false;
if (m_search_complete && !m_next_inst)
- machine().output().set_value("led_status_search", m_search_complete = false);
+ m_led_status_search = m_search_complete = false;
if (m_pointer_valid)
- machine().output().set_value("led_status_ptr_valid", m_pointer_valid = false);
+ m_led_status_ptr_valid = m_pointer_valid = false;
}
}
@@ -1018,6 +1034,7 @@ class mod4_state : public intellec4_state
public:
mod4_state(machine_config const &mconfig, device_type type, char const *tag)
: intellec4_state(mconfig, type, tag)
+ , m_led_status_cpu(*this, "led_status_cpu")
{
}
@@ -1043,6 +1060,8 @@ private:
TIMER_CALLBACK_MEMBER(one_shot_expired);
+ output_finder<> m_led_status_cpu;
+
emu_timer *m_one_shot_timer = nullptr;
// control board state
@@ -1150,6 +1169,8 @@ void mod4_state::driver_start()
{
intellec4_state::driver_start();
+ m_led_status_cpu.resolve();
+
m_one_shot_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mod4_state::one_shot_expired), this));
save_item(NAME(m_one_shot));
@@ -1176,7 +1197,7 @@ void mod4_state::driver_reset()
m_bus->test_in((m_one_shot || m_sw_hold) ? 0 : 1);
// set front panel LEDs
- machine().output().set_value("led_status_cpu", true); // actually driven by clock phase 2 - let's assume it's always running
+ m_led_status_cpu = true; // actually driven by clock phase 2 - let's assume it's always running
}
diff --git a/src/mame/drivers/midxunit.cpp b/src/mame/drivers/midxunit.cpp
index 466d50cfcdc..deb0bed4c25 100644
--- a/src/mame/drivers/midxunit.cpp
+++ b/src/mame/drivers/midxunit.cpp
@@ -113,7 +113,6 @@ ________________________________________________________________
**************************************************************************/
#include "emu.h"
-#include "includes/midtunit.h"
#include "includes/midxunit.h"
#include "audio/dcs.h"
diff --git a/src/mame/drivers/mmd1.cpp b/src/mame/drivers/mmd1.cpp
index 0f1dc9850e5..72516511c82 100644
--- a/src/mame/drivers/mmd1.cpp
+++ b/src/mame/drivers/mmd1.cpp
@@ -91,12 +91,17 @@ public:
, m_cass(*this, "cassette")
, m_uart(*this, "uart")
, m_digits(*this, "digit%u", 0U)
- { }
+ , m_p(*this, "p%u_%u", 0U, 0U)
+ { }
void mmd1(machine_config &config);
DECLARE_INPUT_CHANGED_MEMBER(reset_button);
+protected:
+ virtual void machine_start() override;
+ virtual void machine_reset() override;
+
private:
DECLARE_WRITE8_MEMBER(port00_w);
DECLARE_WRITE8_MEMBER(port01_w);
@@ -107,54 +112,56 @@ private:
DECLARE_WRITE_LINE_MEMBER(so);
TIMER_DEVICE_CALLBACK_MEMBER(kansas_r);
DECLARE_WRITE_LINE_MEMBER(kansas_w);
- u8 m_cass_data[4];
- bool m_cassinbit, m_cassoutbit, m_cassold;
+
void io_map(address_map &map);
void mem_map(address_map &map);
- virtual void machine_reset() override;
+
+ u8 m_cass_data[4];
+ bool m_cassinbit, m_cassoutbit, m_cassold;
uint8_t m_return_code;
- virtual void machine_start() override { m_digits.resolve(); }
+
required_device<i8080_cpu_device> m_maincpu;
required_device<cassette_image_device> m_cass;
required_device<ay31015_device> m_uart;
output_finder<9> m_digits;
+ output_finder<3, 8> m_p;
};
WRITE8_MEMBER( mmd1_state::port00_w )
{
- output().set_value("p0_7", BIT(data,7) ? 0 : 1);
- output().set_value("p0_6", BIT(data,6) ? 0 : 1);
- output().set_value("p0_5", BIT(data,5) ? 0 : 1);
- output().set_value("p0_4", BIT(data,4) ? 0 : 1);
- output().set_value("p0_3", BIT(data,3) ? 0 : 1);
- output().set_value("p0_2", BIT(data,2) ? 0 : 1);
- output().set_value("p0_1", BIT(data,1) ? 0 : 1);
- output().set_value("p0_0", BIT(data,0) ? 0 : 1);
+ m_p[0][7] = BIT(data,7) ? 0 : 1;
+ m_p[0][6] = BIT(data,6) ? 0 : 1;
+ m_p[0][5] = BIT(data,5) ? 0 : 1;
+ m_p[0][4] = BIT(data,4) ? 0 : 1;
+ m_p[0][3] = BIT(data,3) ? 0 : 1;
+ m_p[0][2] = BIT(data,2) ? 0 : 1;
+ m_p[0][1] = BIT(data,1) ? 0 : 1;
+ m_p[0][0] = BIT(data,0) ? 0 : 1;
}
WRITE8_MEMBER( mmd1_state::port01_w )
{
- output().set_value("p1_7", BIT(data,7) ? 0 : 1);
- output().set_value("p1_6", BIT(data,6) ? 0 : 1);
- output().set_value("p1_5", BIT(data,5) ? 0 : 1);
- output().set_value("p1_4", BIT(data,4) ? 0 : 1);
- output().set_value("p1_3", BIT(data,3) ? 0 : 1);
- output().set_value("p1_2", BIT(data,2) ? 0 : 1);
- output().set_value("p1_1", BIT(data,1) ? 0 : 1);
- output().set_value("p1_0", BIT(data,0) ? 0 : 1);
+ m_p[1][7] = BIT(data,7) ? 0 : 1;
+ m_p[1][6] = BIT(data,6) ? 0 : 1;
+ m_p[1][5] = BIT(data,5) ? 0 : 1;
+ m_p[1][4] = BIT(data,4) ? 0 : 1;
+ m_p[1][3] = BIT(data,3) ? 0 : 1;
+ m_p[1][2] = BIT(data,2) ? 0 : 1;
+ m_p[1][1] = BIT(data,1) ? 0 : 1;
+ m_p[1][0] = BIT(data,0) ? 0 : 1;
}
WRITE8_MEMBER( mmd1_state::port02_w )
{
- output().set_value("p2_7", BIT(data,7) ? 0 : 1);
- output().set_value("p2_6", BIT(data,6) ? 0 : 1);
- output().set_value("p2_5", BIT(data,5) ? 0 : 1);
- output().set_value("p2_4", BIT(data,4) ? 0 : 1);
- output().set_value("p2_3", BIT(data,3) ? 0 : 1);
- output().set_value("p2_2", BIT(data,2) ? 0 : 1);
- output().set_value("p2_1", BIT(data,1) ? 0 : 1);
- output().set_value("p2_0", BIT(data,0) ? 0 : 1);
+ m_p[2][7] = BIT(data,7) ? 0 : 1;
+ m_p[2][6] = BIT(data,6) ? 0 : 1;
+ m_p[2][5] = BIT(data,5) ? 0 : 1;
+ m_p[2][4] = BIT(data,4) ? 0 : 1;
+ m_p[2][3] = BIT(data,3) ? 0 : 1;
+ m_p[2][2] = BIT(data,2) ? 0 : 1;
+ m_p[2][1] = BIT(data,1) ? 0 : 1;
+ m_p[2][0] = BIT(data,0) ? 0 : 1;
}
// keyboard has a keydown and a keyup code. Keyup = last keydown + bit 7 set
@@ -306,6 +313,12 @@ INPUT_CHANGED_MEMBER(mmd1_state::reset_button)
m_maincpu->set_input_line(INPUT_LINE_RESET, newval ? ASSERT_LINE : CLEAR_LINE);
}
+void mmd1_state::machine_start()
+{
+ m_digits.resolve();
+ m_p.resolve();
+}
+
void mmd1_state::machine_reset()
{
m_return_code = 0xff;
diff --git a/src/mame/includes/midxunit.h b/src/mame/includes/midxunit.h
index 5a3d7bada8c..9baf2f40484 100644
--- a/src/mame/includes/midxunit.h
+++ b/src/mame/includes/midxunit.h
@@ -10,8 +10,10 @@
#pragma once
+#include "midtunit.h"
#include "machine/midwayic.h"
+
class midxunit_state : public midtunit_state
{
public:
@@ -19,6 +21,8 @@ public:
: midtunit_state(mconfig, type, tag)
, m_nvram(*this, "nvram")
, m_midway_serial_pic(*this, "serial_pic")
+ , m_gun_recoil(*this, "Player%u_Gun_Recoil", 1U)
+ , m_gun_led(*this, "Player%u_Gun_LED", 1U)
{ }
void midxunit(machine_config &config);
@@ -48,6 +52,8 @@ private:
required_shared_ptr<uint16_t> m_nvram;
required_device<midway_serial_pic_device> m_midway_serial_pic;
+ output_finder<3> m_gun_recoil;
+ output_finder<3> m_gun_led;
uint8_t m_cmos_write_enable;
uint16_t m_iodata[8];
diff --git a/src/mame/machine/midxunit.cpp b/src/mame/machine/midxunit.cpp
index 9834cfc507a..e6fc58eb496 100644
--- a/src/mame/machine/midxunit.cpp
+++ b/src/mame/machine/midxunit.cpp
@@ -22,6 +22,7 @@
#define VERBOSE (0)
#include "logmacro.h"
+
/*************************************
*
* CMOS reads/writes
@@ -62,15 +63,15 @@ WRITE16_MEMBER(midxunit_state::midxunit_io_w)
break;
default:
- /* Gun Outputs for RevX */
- /* Note: The Gun for the Coin slot you use is supposed to rumble when you insert coins, and it doesn't for P3. */
- /* Perhaps an Input is hooked up wrong. */
- output().set_value("Player1_Gun_Recoil", data & 0x1 );
- output().set_value("Player2_Gun_Recoil", (data & 0x2) >> 1 );
- output().set_value("Player3_Gun_Recoil", (data & 0x4) >> 2 );
- output().set_value("Player1_Gun_LED", (~data & 0x10) >> 4 );
- output().set_value("Player2_Gun_LED", (~data & 0x20) >> 5 );
- output().set_value("Player3_Gun_LED", (~data & 0x40) >> 6 );
+ // Gun Outputs for RevX
+ // Note: The Gun for the Coin slot you use is supposed to rumble when you insert coins, and it doesn't for P3.
+ // Perhaps an Input is hooked up wrong.
+ m_gun_recoil[0] = BIT(data, 0);
+ m_gun_recoil[1] = BIT(data, 1);
+ m_gun_recoil[2] = BIT(data, 2);
+ m_gun_led[0] = BIT(~data, 4);
+ m_gun_led[1] = BIT(~data, 5);
+ m_gun_led[2] = BIT(~data, 6);
LOGMASKED(LOG_IO, "%s: I/O write to %d = %04X\n", machine().describe_context(), offset, data);
break;
@@ -249,6 +250,9 @@ WRITE16_MEMBER(midxunit_state::midxunit_uart_w)
void midxunit_state::machine_start()
{
+ m_gun_recoil.resolve();
+ m_gun_led.resolve();
+
save_item(NAME(m_cmos_write_enable));
save_item(NAME(m_iodata));
save_item(NAME(m_ioshuffle));