Miscellaneous cleanup:

* Got rid of a few more unnecessary uses of simple_list.
* bus/amiga/zorro: Got rid of a pointer member that would make adding
  save state support unnecessarily difficult.
* nichibutsu/cop01.cpp: Remove need to remove devices from machine
  config.
This commit is contained in:
Vas Crabb 2023-02-09 01:47:40 +11:00
parent cb56ff1b58
commit 7245878a94
11 changed files with 126 additions and 136 deletions

View File

@ -2541,16 +2541,12 @@ end
if (BUSES["VME"]~=null) then
files {
MAME_DIR .. "src/devices/bus/vme/tp881v.cpp",
MAME_DIR .. "src/devices/bus/vme/tp881v.h",
MAME_DIR .. "src/devices/bus/vme/vme.cpp",
MAME_DIR .. "src/devices/bus/vme/vme.h",
MAME_DIR .. "src/devices/bus/vme/vme_cp31.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_cp31.h",
MAME_DIR .. "src/devices/bus/vme/vme_mzr8300.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_mzr8300.h",
MAME_DIR .. "src/devices/bus/vme/vme_mvme120.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_mvme120.h",
MAME_DIR .. "src/devices/bus/vme/vme_mvme350.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_mvme350.h",
MAME_DIR .. "src/devices/bus/vme/vme_fccpu20.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_fccpu20.h",
MAME_DIR .. "src/devices/bus/vme/vme_fcisio.cpp",
@ -2559,16 +2555,20 @@ if (BUSES["VME"]~=null) then
MAME_DIR .. "src/devices/bus/vme/vme_fcscsi.h",
MAME_DIR .. "src/devices/bus/vme/vme_hcpu30.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_hcpu30.h",
MAME_DIR .. "src/devices/bus/vme/vme_smvme2000.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_smvme2000.h",
MAME_DIR .. "src/devices/bus/vme/vme_mvme120.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_mvme120.h",
MAME_DIR .. "src/devices/bus/vme/vme_mvme180.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_mvme180.h",
MAME_DIR .. "src/devices/bus/vme/vme_mvme181.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_mvme181.h",
MAME_DIR .. "src/devices/bus/vme/vme_mvme327a.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_mvme327a.h",
MAME_DIR .. "src/devices/bus/vme/tp881v.cpp",
MAME_DIR .. "src/devices/bus/vme/tp881v.h",
MAME_DIR .. "src/devices/bus/vme/vme_mvme350.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_mvme350.h",
MAME_DIR .. "src/devices/bus/vme/vme_mzr8300.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_mzr8300.h",
MAME_DIR .. "src/devices/bus/vme/vme_smvme2000.cpp",
MAME_DIR .. "src/devices/bus/vme/vme_smvme2000.h",
}
end

View File

@ -196,7 +196,7 @@ zorro2_bus_device::zorro2_bus_device(const machine_config &mconfig, device_type
m_eint4_handler(*this),
m_eint5_handler(*this),
m_eint7_handler(*this),
m_autoconfig_device(nullptr)
m_autoconfig_device(0)
{
}
@ -206,7 +206,6 @@ zorro2_bus_device::zorro2_bus_device(const machine_config &mconfig, device_type
zorro2_bus_device::~zorro2_bus_device()
{
m_dev.detach_all();
}
//-------------------------------------------------
@ -227,6 +226,17 @@ void zorro2_bus_device::device_resolve_objects()
m_eint7_handler.resolve_safe();
}
//-------------------------------------------------
// device_start - device-specific start
//-------------------------------------------------
void zorro2_bus_device::device_start()
{
zorro_bus_device_base::device_start();
save_item(NAME(m_autoconfig_device));
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
@ -237,11 +247,11 @@ void zorro2_bus_device::device_reset()
zorro_bus_device_base::device_reset();
// initiate autoconfig
m_autoconfig_device = m_dev.first();
m_autoconfig_device = 0;
// if we have a device, start the autoconfig chain
if (m_autoconfig_device)
m_autoconfig_device->cfgin_w(0);
if (m_dev.size() > m_autoconfig_device)
m_dev[m_autoconfig_device].get().cfgin_w(0);
}
//-------------------------------------------------
@ -258,7 +268,7 @@ void zorro2_bus_device::add_card(device_zorro_card_interface &card)
tag(), card.device().tag(), card.device().name());
}
card.set_zorro_bus(*this);
m_dev.append(*zorro2_card);
m_dev.emplace_back(*zorro2_card);
}
// from slot device
@ -269,23 +279,16 @@ WRITE_LINE_MEMBER( zorro2_bus_device::eint7_w ) { m_eint7_handler(state); }
WRITE_LINE_MEMBER( zorro2_bus_device::cfgout_w )
{
m_autoconfig_device = m_autoconfig_device->next();
// if there is still a device in the chain, tell it to configure itself
if (m_autoconfig_device)
m_autoconfig_device->cfgin_w(0);
if (m_dev.size() > ++m_autoconfig_device)
m_dev[m_autoconfig_device].get().cfgin_w(0);
}
// from host
void zorro2_bus_device::fc_w(int code)
{
device_zorro2_card_interface *entry = m_dev.first();
while (entry)
{
entry->fc_w(code);
entry = entry->next();
}
for (device_zorro2_card_interface &entry : m_dev)
entry.fc_w(code);
}
@ -375,7 +378,6 @@ void device_exp_card_interface::interface_pre_start()
device_zorro2_card_interface::device_zorro2_card_interface(const machine_config &mconfig, device_t &device) :
device_zorro_card_interface(mconfig, device),
m_next(nullptr),
m_slot(nullptr)
{
}

View File

@ -143,6 +143,10 @@
#pragma once
#include <functional>
#include <utility>
#include <vector>
//**************************************************************************
// TYPE DEFINITIONS
@ -299,18 +303,21 @@ protected:
// device-level overrides
virtual void device_resolve_objects() override ATTR_COLD;
virtual void device_start() override;
virtual void device_reset() override;
private:
using card_vector = std::vector<std::reference_wrapper<device_zorro2_card_interface> >;
devcb_write_line m_eint1_handler;
devcb_write_line m_eint4_handler;
devcb_write_line m_eint5_handler;
devcb_write_line m_eint7_handler;
simple_list<device_zorro2_card_interface> m_dev;
card_vector m_dev;
// the device which is currently configuring
device_zorro2_card_interface *m_autoconfig_device;
uint8_t m_autoconfig_device;
};
// device type definition
@ -364,9 +371,6 @@ public:
// construction/destruction
virtual ~device_zorro2_card_interface();
device_zorro2_card_interface *next() const { return m_next; }
device_zorro2_card_interface *m_next;
protected:
device_zorro2_card_interface(const machine_config &mconfig, device_t &device);

View File

@ -465,7 +465,7 @@ void isa8_device::nmi()
device_isa8_card_interface::device_isa8_card_interface(const machine_config &mconfig, device_t &device)
: device_interface(device, "isa"),
m_isa(nullptr), m_isa_dev(nullptr), m_next(nullptr)
m_isa(nullptr), m_isa_dev(nullptr)
{
}

View File

@ -250,13 +250,10 @@ DECLARE_DEVICE_TYPE(ISA8, isa8_device)
class device_isa8_card_interface : public device_interface
{
friend class isa8_device;
template <class ElementType> friend class simple_list;
public:
// construction/destruction
virtual ~device_isa8_card_interface();
device_isa8_card_interface *next() const { return m_next; }
void set_isa_device();
// configuration access
virtual uint8_t dack_r(int line);
@ -274,9 +271,6 @@ public:
isa8_device *m_isa;
device_t *m_isa_dev;
private:
device_isa8_card_interface *m_next;
};
class isa16_device;

View File

@ -67,11 +67,15 @@ tanbus_device::tanbus_device(const machine_config &mconfig, const char *tag, dev
{
}
tanbus_device::~tanbus_device()
{
}
void tanbus_device::add_card(device_tanbus_interface *card, int num)
{
card->m_tanbus = this;
card->m_page = num;
m_device_list.append(*card);
m_device_list.emplace_back(*card);
}
//-------------------------------------------------
@ -107,13 +111,8 @@ void tanbus_device::set_inhibit_lines(offs_t offset)
// reset inhibit lines
m_inhram = m_inhrom = 0;
device_tanbus_interface *card = m_device_list.first();
while (card)
{
card->set_inhibit_lines(offset, m_inhram, m_inhrom);
card = card->next();
}
for (device_tanbus_interface &card : m_device_list)
card.set_inhibit_lines(offset, m_inhram, m_inhrom);
}
//-------------------------------------------------
@ -126,19 +125,15 @@ uint8_t tanbus_device::read(offs_t offset)
set_inhibit_lines(offset);
device_tanbus_interface *card = m_device_list.first();
while (card)
for (device_tanbus_interface &card : m_device_list)
{
// set block enable line for current card
if (BIT(m_block_register, 4, 3) == card->m_page)
if (BIT(m_block_register, 4, 3) == card.m_page)
m_block_enable = 1;
else
m_block_enable = 0;
data &= card->read(offset, m_inhrom, m_inhram, m_block_enable);
card = card->next();
data &= card.read(offset, m_inhrom, m_inhram, m_block_enable);
}
return data;
@ -162,18 +157,15 @@ void tanbus_device::write(offs_t offset, uint8_t data)
set_inhibit_lines(offset);
device_tanbus_interface *card = m_device_list.first();
while (card)
for (device_tanbus_interface &card : m_device_list)
{
// set block enable line for current card
if (BIT(m_block_register, 0,3) == card->m_page)
if (BIT(m_block_register, 0,3) == card.m_page)
m_block_enable = 1;
else
m_block_enable = 0;
card->write(offset, data, m_inhrom, m_inhram, m_block_enable);
card = card->next();
card.write(offset, data, m_inhrom, m_inhram, m_block_enable);
}
}
@ -189,7 +181,6 @@ device_tanbus_interface::device_tanbus_interface(const machine_config &mconfig,
: device_interface(device, "tanbus")
, m_tanbus(nullptr)
, m_page(0)
, m_next(nullptr)
{
}

View File

@ -11,6 +11,8 @@
#pragma once
#include <functional>
#include <vector>
//**************************************************************************
@ -66,7 +68,7 @@ class tanbus_device : public device_t
public:
// construction/destruction
tanbus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
~tanbus_device() { m_device_list.detach_all(); }
~tanbus_device();
// inline configuration
auto out_irq_callback() { return m_out_irq_cb.bind(); }
@ -106,7 +108,7 @@ private:
int m_inhram;
int m_block_enable;
simple_list<device_tanbus_interface> m_device_list;
std::vector<std::reference_wrapper<device_tanbus_interface> > m_device_list;
};
@ -118,11 +120,8 @@ DECLARE_DEVICE_TYPE(TANBUS, tanbus_device)
class device_tanbus_interface : public device_interface
{
friend class tanbus_device;
template <class ElementType> friend class simple_list;
public:
device_tanbus_interface *next() const { return m_next; }
// bus access
virtual uint8_t read(offs_t offset, int inhrom, int inhram, int be) { return 0xff; }
virtual void write(offs_t offset, uint8_t data, int inhrom, int inhram, int be) { }
@ -133,9 +132,6 @@ protected:
tanbus_device *m_tanbus;
int m_page;
private:
device_tanbus_interface *m_next;
};

View File

@ -221,7 +221,6 @@ vme_device::vme_device(const machine_config &mconfig, device_type type, const ch
vme_device::~vme_device()
{
LOG("%s %s\n", tag(), FUNCNAME);
m_device_list.detach_all();
}
void vme_device::device_start()
@ -252,7 +251,7 @@ void vme_device::device_reset()
void vme_device::add_vme_card(device_vme_card_interface *card)
{
LOG("%s %s\n", tag(), FUNCNAME);
m_device_list.append(*card);
m_device_list.emplace_back(*card);
}
#if 0
@ -438,7 +437,6 @@ device_vme_card_interface::device_vme_card_interface(const machine_config &mconf
: device_interface(device, "vme")
, m_vme(nullptr)
, m_slot(0)
, m_next(nullptr)
{
m_device = &device;
LOG("%s %s\n", m_device->tag(), FUNCNAME);

View File

@ -50,6 +50,10 @@
#pragma once
#include <functional>
#include <utility>
#include <vector>
//**************************************************************************
// CONSTANTS
@ -190,7 +194,7 @@ protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
simple_list<device_vme_card_interface> m_device_list;
std::vector<std::reference_wrapper<device_vme_card_interface> > m_device_list;
virtual space_config_vector memory_space_config() const override;
@ -202,7 +206,7 @@ protected:
int m_prgwidth;
bool m_allocspaces;
const char *m_cputag;
const char *m_cputag;
};
@ -213,7 +217,6 @@ DECLARE_DEVICE_TYPE(VME_SLOT, vme_slot_device)
class device_vme_card_interface : public device_interface
{
template <class ElementType> friend class simple_list;
public:
// inline configuration
void set_vme_bus(vme_device &vme, int slot) { m_vme = &vme; m_slot = slot; }
@ -233,9 +236,6 @@ protected:
vme_device *m_vme;
int m_slot;
private:
device_vme_card_interface *m_next;
};
#endif // MAME_BUS_VME_VME_H

View File

@ -9,61 +9,63 @@
*/
#include "emu.h"
#include "bus/vme/tp881v.h"
#include "bus/vme/vme_mvme120.h"
#include "bus/vme/vme_mvme180.h"
#include "bus/vme/vme_mvme181.h"
#include "bus/vme/vme_mvme327a.h"
#include "bus/vme/vme_smvme2000.h"
#include "bus/vme/tp881v.h"
#include "logmacro.h"
namespace
namespace {
class sys1121_state : public driver_device
{
class sys1121_state : public driver_device
public:
sys1121_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
{
public:
sys1121_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
{
}
void sys1121(machine_config &config);
};
// Input ports
static INPUT_PORTS_START(sys1121)
INPUT_PORTS_END
static void sys1121_vme_cards(device_slot_interface &device)
{
device.option_add("mvme120", VME_MVME120);
device.option_add("mvme121", VME_MVME121);
device.option_add("mvme122", VME_MVME122);
device.option_add("mvme123", VME_MVME123);
device.option_add("smvme2000", VME_SMVME2000);
device.option_add("mvme180", VME_MVME180);
device.option_add("mvme181", VME_MVME181);
device.option_add("mvme327a", VME_MVME327A);
device.option_add("tp881v", TP881V);
}
void sys1121_state::sys1121(machine_config &config)
{
VME(config, "vme", 0);
VME_SLOT(config, "slot1", sys1121_vme_cards, "mvme120", 1, "vme");
VME_SLOT(config, "slot2", sys1121_vme_cards, nullptr, 2, "vme");
VME_SLOT(config, "slot3", sys1121_vme_cards, nullptr, 3, "vme");
VME_SLOT(config, "slot4", sys1121_vme_cards, nullptr, 4, "vme");
VME_SLOT(config, "slot5", sys1121_vme_cards, nullptr, 5, "vme");
VME_SLOT(config, "slot6", sys1121_vme_cards, nullptr, 6, "vme");
VME_SLOT(config, "slot7", sys1121_vme_cards, nullptr, 7, "vme");
VME_SLOT(config, "slot8", sys1121_vme_cards, nullptr, 8, "vme");
}
void sys1121(machine_config &config);
};
// This is a VME chassis so any ROMs are contained in the cards.
ROM_START(sys1121)
ROM_END
// Input ports
INPUT_PORTS_START(sys1121)
INPUT_PORTS_END
void sys1121_vme_cards(device_slot_interface &device)
{
device.option_add("mvme120", VME_MVME120);
device.option_add("mvme121", VME_MVME121);
device.option_add("mvme122", VME_MVME122);
device.option_add("mvme123", VME_MVME123);
device.option_add("smvme2000", VME_SMVME2000);
device.option_add("mvme180", VME_MVME180);
device.option_add("mvme181", VME_MVME181);
device.option_add("mvme327a", VME_MVME327A);
device.option_add("tp881v", TP881V);
}
void sys1121_state::sys1121(machine_config &config)
{
VME(config, "vme", 0);
VME_SLOT(config, "slot1", sys1121_vme_cards, "mvme120", 1, "vme");
VME_SLOT(config, "slot2", sys1121_vme_cards, nullptr, 2, "vme");
VME_SLOT(config, "slot3", sys1121_vme_cards, nullptr, 3, "vme");
VME_SLOT(config, "slot4", sys1121_vme_cards, nullptr, 4, "vme");
VME_SLOT(config, "slot5", sys1121_vme_cards, nullptr, 5, "vme");
VME_SLOT(config, "slot6", sys1121_vme_cards, nullptr, 6, "vme");
VME_SLOT(config, "slot7", sys1121_vme_cards, nullptr, 7, "vme");
VME_SLOT(config, "slot8", sys1121_vme_cards, nullptr, 8, "vme");
}
// This is a VME chassis so any ROMs are contained in the cards.
ROM_START(sys1121)
ROM_END
} // anonymous namespace
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
COMP( 1984, sys1121, 0, 0, sys1121, sys1121, sys1121_state, empty_init, "Motorola", "SYS1121", MACHINE_IS_SKELETON )

View File

@ -89,7 +89,6 @@ public:
m_soundlatch(*this, "soundlatch")
{ }
void init_mightguy();
void cop01(machine_config &config);
protected:
@ -97,10 +96,12 @@ protected:
virtual void machine_reset() override;
virtual void video_start() override;
required_device<cpu_device> m_audiocpu;
uint8_t sound_command_r();
void cop01_base(machine_config &config);
required_device<cpu_device> m_audiocpu;
private:
// memory pointers
required_shared_ptr<uint8_t> m_bgvideoram;
@ -151,6 +152,8 @@ public:
template <int Mask> DECLARE_READ_LINE_MEMBER(area_r);
void init_mightguy();
private:
void audio_io_map(address_map &map);
@ -696,9 +699,9 @@ void cop01_state::machine_reset()
}
void cop01_state::cop01(machine_config &config)
void cop01_state::cop01_base(machine_config &config)
{
static constexpr XTAL MAINCPU_CLOCK = XTAL(12'000'000);
constexpr XTAL MAINCPU_CLOCK = XTAL(12'000'000);
// basic machine hardware
Z80(config, m_maincpu, MAINCPU_CLOCK / 2); // unknown clock / divider
@ -726,6 +729,11 @@ void cop01_state::cop01(machine_config &config)
SPEAKER(config, "mono").front_center();
GENERIC_LATCH_8(config, m_soundlatch).data_pending_callback().set_inputline(m_audiocpu, 0);
}
void cop01_state::cop01(machine_config &config)
{
cop01_base(config);
AY8910(config, "ay1", 1250000).add_route(ALL_OUTPUTS, "mono", 0.50); // unknown clock / divider, hand-tuned to match audio reference
AY8910(config, "ay2", 1250000).add_route(ALL_OUTPUTS, "mono", 0.25); // "
@ -734,9 +742,9 @@ void cop01_state::cop01(machine_config &config)
void mightguy_state::mightguy(machine_config &config)
{
cop01(config);
cop01_base(config);
static constexpr XTAL AUDIOCPU_CLOCK = XTAL(8'000'000);
constexpr XTAL AUDIOCPU_CLOCK = XTAL(8'000'000);
m_audiocpu->set_clock(AUDIOCPU_CLOCK / 2); // unknown divider
m_audiocpu->set_addrmap(AS_IO, &mightguy_state::audio_io_map);
@ -747,10 +755,6 @@ void mightguy_state::mightguy(machine_config &config)
YM3526(config, "ymsnd", AUDIOCPU_CLOCK / 2).add_route(ALL_OUTPUTS, "mono", 1.0); // unknown divider
DAC_8BIT_R2R(config, "dac", 0).add_route(ALL_OUTPUTS, "mono", 0.5); // unknown DAC
config.device_remove("ay1");
config.device_remove("ay2");
config.device_remove("ay3");
}
@ -874,11 +878,10 @@ ROM_END
*
*************************************/
void cop01_state::init_mightguy()
void mightguy_state::init_mightguy()
{
#if MIGHTGUY_HACK
/* This is a hack to fix the game code to get a fully working
"Starting Area" fake Dip Switch */
// This is a hack to fix the game code to get a fully working "Starting Area" fake DIP switch
uint8_t *rom = (uint8_t *)memregion("maincpu")->base();
rom[0x00e4] = 0x07; // rlca
rom[0x00e5] = 0x07; // rlca