summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Nigel Barnes <ngbarnes@gmail.com>2025-09-07 19:54:33 +0100
committer Nigel Barnes <ngbarnes@gmail.com>2025-09-13 16:55:33 +0100
commiteb6eb509bc7eee440776730b1dddb844c81faafc (patch)
treec970ac22be20ef2e3becf2e4d23f5149e3be18dc
parentb1b923d9697e28caecbcf4f4fd0c75e51f545b17 (diff)
machine/upd7002.cpp: Replaced custom delegates with devcb.
bus/bbc/analogue: Amended devices to return 12 bit digital values. - Moved classes into anonymous namespace.
-rw-r--r--src/devices/bus/archimedes/podule/io.cpp33
-rw-r--r--src/devices/bus/archimedes/podule/io_hccs.cpp74
-rw-r--r--src/devices/bus/archimedes/podule/io_morley.cpp47
-rw-r--r--src/devices/bus/archimedes/podule/io_we.cpp82
-rw-r--r--src/devices/bus/bbc/analogue/analogue.cpp27
-rw-r--r--src/devices/bus/bbc/analogue/analogue.h7
-rw-r--r--src/devices/bus/bbc/analogue/bitstik.cpp156
-rw-r--r--src/devices/bus/bbc/analogue/bitstik.h63
-rw-r--r--src/devices/bus/bbc/analogue/cfa3000a.cpp103
-rw-r--r--src/devices/bus/bbc/analogue/cfa3000a.h41
-rw-r--r--src/devices/bus/bbc/analogue/joystick.cpp145
-rw-r--r--src/devices/bus/bbc/analogue/joystick.h54
-rw-r--r--src/devices/bus/bbc/analogue/quinkey.cpp11
-rw-r--r--src/devices/bus/bbc/analogue/quinkey.h2
-rw-r--r--src/devices/bus/bbc/exp/exp.cpp24
-rw-r--r--src/devices/bus/bbc/exp/exp.h11
-rw-r--r--src/devices/bus/bbc/exp/mertec.cpp154
-rw-r--r--src/devices/bus/bbc/exp/mertec.h65
-rw-r--r--src/devices/bus/bbc/joyport/joyport.cpp6
-rw-r--r--src/devices/bus/bbc/joyport/joyport.h4
-rw-r--r--src/devices/machine/upd7002.cpp17
-rw-r--r--src/devices/machine/upd7002.h34
-rw-r--r--src/mame/acorn/bbc.h2
-rw-r--r--src/mame/acorn/bbc_m.cpp10
-rw-r--r--src/mame/acorn/bbcb.cpp4
-rw-r--r--src/mame/acorn/bbcbp.cpp4
-rw-r--r--src/mame/acorn/bbcm.cpp4
27 files changed, 408 insertions, 776 deletions
diff --git a/src/devices/bus/archimedes/podule/io.cpp b/src/devices/bus/archimedes/podule/io.cpp
index 7e23b3ac57f..ed0dcb86f0e 100644
--- a/src/devices/bus/archimedes/podule/io.cpp
+++ b/src/devices/bus/archimedes/podule/io.cpp
@@ -21,30 +21,29 @@
#include "emu.h"
#include "io.h"
+
+#include "bus/bbc/1mhzbus/1mhzbus.h"
+#include "bus/bbc/analogue/analogue.h"
+#include "bus/bbc/userport/userport.h"
+#include "bus/midi/midi.h"
#include "machine/6522via.h"
#include "machine/6850acia.h"
#include "machine/clock.h"
#include "machine/input_merger.h"
#include "machine/mc68681.h"
#include "machine/upd7002.h"
-#include "bus/bbc/1mhzbus/1mhzbus.h"
-#include "bus/bbc/analogue/analogue.h"
-#include "bus/bbc/userport/userport.h"
-#include "bus/midi/midi.h"
namespace {
// ======================> arc_io_aka_device
-class arc_io_aka_device :
- public device_t,
- public device_archimedes_podule_interface
+class arc_io_aka_device : public device_t, public device_archimedes_podule_interface
{
protected:
arc_io_aka_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
- // device-level overrides
+ // device_t overrides
virtual void device_start() override ATTR_COLD;
virtual void device_reset() override ATTR_COLD;
@@ -61,8 +60,6 @@ protected:
u8 m_rom_page;
u8 pa_r();
- int get_analogue_input(int channel_number);
- void upd7002_eoc(int state);
int m_irq_en;
};
@@ -268,8 +265,8 @@ void arc_io_aka_device::add_userport(machine_config &config)
void arc_io_aka_device::add_analogue(machine_config &config)
{
upd7002_device &upd7002(UPD7002(config, "upd7002", DERIVED_CLOCK(1, 4)));
- upd7002.set_get_analogue_callback(FUNC(arc_io_aka_device::get_analogue_input));
- upd7002.set_eoc_callback(FUNC(arc_io_aka_device::upd7002_eoc));
+ upd7002.get_analogue_callback().set(m_analog, FUNC(bbc_analogue_slot_device::ch_r));
+ upd7002.eoc_callback().set(m_irqs, FUNC(input_merger_device::in_w<1>)).invert();
BBC_ANALOGUE_SLOT(config, m_analog, bbc_analogue_devices, nullptr);
m_analog->lpstb_handler().set("via", FUNC(via6522_device::write_ca1));
@@ -277,7 +274,7 @@ void arc_io_aka_device::add_analogue(machine_config &config)
void arc_io_aka_device::add_1mhzbus(machine_config &config)
{
- bbc_1mhzbus_slot_device &bus(BBC_1MHZBUS_SLOT(config, "1mhzbus", DERIVED_CLOCK(1, 8), bbcm_1mhzbus_devices, nullptr));
+ bbc_1mhzbus_slot_device &bus(BBC_1MHZBUS_SLOT(config, "1mhzbus", DERIVED_CLOCK(1, 8), bbc_1mhzbus_devices, nullptr));
bus.irq_handler().set(m_irqs, FUNC(input_merger_device::in_w<2>));
bus.nmi_handler().set([this](int state) { set_pfiq(state); });
}
@@ -423,16 +420,6 @@ u8 arc_io_aka_device::pa_r()
return data;
}
-int arc_io_aka_device::get_analogue_input(int channel_number)
-{
- return m_analog->ch_r(channel_number) << 8;
-}
-
-void arc_io_aka_device::upd7002_eoc(int state)
-{
- m_irqs->in_w<1>(!state);
-}
-
} // anonymous namespace
diff --git a/src/devices/bus/archimedes/podule/io_hccs.cpp b/src/devices/bus/archimedes/podule/io_hccs.cpp
index c815549d193..9ef02da6ca6 100644
--- a/src/devices/bus/archimedes/podule/io_hccs.cpp
+++ b/src/devices/bus/archimedes/podule/io_hccs.cpp
@@ -10,27 +10,30 @@
#include "emu.h"
#include "io_hccs.h"
-#include "machine/6522via.h"
-#include "machine/upd7002.h"
+
#include "bus/bbc/analogue/analogue.h"
#include "bus/bbc/userport/userport.h"
+#include "machine/6522via.h"
+#include "machine/upd7002.h"
namespace {
// ======================> arc_upa_hccs_device
-class arc_upa_hccs_device :
- public device_t,
- public device_archimedes_podule_interface
+class arc_upa_hccs_device : public device_t, public device_archimedes_podule_interface
{
public:
- // construction/destruction
- arc_upa_hccs_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+ arc_upa_hccs_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : device_t(mconfig, ARC_UPA_HCCS, tag, owner, clock)
+ , device_archimedes_podule_interface(mconfig, *this)
+ , m_podule_rom(*this, "podule_rom")
+ {
+ }
protected:
- // device-level overrides
- virtual void device_start() override ATTR_COLD;
+ // device_t overrides
+ virtual void device_start() override ATTR_COLD { }
// optional information overrides
virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
@@ -41,9 +44,6 @@ protected:
private:
required_memory_region m_podule_rom;
- required_device<bbc_analogue_slot_device> m_analog;
-
- int get_analogue_input(int channel_number);
};
@@ -79,7 +79,7 @@ void arc_upa_hccs_device::device_add_mconfig(machine_config &config)
{
via6522_device &via(MOS6522(config, "via", DERIVED_CLOCK(1, 4)));
via.irq_handler().set([this](int state) { set_pirq(state); });
- via.readpa_handler().set(m_analog, FUNC(bbc_analogue_slot_device::pb_r));
+ via.readpa_handler().set("analog", FUNC(bbc_analogue_slot_device::pb_r));
via.readpb_handler().set("userport", FUNC(bbc_userport_slot_device::pb_r));
via.writepb_handler().set("userport", FUNC(bbc_userport_slot_device::pb_w));
via.cb1_handler().set("userport", FUNC(bbc_userport_slot_device::write_cb1));
@@ -90,54 +90,14 @@ void arc_upa_hccs_device::device_add_mconfig(machine_config &config)
userport.cb2_handler().set("via", FUNC(via6522_device::write_cb2));
upd7002_device &upd7002(UPD7002(config, "upd7002", DERIVED_CLOCK(1, 4)));
- upd7002.set_get_analogue_callback(FUNC(arc_upa_hccs_device::get_analogue_input));
- upd7002.set_eoc_callback("via", FUNC(via6522_device::write_ca2));
-
- BBC_ANALOGUE_SLOT(config, m_analog, bbc_analogue_devices, nullptr);
- m_analog->lpstb_handler().set("via", FUNC(via6522_device::write_ca1));
-}
-
+ upd7002.get_analogue_callback().set("analog", FUNC(bbc_analogue_slot_device::ch_r));
+ upd7002.eoc_callback().set("via", FUNC(via6522_device::write_ca2));
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// arc_upa_hccs_device - constructor
-//-------------------------------------------------
-
-arc_upa_hccs_device::arc_upa_hccs_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
- : device_t(mconfig, ARC_UPA_HCCS, tag, owner, clock)
- , device_archimedes_podule_interface(mconfig, *this)
- , m_podule_rom(*this, "podule_rom")
- , m_analog(*this, "analogue")
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void arc_upa_hccs_device::device_start()
-{
-}
-
-
-//**************************************************************************
-// IMPLEMENTATION
-//**************************************************************************
-
-int arc_upa_hccs_device::get_analogue_input(int channel_number)
-{
- return m_analog->ch_r(channel_number) << 8;
+ bbc_analogue_slot_device &analog(BBC_ANALOGUE_SLOT(config, "analog", bbc_analogue_devices, nullptr));
+ analog.lpstb_handler().set("via", FUNC(via6522_device::write_ca1));
}
} // anonymous namespace
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
DEFINE_DEVICE_TYPE_PRIVATE(ARC_UPA_HCCS, device_archimedes_podule_interface, arc_upa_hccs_device, "arc_upa_hccs", "HCCS User/Analogue Podule")
diff --git a/src/devices/bus/archimedes/podule/io_morley.cpp b/src/devices/bus/archimedes/podule/io_morley.cpp
index d030e3120f8..ace971a5627 100644
--- a/src/devices/bus/archimedes/podule/io_morley.cpp
+++ b/src/devices/bus/archimedes/podule/io_morley.cpp
@@ -18,27 +18,26 @@
#include "emu.h"
#include "io_morley.h"
+
+#include "bus/bbc/analogue/analogue.h"
+#include "bus/bbc/userport/userport.h"
+#include "bus/midi/midi.h"
#include "machine/6522via.h"
#include "machine/input_merger.h"
#include "machine/mc68681.h"
#include "machine/upd7002.h"
-#include "bus/bbc/analogue/analogue.h"
-#include "bus/bbc/userport/userport.h"
-#include "bus/midi/midi.h"
namespace {
// ======================> arc_io_morley_device
-class arc_io_morley_device :
- public device_t,
- public device_archimedes_podule_interface
+class arc_io_morley_device : public device_t, public device_archimedes_podule_interface
{
protected:
arc_io_morley_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
- // device-level overrides
+ // device_t overrides
virtual void device_start() override ATTR_COLD;
virtual void device_reset() override ATTR_COLD;
@@ -48,12 +47,8 @@ protected:
required_memory_region m_podule_rom;
required_device<input_merger_device> m_irqs;
- optional_device<bbc_analogue_slot_device> m_analog;
u8 m_rom_page;
-
- int get_analogue_input(int channel_number);
- void upd7002_eoc(int state);
};
@@ -197,7 +192,7 @@ void arc_io_morley_device::add_userport(machine_config &config)
{
via6522_device &via(MOS6522(config, "via", DERIVED_CLOCK(1, 4)));
via.irq_handler().set(m_irqs, FUNC(input_merger_device::in_w<0>));
- via.readpa_handler().set(m_analog, FUNC(bbc_analogue_slot_device::pb_r)).lshift(2);
+ via.readpa_handler().set("analog", FUNC(bbc_analogue_slot_device::pb_r)).lshift(2);
via.writepa_handler().set([this](u8 data) { m_rom_page = data; });
via.readpb_handler().set("userport", FUNC(bbc_userport_slot_device::pb_r));
via.writepb_handler().set("userport", FUNC(bbc_userport_slot_device::pb_w));
@@ -212,11 +207,11 @@ void arc_io_morley_device::add_userport(machine_config &config)
void arc_io_morley_device::add_analogue(machine_config &config)
{
upd7002_device &upd7002(UPD7002(config, "upd7002", DERIVED_CLOCK(1, 4)));
- upd7002.set_get_analogue_callback(FUNC(arc_io_morley_device::get_analogue_input));
- upd7002.set_eoc_callback(FUNC(arc_io_morley_device::upd7002_eoc));
+ upd7002.get_analogue_callback().set("analog", FUNC(bbc_analogue_slot_device::ch_r));
+ upd7002.eoc_callback().set(m_irqs, FUNC(input_merger_device::in_w<1>)).invert();
- BBC_ANALOGUE_SLOT(config, m_analog, bbc_analogue_devices, nullptr);
- m_analog->lpstb_handler().set("via", FUNC(via6522_device::write_ca1));
+ bbc_analogue_slot_device &analog(BBC_ANALOGUE_SLOT(config, "analog", bbc_analogue_devices, nullptr));
+ analog.lpstb_handler().set("via", FUNC(via6522_device::write_ca1));
}
void arc_io_morley_device::add_midi(machine_config &config)
@@ -271,7 +266,6 @@ arc_io_morley_device::arc_io_morley_device(const machine_config &mconfig, device
, device_archimedes_podule_interface(mconfig, *this)
, m_podule_rom(*this, "podule_rom")
, m_irqs(*this, "irqs")
- , m_analog(*this, "analogue")
, m_rom_page(0)
{
}
@@ -311,28 +305,9 @@ void arc_io_morley_device::device_reset()
m_rom_page = 0x00;
}
-
-//**************************************************************************
-// IMPLEMENTATION
-//**************************************************************************
-
-int arc_io_morley_device::get_analogue_input(int channel_number)
-{
- return m_analog->ch_r(channel_number) << 8;
-}
-
-void arc_io_morley_device::upd7002_eoc(int state)
-{
- m_irqs->in_w<1>(!state);
-}
-
} // anonymous namespace
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
DEFINE_DEVICE_TYPE_PRIVATE(ARC_BBCIO_AGA30, device_archimedes_podule_interface, arc_bbcio_aga30_device, "arc_bbcio_aga30", "Acorn AGA30 BBC I/O Podule")
DEFINE_DEVICE_TYPE_PRIVATE(ARC_UA_MORLEY, device_archimedes_podule_interface, arc_ua_morley_device, "arc_ua_morley", "Morley Electronics Analogue and User Interface")
DEFINE_DEVICE_TYPE_PRIVATE(ARC_UMA_MORLEY, device_archimedes_podule_interface, arc_uma_morley_device, "arc_uma_morley", "Morley Electronics User/MIDI/Analogue Interface")
diff --git a/src/devices/bus/archimedes/podule/io_we.cpp b/src/devices/bus/archimedes/podule/io_we.cpp
index d05e646ec6c..7d01dc49a72 100644
--- a/src/devices/bus/archimedes/podule/io_we.cpp
+++ b/src/devices/bus/archimedes/podule/io_we.cpp
@@ -10,27 +10,35 @@
#include "emu.h"
#include "io_we.h"
+
+#include "bus/bbc/analogue/analogue.h"
+#include "bus/bbc/userport/userport.h"
#include "machine/6522via.h"
#include "machine/input_merger.h"
#include "machine/upd7002.h"
-#include "bus/bbc/analogue/analogue.h"
-#include "bus/bbc/userport/userport.h"
namespace {
// ======================> arc_bbcio_we_device
-class arc_bbcio_we_device :
- public device_t,
- public device_archimedes_podule_interface
+class arc_bbcio_we_device : public device_t, public device_archimedes_podule_interface
{
public:
- // construction/destruction
- arc_bbcio_we_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+ arc_bbcio_we_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : device_t(mconfig, ARC_BBCIO_WE, tag, owner, clock)
+ , device_archimedes_podule_interface(mconfig, *this)
+ , m_podule_rom(*this, "podule_rom")
+ , m_irqs(*this, "irqs")
+ , m_upd7002(*this, "upd7002")
+ , m_rom_page(0)
+ , m_adc_irq(0)
+ , m_via_irq(0)
+ {
+ }
protected:
- // device-level overrides
+ // device_t overrides
virtual void device_start() override ATTR_COLD;
virtual void device_reset() override ATTR_COLD;
@@ -45,14 +53,10 @@ protected:
private:
required_memory_region m_podule_rom;
required_device<input_merger_device> m_irqs;
- required_device<bbc_analogue_slot_device> m_analog;
required_device<upd7002_device> m_upd7002;
u8 m_rom_page;
- int get_analogue_input(int channel_number);
- void upd7002_eoc(int state);
-
int m_adc_irq;
int m_via_irq;
};
@@ -99,7 +103,7 @@ void arc_bbcio_we_device::device_add_mconfig(machine_config &config)
via6522_device &via(MOS6522(config, "via", DERIVED_CLOCK(1, 4)));
via.irq_handler().set([this](int state) { m_via_irq = state; m_irqs->in_w<0>(state); });
- via.readpa_handler().set(m_analog, FUNC(bbc_analogue_slot_device::pb_r)).lshift(2);
+ via.readpa_handler().set("analog", FUNC(bbc_analogue_slot_device::pb_r)).lshift(2);
via.writepa_handler().set([this](u8 data) { m_rom_page = data; });
via.readpb_handler().set("userport", FUNC(bbc_userport_slot_device::pb_r));
via.writepb_handler().set("userport", FUNC(bbc_userport_slot_device::pb_w));
@@ -111,38 +115,16 @@ void arc_bbcio_we_device::device_add_mconfig(machine_config &config)
userport.cb2_handler().set("via", FUNC(via6522_device::write_cb2));
upd7002_device &upd7002(UPD7002(config, "upd7002", DERIVED_CLOCK(1, 4)));
- upd7002.set_get_analogue_callback(FUNC(arc_bbcio_we_device::get_analogue_input));
- upd7002.set_eoc_callback(FUNC(arc_bbcio_we_device::upd7002_eoc));
+ upd7002.get_analogue_callback().set("analog", FUNC(bbc_analogue_slot_device::ch_r));
+ upd7002.eoc_callback().set([this](int state) { m_adc_irq = !state; m_irqs->in_w<1>(!state); });
- BBC_ANALOGUE_SLOT(config, m_analog, bbc_analogue_devices, nullptr);
- m_analog->lpstb_handler().set("via", FUNC(via6522_device::write_ca1));
+ bbc_analogue_slot_device &analog(BBC_ANALOGUE_SLOT(config, "analog", bbc_analogue_devices, nullptr));
+ analog.lpstb_handler().set("via", FUNC(via6522_device::write_ca1));
// TODO: internal A3000 version adds IIC port
}
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// arc_bbcio_we_device - constructor
-//-------------------------------------------------
-
-arc_bbcio_we_device::arc_bbcio_we_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
- : device_t(mconfig, ARC_BBCIO_WE, tag, owner, clock)
- , device_archimedes_podule_interface(mconfig, *this)
- , m_podule_rom(*this, "podule_rom")
- , m_irqs(*this, "irqs")
- , m_analog(*this, "analogue")
- , m_upd7002(*this, "upd7002")
- , m_rom_page(0)
- , m_adc_irq(0)
- , m_via_irq(0)
-{
-}
-
-
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
@@ -162,29 +144,7 @@ void arc_bbcio_we_device::device_reset()
m_rom_page = 0x00;
}
-
-//**************************************************************************
-// IMPLEMENTATION
-//**************************************************************************
-
-int arc_bbcio_we_device::get_analogue_input(int channel_number)
-{
- return m_analog->ch_r(channel_number) << 8;
-}
-
-void arc_bbcio_we_device::upd7002_eoc(int state)
-{
- m_adc_irq = !state;
-
- m_irqs->in_w<1>(!state);
-}
-
-
} // anonymous namespace
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-
DEFINE_DEVICE_TYPE_PRIVATE(ARC_BBCIO_WE, device_archimedes_podule_interface, arc_bbcio_we_device, "arc_bbcio_we", "Watford Electronics BBC User I/O Card")
diff --git a/src/devices/bus/bbc/analogue/analogue.cpp b/src/devices/bus/bbc/analogue/analogue.cpp
index ab4da0b90e2..d53e08ac42e 100644
--- a/src/devices/bus/bbc/analogue/analogue.cpp
+++ b/src/devices/bus/bbc/analogue/analogue.cpp
@@ -17,7 +17,6 @@
DEFINE_DEVICE_TYPE(BBC_ANALOGUE_SLOT, bbc_analogue_slot_device, "bbc_analogue_slot", "BBC Micro Analogue port")
-
//**************************************************************************
// DEVICE BBC_ANALOGUE PORT INTERFACE
//**************************************************************************
@@ -26,10 +25,10 @@ DEFINE_DEVICE_TYPE(BBC_ANALOGUE_SLOT, bbc_analogue_slot_device, "bbc_analogue_sl
// device_bbc_analogue_interface - constructor
//-------------------------------------------------
-device_bbc_analogue_interface::device_bbc_analogue_interface(const machine_config &mconfig, device_t &device) :
- device_interface(device, "bbcanalogue")
+device_bbc_analogue_interface::device_bbc_analogue_interface(const machine_config &mconfig, device_t &device)
+ : device_interface(device, "bbcanalogue")
+ , m_slot(dynamic_cast<bbc_analogue_slot_device*>(device.owner()))
{
- m_slot = dynamic_cast<bbc_analogue_slot_device *>(device.owner());
}
@@ -41,11 +40,11 @@ device_bbc_analogue_interface::device_bbc_analogue_interface(const machine_confi
// bbc_analogue_slot_device - constructor
//-------------------------------------------------
-bbc_analogue_slot_device::bbc_analogue_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- device_t(mconfig, BBC_ANALOGUE_SLOT, tag, owner, clock),
- device_single_card_slot_interface<device_bbc_analogue_interface>(mconfig, *this),
- m_card(nullptr),
- m_lpstb_handler(*this)
+bbc_analogue_slot_device::bbc_analogue_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, BBC_ANALOGUE_SLOT, tag, owner, clock)
+ , device_single_card_slot_interface<device_bbc_analogue_interface>(mconfig, *this)
+ , m_card(nullptr)
+ , m_lpstb_handler(*this)
{
}
@@ -59,12 +58,12 @@ void bbc_analogue_slot_device::device_start()
m_card = get_card_device();
}
-uint8_t bbc_analogue_slot_device::ch_r(int channel)
+uint16_t bbc_analogue_slot_device::ch_r(offs_t channel)
{
if (m_card)
return m_card->ch_r(channel);
else
- return 0xff;
+ return 0xfff0;
}
uint8_t bbc_analogue_slot_device::pb_r()
@@ -90,6 +89,7 @@ void bbc_analogue_slot_device::pb_w(uint8_t data)
// slot devices
#include "joystick.h"
#include "bitstik.h"
+//#include "colourlp.h"
//#include "lightpen.h"
//#include "micromike.h"
#include "quinkey.h"
@@ -101,7 +101,10 @@ void bbc_analogue_devices(device_slot_interface &device)
device.option_add("acornjoy", BBC_ACORNJOY); /* Acorn ANH01 Joysticks */
device.option_add("bitstik1", BBC_BITSTIK1); /* Acorn ANF04 Bitstik */
device.option_add("bitstik2", BBC_BITSTIK2); /* Robocom Bitstik 2 */
- //device.option_add("lightpen", BBC_LIGHTPEN); /* RH Electronics Lightpen */
+ //device.option_add("i2crtc", BBC_I2C_RTCA); /* I2C RTC Module */
+ //device.option_add("colourlp", BBC_COLOURLP); /* RH Electronics Colour Light Pen */
+ //device.option_add("robinlp", BBC_ROBINLP); /* The Robin Light Pen */
+ //device.option_add("stacklr", BBC_STACKLR); /* Stack Light Rifle */
//device.option_add("micromike", BBC_MICROMIKE); /* Micro Mike */
device.option_add("voltmace3b", BBC_VOLTMACE3B); /* Voltmace Delta 3b "Twin" Joysticks */
device.option_add("quinkey", BBC_QUINKEY_INTF); /* Microwriter Quinkey */
diff --git a/src/devices/bus/bbc/analogue/analogue.h b/src/devices/bus/bbc/analogue/analogue.h
index 12ad0a4c608..9820709074a 100644
--- a/src/devices/bus/bbc/analogue/analogue.h
+++ b/src/devices/bus/bbc/analogue/analogue.h
@@ -32,7 +32,6 @@
#pragma once
-
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
@@ -62,7 +61,7 @@ public:
void lpstb_w(int state) { m_lpstb_handler(state); }
- uint8_t ch_r(int channel);
+ uint16_t ch_r(offs_t channel);
uint8_t pb_r();
void pb_w(uint8_t data);
@@ -82,14 +81,14 @@ private:
class device_bbc_analogue_interface : public device_interface
{
public:
- virtual uint8_t ch_r(int channel) { return 0x00; }
+ virtual uint16_t ch_r(offs_t channel) { return 0x00; }
virtual uint8_t pb_r() { return 0x30; }
virtual void pb_w(uint8_t data) { }
protected:
device_bbc_analogue_interface(const machine_config &mconfig, device_t &device);
- bbc_analogue_slot_device *m_slot;
+ bbc_analogue_slot_device *const m_slot;
};
diff --git a/src/devices/bus/bbc/analogue/bitstik.cpp b/src/devices/bus/bbc/analogue/bitstik.cpp
index f904e20db9f..e28e57f438b 100644
--- a/src/devices/bus/bbc/analogue/bitstik.cpp
+++ b/src/devices/bus/bbc/analogue/bitstik.cpp
@@ -13,15 +13,70 @@
#include "emu.h"
#include "bitstik.h"
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-DEFINE_DEVICE_TYPE(BBC_BITSTIK1, bbc_bitstik1_device, "bbc_bitstik1", "Acorn Bitstik")
-DEFINE_DEVICE_TYPE(BBC_BITSTIK2, bbc_bitstik2_device, "bbc_bitstik2", "Robo Bitstik 2")
+namespace {
+
+class bbc_bitstik_device : public device_t, public device_bbc_analogue_interface
+{
+protected:
+ bbc_bitstik_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, type, tag, owner, clock),
+ device_bbc_analogue_interface(mconfig, *this),
+ m_channel(*this, "CHANNEL%u", 0),
+ m_buttons(*this, "BUTTONS")
+ {
+ }
+
+ // device_t overrides
+ virtual void device_start() override ATTR_COLD { }
+
+ // optional information overrides
+ virtual ioport_constructor device_input_ports() const override ATTR_COLD;
+
+ virtual uint16_t ch_r(offs_t channel) override
+ {
+ return m_channel[channel]->read() << 4;
+ }
+
+ virtual uint8_t pb_r() override
+ {
+ return m_buttons->read() & 0x30;
+ }
+
+private:
+ required_ioport_array<4> m_channel;
+ required_ioport m_buttons;
+};
+
+
+class bbc_bitstik1_device : public bbc_bitstik_device
+{
+public:
+ bbc_bitstik1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ bbc_bitstik_device(mconfig, BBC_BITSTIK1, tag, owner, clock)
+ {
+ }
+
+protected:
+ virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD;
+};
+
+
+class bbc_bitstik2_device : public bbc_bitstik_device
+{
+public:
+ bbc_bitstik2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ bbc_bitstik_device(mconfig, BBC_BITSTIK2, tag, owner, clock)
+ {
+ }
+
+protected:
+ virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD;
+};
+
//-------------------------------------------------
-// ROM( bitstik )
+// rom_region - device-specific ROM region
//-------------------------------------------------
ROM_START(bitstik1)
@@ -36,40 +91,6 @@ ROM_START(bitstik2)
ROM_RELOAD(0x2000, 0x2000)
ROM_END
-//-------------------------------------------------
-// INPUT_PORTS( bitstik )
-//-------------------------------------------------
-
-static INPUT_PORTS_START(bitstik)
- PORT_START("CHANNEL0")
- PORT_BIT(0xff, 0x00, IPT_AD_STICK_X) PORT_MINMAX(0x00, 0xff) PORT_SENSITIVITY(25) PORT_KEYDELTA(200) PORT_NAME("AD Stick X")
-
- PORT_START("CHANNEL1")
- PORT_BIT(0xff, 0x00, IPT_AD_STICK_Y) PORT_MINMAX(0x00, 0xff) PORT_SENSITIVITY(25) PORT_KEYDELTA(200) PORT_NAME("AD Stick Y")
-
- PORT_START("CHANNEL2")
- PORT_BIT(0xff, 0x00, IPT_AD_STICK_Z) PORT_MINMAX(0x00, 0xff) PORT_SENSITIVITY(25) PORT_KEYDELTA(200) PORT_NAME("AD Stick Z")
-
- PORT_START("CHANNEL3")
- PORT_BIT(0xff, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_NAME("Right Button - Release")
-
- PORT_START("BUTTONS")
- PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Top Button - Execute")
- PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_NAME("Left Button - Confirm")
-INPUT_PORTS_END
-
-//-------------------------------------------------
-// input_ports - device-specific input ports
-//-------------------------------------------------
-
-ioport_constructor bbc_bitstik_device::device_input_ports() const
-{
- return INPUT_PORTS_NAME(bitstik);
-}
-
-//-------------------------------------------------
-// rom_region - device-specific ROM region
-//-------------------------------------------------
const tiny_rom_entry *bbc_bitstik1_device::device_rom_region() const
{
@@ -81,52 +102,37 @@ const tiny_rom_entry *bbc_bitstik2_device::device_rom_region() const
return ROM_NAME(bitstik2);
}
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
//-------------------------------------------------
-// bbc_bitstik_device - constructor
+// input_ports - device-specific input ports
//-------------------------------------------------
-bbc_bitstik_device::bbc_bitstik_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
- device_t(mconfig, type, tag, owner, clock),
- device_bbc_analogue_interface(mconfig, *this),
- m_channel(*this, "CHANNEL%u", 0),
- m_buttons(*this, "BUTTONS")
-{
-}
+static INPUT_PORTS_START(bitstik)
+ PORT_START("CHANNEL0")
+ PORT_BIT(0xfff, 0x800, IPT_AD_STICK_X) PORT_MINMAX(0x00, 0xfff) PORT_SENSITIVITY(100) PORT_KEYDELTA(50) PORT_NAME("AD Stick X")
-bbc_bitstik1_device::bbc_bitstik1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- bbc_bitstik_device(mconfig, BBC_BITSTIK1, tag, owner, clock)
-{
-}
+ PORT_START("CHANNEL1")
+ PORT_BIT(0xfff, 0x800, IPT_AD_STICK_Y) PORT_MINMAX(0x00, 0xfff) PORT_SENSITIVITY(100) PORT_KEYDELTA(50) PORT_NAME("AD Stick Y")
-bbc_bitstik2_device::bbc_bitstik2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- bbc_bitstik_device(mconfig, BBC_BITSTIK2, tag, owner, clock)
-{
-}
+ PORT_START("CHANNEL2")
+ PORT_BIT(0xfff, 0x800, IPT_AD_STICK_Z) PORT_MINMAX(0x00, 0xfff) PORT_SENSITIVITY(100) PORT_KEYDELTA(50) PORT_NAME("AD Stick Z")
+ PORT_START("CHANNEL3")
+ PORT_BIT(0xfff, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_NAME("Right Button - Release")
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
+ PORT_START("BUTTONS")
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Top Button - Execute")
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_NAME("Left Button - Confirm")
+INPUT_PORTS_END
-void bbc_bitstik_device::device_start()
+
+ioport_constructor bbc_bitstik_device::device_input_ports() const
{
+ return INPUT_PORTS_NAME(bitstik);
}
+} // anonymous namespace
-//**************************************************************************
-// IMPLEMENTATION
-//**************************************************************************
-
-uint8_t bbc_bitstik_device::ch_r(int channel)
-{
- return m_channel[channel]->read();
-}
-uint8_t bbc_bitstik_device::pb_r()
-{
- return m_buttons->read() & 0x30;
-}
+DEFINE_DEVICE_TYPE_PRIVATE(BBC_BITSTIK1, device_bbc_analogue_interface, bbc_bitstik1_device, "bbc_bitstik1", "Acorn Bitstik")
+DEFINE_DEVICE_TYPE_PRIVATE(BBC_BITSTIK2, device_bbc_analogue_interface, bbc_bitstik2_device, "bbc_bitstik2", "Robo Bitstik 2")
diff --git a/src/devices/bus/bbc/analogue/bitstik.h b/src/devices/bus/bbc/analogue/bitstik.h
index c5986e39dd1..3d859d57323 100644
--- a/src/devices/bus/bbc/analogue/bitstik.h
+++ b/src/devices/bus/bbc/analogue/bitstik.h
@@ -1,73 +1,14 @@
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
-/**********************************************************************
-
- Acorn ANF04 Bitstik
-
- http://chrisacorns.computinghistory.org.uk/8bit_Upgrades/Acorn_BitStik.html
-
- Robocom Bitstik 2
-
-**********************************************************************/
-
-
#ifndef MAME_BUS_BBC_ANALOGUE_BITSTIK_H
#define MAME_BUS_BBC_ANALOGUE_BITSTIK_H
#pragma once
-
#include "analogue.h"
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> bbc_bitstik_device
-
-class bbc_bitstik_device :
- public device_t,
- public device_bbc_analogue_interface
-{
-protected:
- // construction/destruction
- bbc_bitstik_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
-
- // device-level overrides
- virtual void device_start() override ATTR_COLD;
-
- // optional information overrides
- virtual ioport_constructor device_input_ports() const override ATTR_COLD;
-
- virtual uint8_t ch_r(int channel) override;
- virtual uint8_t pb_r() override;
-
-private:
- required_ioport_array<4> m_channel;
- required_ioport m_buttons;
-};
-
-class bbc_bitstik1_device : public bbc_bitstik_device
-{
-public:
- bbc_bitstik1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
-protected:
- virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD;
-};
-
-class bbc_bitstik2_device : public bbc_bitstik_device
-{
-public:
- bbc_bitstik2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
-protected:
- virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD;
-};
-
-// device type definition
-DECLARE_DEVICE_TYPE(BBC_BITSTIK1, bbc_bitstik1_device)
-DECLARE_DEVICE_TYPE(BBC_BITSTIK2, bbc_bitstik2_device)
+DECLARE_DEVICE_TYPE(BBC_BITSTIK1, device_bbc_analogue_interface)
+DECLARE_DEVICE_TYPE(BBC_BITSTIK2, device_bbc_analogue_interface)
#endif // MAME_BUS_BBC_ANALOGUE_BITSTIK_H
diff --git a/src/devices/bus/bbc/analogue/cfa3000a.cpp b/src/devices/bus/bbc/analogue/cfa3000a.cpp
index f48234e091b..ccd2ac29161 100644
--- a/src/devices/bus/bbc/analogue/cfa3000a.cpp
+++ b/src/devices/bus/bbc/analogue/cfa3000a.cpp
@@ -6,95 +6,74 @@
**********************************************************************/
-
#include "emu.h"
#include "cfa3000a.h"
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-DEFINE_DEVICE_TYPE(CFA3000_ANLG, cfa3000_anlg_device, "cfa3000a", "Henson CFA 3000 Analogue")
+namespace {
+
+class cfa3000_anlg_device : public device_t, public device_bbc_analogue_interface
+{
+public:
+ cfa3000_anlg_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, CFA3000_ANLG, tag, owner, clock),
+ device_bbc_analogue_interface(mconfig, *this),
+ m_channel(*this, "CHANNEL%u", 0),
+ m_buttons(*this, "BUTTONS")
+ {
+ }
+
+protected:
+ // device_t overrides
+ virtual void device_start() override ATTR_COLD { }
+
+ // optional information overrides
+ virtual ioport_constructor device_input_ports() const override ATTR_COLD;
+
+ virtual uint16_t ch_r(offs_t channel) override
+ {
+ return m_channel[channel]->read() << 4;
+ }
+
+ virtual uint8_t pb_r() override
+ {
+ return m_buttons->read() & 0x30;
+ }
+
+private:
+ required_ioport_array<4> m_channel;
+ required_ioport m_buttons;
+};
//-------------------------------------------------
-// INPUT_PORTS( cfa3000a )
+// input_ports - device-specific input ports
//-------------------------------------------------
static INPUT_PORTS_START( cfa3000a )
PORT_START("CHANNEL0")
- PORT_BIT(0xff, 0x80, IPT_PADDLE) PORT_NAME("Background Intensity") PORT_SENSITIVITY(25) PORT_KEYDELTA(5) PORT_CENTERDELTA(0)
+ PORT_BIT(0xfff, 0x800, IPT_PADDLE) PORT_NAME("Background Intensity") PORT_SENSITIVITY(25) PORT_KEYDELTA(5) PORT_CENTERDELTA(0)
PORT_START("CHANNEL1")
- PORT_BIT(0xff, 0xff, IPT_UNKNOWN)
+ PORT_BIT(0xfff, 0xfff, IPT_UNKNOWN)
PORT_START("CHANNEL2")
- PORT_BIT(0xff, 0x80, IPT_PADDLE) PORT_NAME("Age") PORT_SENSITIVITY(25) PORT_KEYDELTA(5) PORT_CENTERDELTA(0)
+ PORT_BIT(0xfff, 0x800, IPT_PADDLE) PORT_NAME("Age") PORT_SENSITIVITY(25) PORT_KEYDELTA(5) PORT_CENTERDELTA(0)
PORT_START("CHANNEL3")
- PORT_BIT(0xff, 0xff, IPT_UNKNOWN)
+ PORT_BIT(0xfff, 0xfff, IPT_UNKNOWN)
PORT_START("BUTTONS")
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN)
PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN)
INPUT_PORTS_END
-
-//-------------------------------------------------
-// input_ports - device-specific input ports
-//-------------------------------------------------
-
ioport_constructor cfa3000_anlg_device::device_input_ports() const
{
return INPUT_PORTS_NAME( cfa3000a );
}
+} // anonymous namespace
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// cfa3000_anlg_device - constructor
-//-------------------------------------------------
-
-cfa3000_anlg_device::cfa3000_anlg_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- device_t(mconfig, CFA3000_ANLG, tag, owner, clock),
- device_bbc_analogue_interface(mconfig, *this),
- m_channel(*this, "CHANNEL%u", 0),
- m_buttons(*this, "BUTTONS")
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void cfa3000_anlg_device::device_start()
-{
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void cfa3000_anlg_device::device_reset()
-{
-}
-
-
-//**************************************************************************
-// IMPLEMENTATION
-//**************************************************************************
-uint8_t cfa3000_anlg_device::ch_r(int channel)
-{
- return m_channel[channel]->read();
-}
-
-uint8_t cfa3000_anlg_device::pb_r()
-{
- return m_buttons->read() & 0x30;
-}
+DEFINE_DEVICE_TYPE_PRIVATE(CFA3000_ANLG, device_bbc_analogue_interface, cfa3000_anlg_device, "cfa3000a", "Henson CFA 3000 Analogue")
diff --git a/src/devices/bus/bbc/analogue/cfa3000a.h b/src/devices/bus/bbc/analogue/cfa3000a.h
index 3e2ddb43ccc..93944c66a92 100644
--- a/src/devices/bus/bbc/analogue/cfa3000a.h
+++ b/src/devices/bus/bbc/analogue/cfa3000a.h
@@ -1,12 +1,5 @@
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
-/**********************************************************************
-
- Henson CFA3000 Analogue
-
-**********************************************************************/
-
-
#ifndef MAME_BUS_BBC_ANALOGUE_CFA3000A_H
#define MAME_BUS_BBC_ANALOGUE_CFA3000A_H
@@ -14,39 +7,7 @@
#include "analogue.h"
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> cfa3000_anlg_device
-
-class cfa3000_anlg_device :
- public device_t,
- public device_bbc_analogue_interface
-{
-public:
- // construction/destruction
- cfa3000_anlg_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
-protected:
- // device-level overrides
- virtual void device_start() override ATTR_COLD;
- virtual void device_reset() override ATTR_COLD;
-
- // optional information overrides
- virtual ioport_constructor device_input_ports() const override ATTR_COLD;
-
- virtual uint8_t ch_r(int channel) override;
- virtual uint8_t pb_r() override;
-
-private:
- required_ioport_array<4> m_channel;
- required_ioport m_buttons;
-};
-
-
-// device type definition
-DECLARE_DEVICE_TYPE(CFA3000_ANLG, cfa3000_anlg_device)
+DECLARE_DEVICE_TYPE(CFA3000_ANLG, device_bbc_analogue_interface)
#endif // MAME_BUS_BBC_ANALOGUE_CFA3000A_H
diff --git a/src/devices/bus/bbc/analogue/joystick.cpp b/src/devices/bus/bbc/analogue/joystick.cpp
index 434ea1060b2..bc7f66d654d 100644
--- a/src/devices/bus/bbc/analogue/joystick.cpp
+++ b/src/devices/bus/bbc/analogue/joystick.cpp
@@ -14,26 +14,81 @@
#include "emu.h"
#include "joystick.h"
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-DEFINE_DEVICE_TYPE(BBC_ACORNJOY, bbc_acornjoy_device, "bbc_acornjoy", "Acorn Analogue Joysticks")
-DEFINE_DEVICE_TYPE(BBC_VOLTMACE3B, bbc_voltmace3b_device, "bbc_voltmace3b", "Voltmace Delta 3b Twin Joysticks")
+namespace {
+class bbc_joystick_device : public device_t, public device_bbc_analogue_interface
+{
+protected:
+ bbc_joystick_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, type, tag, owner, clock),
+ device_bbc_analogue_interface(mconfig, *this),
+ m_joy(*this, "JOY%u", 0),
+ m_buttons(*this, "BUTTONS")
+ {
+ }
+
+ // device_t overrides
+ virtual void device_start() override ATTR_COLD { }
+
+ virtual uint16_t ch_r(offs_t channel) override
+ {
+ return m_joy[channel]->read() << 4;
+ }
+
+ virtual uint8_t pb_r() override
+ {
+ return m_buttons->read() & 0x30;
+ }
+
+private:
+ required_ioport_array<4> m_joy;
+ required_ioport m_buttons;
+};
+
+
+class bbc_acornjoy_device : public bbc_joystick_device
+{
+public:
+ bbc_acornjoy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ bbc_joystick_device(mconfig, BBC_ACORNJOY, tag, owner, clock)
+ {
+ }
+
+protected:
+ virtual ioport_constructor device_input_ports() const override ATTR_COLD;
+};
+
+
+class bbc_voltmace3b_device : public bbc_joystick_device
+{
+public:
+ bbc_voltmace3b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ bbc_joystick_device(mconfig, BBC_VOLTMACE3B, tag, owner, clock)
+ {
+ }
+
+protected:
+ virtual ioport_constructor device_input_ports() const override ATTR_COLD;
+};
+
+
+//-------------------------------------------------
+// input_ports - device-specific input ports
+//-------------------------------------------------
static INPUT_PORTS_START( acornjoy )
PORT_START("JOY0")
- PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(0) PORT_MINMAX(0x00, 0xff) PORT_REVERSE PORT_PLAYER(1)
+ PORT_BIT(0xfff, 0x800, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(50) PORT_CENTERDELTA(0) PORT_MINMAX(0x00, 0xfff) PORT_REVERSE PORT_PLAYER(1)
PORT_START("JOY1")
- PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(0) PORT_MINMAX(0x00, 0xff) PORT_REVERSE PORT_PLAYER(1)
+ PORT_BIT(0xfff, 0x800, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(50) PORT_CENTERDELTA(0) PORT_MINMAX(0x00, 0xfff) PORT_REVERSE PORT_PLAYER(1)
PORT_START("JOY2")
- PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(0) PORT_MINMAX(0x00, 0xff) PORT_REVERSE PORT_PLAYER(2)
+ PORT_BIT(0xfff, 0x800, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(50) PORT_CENTERDELTA(0) PORT_MINMAX(0x00, 0xfff) PORT_REVERSE PORT_PLAYER(2)
PORT_START("JOY3")
- PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(0) PORT_MINMAX(0x00, 0xff) PORT_REVERSE PORT_PLAYER(2)
+ PORT_BIT(0xfff, 0x800, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(50) PORT_CENTERDELTA(0) PORT_MINMAX(0x00, 0xfff) PORT_REVERSE PORT_PLAYER(2)
PORT_START("BUTTONS")
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1)
@@ -42,16 +97,16 @@ INPUT_PORTS_END
static INPUT_PORTS_START( voltmace3b )
PORT_START("JOY0")
- PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(20) PORT_MINMAX(0x00, 0xff) PORT_REVERSE PORT_PLAYER(1)
+ PORT_BIT(0xfff, 0x800, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(50) PORT_CENTERDELTA(50) PORT_MINMAX(0x00, 0xfff) PORT_REVERSE PORT_PLAYER(1)
PORT_START("JOY1")
- PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(20) PORT_MINMAX(0x00, 0xff) PORT_REVERSE PORT_PLAYER(1)
+ PORT_BIT(0xfff, 0x800, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(50) PORT_CENTERDELTA(50) PORT_MINMAX(0x00, 0xfff) PORT_REVERSE PORT_PLAYER(1)
PORT_START("JOY2")
- PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(20) PORT_MINMAX(0x00, 0xff) PORT_REVERSE PORT_PLAYER(2)
+ PORT_BIT(0xfff, 0x800, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(50) PORT_CENTERDELTA(50) PORT_MINMAX(0x00, 0xfff) PORT_REVERSE PORT_PLAYER(2)
PORT_START("JOY3")
- PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(2) PORT_CENTERDELTA(20) PORT_MINMAX(0x00, 0xff) PORT_REVERSE PORT_PLAYER(2)
+ PORT_BIT(0xfff, 0x800, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(50) PORT_CENTERDELTA(50) PORT_MINMAX(0x00, 0xfff) PORT_REVERSE PORT_PLAYER(2)
PORT_START("BUTTONS")
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1)
@@ -59,10 +114,6 @@ static INPUT_PORTS_START( voltmace3b )
INPUT_PORTS_END
-//-------------------------------------------------
-// input_ports - device-specific input ports
-//-------------------------------------------------
-
ioport_constructor bbc_acornjoy_device::device_input_ports() const
{
return INPUT_PORTS_NAME( acornjoy );
@@ -73,62 +124,8 @@ ioport_constructor bbc_voltmace3b_device::device_input_ports() const
return INPUT_PORTS_NAME( voltmace3b );
}
+} // anonymous namespace
-//**************************************************************************
-// LIVE DEVICE
-//**************************************************************************
-
-//-------------------------------------------------
-// bbc_joystick_device - constructor
-//-------------------------------------------------
-
-bbc_joystick_device::bbc_joystick_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
- device_t(mconfig, type, tag, owner, clock),
- device_bbc_analogue_interface(mconfig, *this),
- m_joy(*this, "JOY%u", 0),
- m_buttons(*this, "BUTTONS")
-{
-}
-
-bbc_acornjoy_device::bbc_acornjoy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- bbc_joystick_device(mconfig, BBC_ACORNJOY, tag, owner, clock)
-{
-}
-bbc_voltmace3b_device::bbc_voltmace3b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- bbc_joystick_device(mconfig, BBC_VOLTMACE3B, tag, owner, clock)
-{
-}
-
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void bbc_joystick_device::device_start()
-{
-}
-
-
-//-------------------------------------------------
-// device_reset - device-specific reset
-//-------------------------------------------------
-
-void bbc_joystick_device::device_reset()
-{
-}
-
-
-//**************************************************************************
-// IMPLEMENTATION
-//**************************************************************************
-
-uint8_t bbc_joystick_device::ch_r(int channel)
-{
- return m_joy[channel]->read();
-}
-
-uint8_t bbc_joystick_device::pb_r()
-{
- return m_buttons->read() & 0x30;
-}
+DEFINE_DEVICE_TYPE_PRIVATE(BBC_ACORNJOY, device_bbc_analogue_interface, bbc_acornjoy_device, "bbc_acornjoy", "Acorn Analogue Joysticks")
+DEFINE_DEVICE_TYPE_PRIVATE(BBC_VOLTMACE3B, device_bbc_analogue_interface, bbc_voltmace3b_device, "bbc_voltmace3b", "Voltmace Delta 3b Twin Joysticks")
diff --git a/src/devices/bus/bbc/analogue/joystick.h b/src/devices/bus/bbc/analogue/joystick.h
index 5f4572a7cf6..404e388c08c 100644
--- a/src/devices/bus/bbc/analogue/joystick.h
+++ b/src/devices/bus/bbc/analogue/joystick.h
@@ -1,64 +1,14 @@
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
-/**********************************************************************
-
- Joystick Controllers
-
-**********************************************************************/
-
#ifndef MAME_BUS_BBC_ANALOGUE_JOYSTICK_H
#define MAME_BUS_BBC_ANALOGUE_JOYSTICK_H
#pragma once
-
#include "analogue.h"
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-// ======================> bbc_joystick_device
-
-class bbc_joystick_device :
- public device_t,
- public device_bbc_analogue_interface
-{
-protected:
- // construction/destruction
- bbc_joystick_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
-
- // device-level overrides
- virtual void device_start() override ATTR_COLD;
- virtual void device_reset() override ATTR_COLD;
-
- virtual uint8_t ch_r(int channel) override;
- virtual uint8_t pb_r() override;
-
-private:
- required_ioport_array<4> m_joy;
- required_ioport m_buttons;
-};
-
-class bbc_acornjoy_device : public bbc_joystick_device
-{
-public:
- bbc_acornjoy_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- virtual ioport_constructor device_input_ports() const override ATTR_COLD;
-};
-
-class bbc_voltmace3b_device : public bbc_joystick_device
-{
-public:
- bbc_voltmace3b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- virtual ioport_constructor device_input_ports() const override ATTR_COLD;
-};
-
-// device type definition
-DECLARE_DEVICE_TYPE(BBC_ACORNJOY, bbc_acornjoy_device)
-DECLARE_DEVICE_TYPE(BBC_VOLTMACE3B, bbc_voltmace3b_device)
+DECLARE_DEVICE_TYPE(BBC_ACORNJOY, device_bbc_analogue_interface)
+DECLARE_DEVICE_TYPE(BBC_VOLTMACE3B, device_bbc_analogue_interface)
#endif // MAME_BUS_BBC_ANALOGUE_JOYSTICK_H
diff --git a/src/devices/bus/bbc/analogue/quinkey.cpp b/src/devices/bus/bbc/analogue/quinkey.cpp
index b5fee35e7d1..8d93dbffb23 100644
--- a/src/devices/bus/bbc/analogue/quinkey.cpp
+++ b/src/devices/bus/bbc/analogue/quinkey.cpp
@@ -37,7 +37,7 @@ void bbc_quinkey_intf_device::device_add_mconfig(machine_config &config)
//-------------------------------------------------
-// INPUT_PORTS( quinkey )
+// input_ports - device-specific input ports
//-------------------------------------------------
static INPUT_PORTS_START( quinkey )
@@ -52,11 +52,6 @@ static INPUT_PORTS_START( quinkey )
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_UNUSED)
INPUT_PORTS_END
-
-//-------------------------------------------------
-// input_ports - device-specific input ports
-//-------------------------------------------------
-
ioport_constructor bbc_quinkey_device::device_input_ports() const
{
return INPUT_PORTS_NAME(quinkey);
@@ -88,9 +83,9 @@ void bbc_quinkey_intf_device::device_start()
}
-uint8_t bbc_quinkey_intf_device::ch_r(int channel)
+uint16_t bbc_quinkey_intf_device::ch_r(offs_t channel)
{
- return m_quinkey[channel]->read();
+ return m_quinkey[channel]->read() << 8;
}
diff --git a/src/devices/bus/bbc/analogue/quinkey.h b/src/devices/bus/bbc/analogue/quinkey.h
index f88df64ec2c..44e1b0da34a 100644
--- a/src/devices/bus/bbc/analogue/quinkey.h
+++ b/src/devices/bus/bbc/analogue/quinkey.h
@@ -35,7 +35,7 @@ protected:
// optional information overrides
virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
- virtual uint8_t ch_r(int channel) override;
+ virtual uint16_t ch_r(offs_t channel) override;
private:
required_device_array<bbc_quinkey_slot_device, 4> m_quinkey;
diff --git a/src/devices/bus/bbc/exp/exp.cpp b/src/devices/bus/bbc/exp/exp.cpp
index 5c255d226ed..c823647adee 100644
--- a/src/devices/bus/bbc/exp/exp.cpp
+++ b/src/devices/bus/bbc/exp/exp.cpp
@@ -17,7 +17,6 @@
DEFINE_DEVICE_TYPE(BBC_EXP_SLOT, bbc_exp_slot_device, "bbc_exp_slot", "BBC Master Compact Expansion port")
-
//**************************************************************************
// DEVICE BBC_EXP PORT INTERFACE
//**************************************************************************
@@ -41,14 +40,15 @@ device_bbc_exp_interface::device_bbc_exp_interface(const machine_config &mconfig
// bbc_exp_slot_device - constructor
//-------------------------------------------------
-bbc_exp_slot_device::bbc_exp_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
- device_t(mconfig, BBC_EXP_SLOT, tag, owner, clock),
- device_single_card_slot_interface<device_bbc_exp_interface>(mconfig, *this),
- m_card(nullptr),
- m_irq_handler(*this),
- m_nmi_handler(*this),
- m_cb1_handler(*this),
- m_cb2_handler(*this)
+bbc_exp_slot_device::bbc_exp_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, BBC_EXP_SLOT, tag, owner, clock)
+ , device_single_card_slot_interface<device_bbc_exp_interface>(mconfig, *this)
+ , m_card(nullptr)
+ , m_irq_handler(*this)
+ , m_nmi_handler(*this)
+ , m_lpstb_handler(*this)
+ , m_cb1_handler(*this)
+ , m_cb2_handler(*this)
{
}
@@ -99,12 +99,6 @@ void bbc_exp_slot_device::jim_w(offs_t offset, uint8_t data)
m_card->jim_w(offset, data);
}
-void bbc_exp_slot_device::sheila_w(offs_t offset, uint8_t data)
-{
- if (m_card)
- m_card->sheila_w(offset, data);
-}
-
//-------------------------------------------------
// pb_r
//-------------------------------------------------
diff --git a/src/devices/bus/bbc/exp/exp.h b/src/devices/bus/bbc/exp/exp.h
index dc6396fbf48..570f3d02e92 100644
--- a/src/devices/bus/bbc/exp/exp.h
+++ b/src/devices/bus/bbc/exp/exp.h
@@ -70,14 +70,12 @@ public:
// callbacks
auto irq_handler() { return m_irq_handler.bind(); }
auto nmi_handler() { return m_nmi_handler.bind(); }
-
+ auto lpstb_handler() { return m_lpstb_handler.bind(); }
uint8_t fred_r(offs_t offset);
void fred_w(offs_t offset, uint8_t data);
uint8_t jim_r(offs_t offset);
void jim_w(offs_t offset, uint8_t data);
- uint8_t sheila_r(offs_t offset);
- void sheila_w(offs_t offset, uint8_t data);
void irq_w(int state) { m_irq_handler(state); }
void nmi_w(int state) { m_nmi_handler(state); }
@@ -95,7 +93,7 @@ public:
void write_cb2(int state);
protected:
- // device-level overrides
+ // device_t overrides
virtual void device_start() override ATTR_COLD;
device_bbc_exp_interface *m_card;
@@ -103,6 +101,7 @@ protected:
private:
devcb_write_line m_irq_handler;
devcb_write_line m_nmi_handler;
+ devcb_write_line m_lpstb_handler;
devcb_write_line m_cb1_handler;
devcb_write_line m_cb2_handler;
@@ -118,8 +117,6 @@ public:
virtual void fred_w(offs_t offset, uint8_t data) { }
virtual uint8_t jim_r(offs_t offset) { return 0xff; }
virtual void jim_w(offs_t offset, uint8_t data) { }
- virtual uint8_t sheila_r(offs_t offset) { return 0xfe; }
- virtual void sheila_w(offs_t offset, uint8_t data) { }
virtual uint8_t pb_r() { return 0xff; }
virtual void pb_w(uint8_t data) { }
@@ -129,7 +126,7 @@ public:
protected:
device_bbc_exp_interface(const machine_config &mconfig, device_t &device);
- bbc_exp_slot_device *m_slot;
+ bbc_exp_slot_device *const m_slot;
};
diff --git a/src/devices/bus/bbc/exp/mertec.cpp b/src/devices/bus/bbc/exp/mertec.cpp
index c561f052460..d120e201db8 100644
--- a/src/devices/bus/bbc/exp/mertec.cpp
+++ b/src/devices/bus/bbc/exp/mertec.cpp
@@ -9,20 +9,67 @@
TODO:
- Fix userport, by somehow passing lines into joyport
- Not sure whether any 1MHz bus devices should work on the 2MHz bus
- - No idea how the 6821 is connected/used
+ - Map 6821 to ROM region offset 0x6000
**********************************************************************/
-
#include "emu.h"
#include "mertec.h"
+#include "bus/bbc/1mhzbus/1mhzbus.h"
+#include "bus/bbc/analogue/analogue.h"
+#include "bus/bbc/userport/userport.h"
+#include "machine/6821pia.h"
+#include "machine/upd7002.h"
-//**************************************************************************
-// DEVICE DEFINITIONS
-//**************************************************************************
-DEFINE_DEVICE_TYPE(BBC_MERTEC, bbc_mertec_device, "bbc_mertec", "Mertec Compact Companion");
+namespace {
+
+class bbc_mertec_device : public device_t, public device_bbc_exp_interface
+{
+public:
+ bbc_mertec_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, BBC_MERTEC, tag, owner, clock)
+ , device_bbc_exp_interface(mconfig, *this)
+ , m_pia(*this, "pia")
+ , m_upd7002(*this, "upd7002")
+ , m_analog(*this, "analogue")
+ , m_userport(*this, "userport")
+ , m_2mhzbus(*this, "2mhzbus")
+ , m_ext_rom(*this, "ext_rom")
+ {
+ }
+
+protected:
+ // device_t overrides
+ virtual void device_start() override ATTR_COLD { }
+
+ // optional information overrides
+ virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
+ virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD;
+
+ virtual uint8_t fred_r(offs_t offset) override;
+ virtual void fred_w(offs_t offset, uint8_t data) override;
+ virtual uint8_t jim_r(offs_t offset) override;
+ virtual void jim_w(offs_t offset, uint8_t data) override;
+
+ virtual uint8_t pb_r() override;
+ virtual void pb_w(uint8_t data) override;
+
+private:
+ uint8_t m_adc_ctrl = 0;
+ uint8_t m_adc_data = 0;
+
+ uint8_t adc_ctrl_r();
+ void adc_ctrl_w(uint8_t data);
+
+ required_device<pia6821_device> m_pia;
+ required_device<upd7002_device> m_upd7002;
+ required_device<bbc_analogue_slot_device> m_analog;
+ required_device<bbc_userport_slot_device> m_userport;
+ required_device<bbc_1mhzbus_slot_device> m_2mhzbus;
+ required_memory_region m_ext_rom;
+};
//-------------------------------------------------
@@ -47,24 +94,26 @@ const tiny_rom_entry *bbc_mertec_device::device_rom_region() const
void bbc_mertec_device::device_add_mconfig(machine_config &config)
{
PIA6821(config, m_pia, DERIVED_CLOCK(1, 8));
- //m_pia->readpb_handler().set("userport", FUNC(bbc_userport_slot_device::pb_r));
- //m_pia->writepb_handler().set("userport", FUNC(bbc_userport_slot_device::pb_w));
- //m_pia->irq_handler().set("irqs", FUNC(input_merger_device::in_w<0>));
+ m_pia->readpa_handler().set(FUNC(bbc_mertec_device::adc_ctrl_r));
+ m_pia->writepa_handler().set(FUNC(bbc_mertec_device::adc_ctrl_w));
+ m_pia->readpb_handler().set([this]() { return m_adc_data; });
+ m_pia->writepb_handler().set([this](uint8_t data) { m_adc_data = data; });
+ m_pia->irqb_handler().set(DEVICE_SELF_OWNER, FUNC(bbc_exp_slot_device::irq_w));
- /* adc */
UPD7002(config, m_upd7002, DERIVED_CLOCK(1, 8));
- m_upd7002->set_get_analogue_callback(FUNC(bbc_mertec_device::get_analogue_input));
- m_upd7002->set_eoc_callback(FUNC(bbc_mertec_device::upd7002_eoc));
+ m_upd7002->get_analogue_callback().set(m_analog, FUNC(bbc_analogue_slot_device::ch_r));
+ m_upd7002->eoc_callback().set(m_pia, FUNC(pia6821_device::cb1_w));
- /* analogue port */
+ // analogue port
BBC_ANALOGUE_SLOT(config, m_analog, bbc_analogue_devices, nullptr);
+ //m_analog->lpstb_handler().set(DEVICE_SELF_OWNER, FUNC(bbc_exp_slot_device::lpstb_w));
- /* user port */
+ // user port
BBC_USERPORT_SLOT(config, m_userport, bbc_userport_devices, nullptr);
- //m_userport->cb1_handler().set(m_pia, FUNC(via6522_device::write_cb1));
- //m_userport->cb2_handler().set(m_pia, FUNC(via6522_device::write_cb2));
+ m_userport->cb1_handler().set(DEVICE_SELF_OWNER, FUNC(bbc_exp_slot_device::cb1_w));
+ m_userport->cb2_handler().set(DEVICE_SELF_OWNER, FUNC(bbc_exp_slot_device::cb2_w));
- /* 2mhz bus port */
+ // 2mhz bus port
BBC_1MHZBUS_SLOT(config, m_2mhzbus, DERIVED_CLOCK(1, 4), bbc_1mhzbus_devices, nullptr);
m_2mhzbus->irq_handler().set(DEVICE_SELF_OWNER, FUNC(bbc_exp_slot_device::irq_w));
m_2mhzbus->nmi_handler().set(DEVICE_SELF_OWNER, FUNC(bbc_exp_slot_device::nmi_w));
@@ -72,46 +121,28 @@ void bbc_mertec_device::device_add_mconfig(machine_config &config)
//**************************************************************************
-// LIVE DEVICE
+// IMPLEMENTATION
//**************************************************************************
-//-------------------------------------------------
-// bbc_mertec_device - constructor
-//-------------------------------------------------
-
-bbc_mertec_device::bbc_mertec_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, BBC_MERTEC, tag, owner, clock)
- , device_bbc_exp_interface(mconfig, *this)
- , m_pia(*this, "pia")
- , m_upd7002(*this, "upd7002")
- , m_analog(*this, "analogue")
- , m_userport(*this, "userport")
- , m_2mhzbus(*this, "2mhzbus")
- , m_ext_rom(*this, "ext_rom")
+uint8_t bbc_mertec_device::adc_ctrl_r()
{
+ return (m_adc_ctrl & 0x1f) | (m_analog->pb_r() << 1);
}
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void bbc_mertec_device::device_start()
+void bbc_mertec_device::adc_ctrl_w(uint8_t data)
{
-}
-
+ m_adc_ctrl = data & 0x1f;
-//**************************************************************************
-// IMPLEMENTATION
-//**************************************************************************
-
-int bbc_mertec_device::get_analogue_input(int channel_number)
-{
- return m_analog->ch_r(channel_number) << 8;
-}
+ if (!BIT(data, 4)) // CS
+ {
+ switch (data & 0x0c)
+ {
+ case 0x04: m_upd7002->write(data & 3, m_adc_data); break;
+ case 0x08: m_adc_data = m_upd7002->read(data & 3); break;
+ }
+ }
-void bbc_mertec_device::upd7002_eoc(int data)
-{
- //m_via6522_0->write_cb1(data);
+ m_analog->pb_w(data >> 1);
}
uint8_t bbc_mertec_device::fred_r(offs_t offset)
@@ -134,26 +165,6 @@ void bbc_mertec_device::jim_w(offs_t offset, uint8_t data)
m_2mhzbus->jim_w(offset, data);
}
-uint8_t bbc_mertec_device::sheila_r(offs_t offset)
-{
- uint8_t data = 0xfe;
-
- if (offset >= 0x18 && offset < 0x20)
- {
- data = m_upd7002->read(offset & 0x03);
- }
-
- return data;
-}
-
-void bbc_mertec_device::sheila_w(offs_t offset, uint8_t data)
-{
- if (offset >= 0x18 && offset < 0x20)
- {
- m_upd7002->write(offset & 0x03, data);
- }
-}
-
uint8_t bbc_mertec_device::pb_r()
{
return m_userport->pb_r();
@@ -163,3 +174,8 @@ void bbc_mertec_device::pb_w(uint8_t data)
{
m_userport->pb_w(data);
}
+
+} // anonymous namespace
+
+
+DEFINE_DEVICE_TYPE_PRIVATE(BBC_MERTEC, device_bbc_exp_interface, bbc_mertec_device, "bbc_mertec", "Mertec Compact Companion");
diff --git a/src/devices/bus/bbc/exp/mertec.h b/src/devices/bus/bbc/exp/mertec.h
index 9f3847996c6..449835411e4 100644
--- a/src/devices/bus/bbc/exp/mertec.h
+++ b/src/devices/bus/bbc/exp/mertec.h
@@ -1,70 +1,13 @@
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
-/**********************************************************************
-
- Mertec Compact Companion
-
- http://chrisacorns.computinghistory.org.uk/8bit_Upgrades/Mertec_CompactComp.html
-
-**********************************************************************/
-
-
#ifndef MAME_BUS_BBC_EXP_MERTEC_H
#define MAME_BUS_BBC_EXP_MERTEC_H
-#include "exp.h"
-#include "machine/6821pia.h"
-#include "machine/upd7002.h"
-#include "bus/bbc/1mhzbus/1mhzbus.h"
-#include "bus/bbc/analogue/analogue.h"
-#include "bus/bbc/userport/userport.h"
-
-//**************************************************************************
-// TYPE DEFINITIONS
-//**************************************************************************
-
-class bbc_mertec_device :
- public device_t,
- public device_bbc_exp_interface
-{
-public:
- // construction/destruction
- bbc_mertec_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
-
-protected:
- // device-level overrides
- virtual void device_start() override ATTR_COLD;
-
- // optional information overrides
- virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
- virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD;
-
- virtual uint8_t fred_r(offs_t offset) override;
- virtual void fred_w(offs_t offset, uint8_t data) override;
- virtual uint8_t jim_r(offs_t offset) override;
- virtual void jim_w(offs_t offset, uint8_t data) override;
- virtual uint8_t sheila_r(offs_t offset) override;
- virtual void sheila_w(offs_t offset, uint8_t data) override;
-
- virtual uint8_t pb_r() override;
- virtual void pb_w(uint8_t data) override;
-
-private:
- int get_analogue_input(int channel_number);
- void upd7002_eoc(int data);
-
- required_device<pia6821_device> m_pia;
- required_device<upd7002_device> m_upd7002;
- required_device<bbc_analogue_slot_device> m_analog;
- required_device<bbc_userport_slot_device> m_userport;
- required_device<bbc_1mhzbus_slot_device> m_2mhzbus;
- required_memory_region m_ext_rom;
-};
+#pragma once
+#include "exp.h"
-// device type definition
-DECLARE_DEVICE_TYPE(BBC_MERTEC, bbc_mertec_device);
+DECLARE_DEVICE_TYPE(BBC_MERTEC, device_bbc_exp_interface);
-#endif /* MAME_BUS_BBC_EXP_MERTEC_H */
+#endif // MAME_BUS_BBC_EXP_MERTEC_H
diff --git a/src/devices/bus/bbc/joyport/joyport.cpp b/src/devices/bus/bbc/joyport/joyport.cpp
index 44387a80deb..b0f3c6f418f 100644
--- a/src/devices/bus/bbc/joyport/joyport.cpp
+++ b/src/devices/bus/bbc/joyport/joyport.cpp
@@ -25,10 +25,10 @@ DEFINE_DEVICE_TYPE(BBC_JOYPORT_SLOT, bbc_joyport_slot_device, "bbc_joyport_slot"
// device_bbc_joyport_interface - constructor
//-------------------------------------------------
-device_bbc_joyport_interface::device_bbc_joyport_interface(const machine_config &mconfig, device_t &device) :
- device_interface(device, "bbcjoyport")
+device_bbc_joyport_interface::device_bbc_joyport_interface(const machine_config &mconfig, device_t &device)
+ : device_interface(device, "bbcjoyport")
+ , m_slot(dynamic_cast<bbc_joyport_slot_device *>(device.owner()))
{
- m_slot = dynamic_cast<bbc_joyport_slot_device *>(device.owner());
}
diff --git a/src/devices/bus/bbc/joyport/joyport.h b/src/devices/bus/bbc/joyport/joyport.h
index 8e23e4b8a9a..0cd1e735d5d 100644
--- a/src/devices/bus/bbc/joyport/joyport.h
+++ b/src/devices/bus/bbc/joyport/joyport.h
@@ -72,7 +72,7 @@ public:
void write_cb2(int state);
protected:
- // device-level overrides
+ // device_t overrides
virtual void device_start() override ATTR_COLD;
device_bbc_joyport_interface *m_device;
@@ -96,7 +96,7 @@ public:
protected:
device_bbc_joyport_interface(const machine_config &mconfig, device_t &device);
- bbc_joyport_slot_device *m_slot;
+ bbc_joyport_slot_device *const m_slot;
};
diff --git a/src/devices/machine/upd7002.cpp b/src/devices/machine/upd7002.cpp
index ab97f46b4b3..7bbe086a477 100644
--- a/src/devices/machine/upd7002.cpp
+++ b/src/devices/machine/upd7002.cpp
@@ -10,8 +10,6 @@
#include "upd7002.h"
-/* Device Interface */
-
DEFINE_DEVICE_TYPE(UPD7002, upd7002_device, "upd7002", "uPD7002 ADC")
upd7002_device::upd7002_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
@@ -21,7 +19,7 @@ upd7002_device::upd7002_device(const machine_config &mconfig, const char *tag, d
, m_data0(0)
, m_digitalvalue(0)
, m_conversion_counter(0)
- , m_get_analogue_cb(*this)
+ , m_get_analogue_cb(*this, 0)
, m_eoc_cb(*this)
{
}
@@ -33,8 +31,6 @@ upd7002_device::upd7002_device(const machine_config &mconfig, const char *tag, d
void upd7002_device::device_start()
{
m_conversion_timer = timer_alloc(FUNC(upd7002_device::conversion_complete), this);
- m_get_analogue_cb.resolve();
- m_eoc_cb.resolve_safe();
// register for state saving
save_item(NAME(m_status));
@@ -62,7 +58,6 @@ void upd7002_device::device_reset()
Implementation
*****************************************************************************/
-
int upd7002_device::eoc_r()
{
return BIT(m_status, 7);
@@ -109,8 +104,6 @@ uint8_t upd7002_device::read(offs_t offset)
void upd7002_device::write(offs_t offset, uint8_t data)
{
- /* logerror("write to uPD7002 $%02X = $%02X\n",offset,data); */
-
switch (offset & 0x03)
{
case 0:
@@ -121,21 +114,21 @@ void upd7002_device::write(offs_t offset, uint8_t data)
D3 defines whether an 8 (0) or 12 (1) bit resolution conversion should occur
D4 to D7 not used.
- an 8 bit conversion typically takes 4ms
- an 12 bit conversion typically takes 10ms
+ an 8 bit conversion typically takes 4ms
+ a 12 bit conversion typically takes 10ms
writing to this register will initiate a conversion.
*/
/* set D6=0 busy ,D7=1 conversion not complete */
- m_status=(data & 0x0f) | 0x80;
+ m_status = (data & 0x0f) | 0x80;
// call the EOC function with EOC from status
// eoc_r(0) this has just been set to 1
m_eoc_cb(1);
/* the uPD7002 works by sampling the analogue value at the start of the conversion
- so it is read hear and stored until the end of the A to D conversion */
+ so it is read here and stored until the end of the A to D conversion */
// this function should return a 16 bit value.
m_digitalvalue = m_get_analogue_cb(m_status & 0x03);
diff --git a/src/devices/machine/upd7002.h b/src/devices/machine/upd7002.h
index 7fe1f2ea20b..4b6db9719cc 100644
--- a/src/devices/machine/upd7002.h
+++ b/src/devices/machine/upd7002.h
@@ -2,12 +2,8 @@
// copyright-holders:Gordon Jefferyes
/*****************************************************************************
*
- * machine/upd7002.h
- *
* uPD7002 Analogue to Digital Converter
*
- * Driver by Gordon Jefferyes <mess_bbc@gjeffery.dircon.co.uk>
- *
****************************************************************************/
#ifndef MAME_MACHINE_UPD7002_H
@@ -15,34 +11,26 @@
#pragma once
-/***************************************************************************
- MACROS
-***************************************************************************/
class upd7002_device : public device_t
{
public:
- typedef device_delegate<int (int channel_number)> get_analogue_delegate;
- typedef device_delegate<void (int data)> eoc_delegate;
-
upd7002_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- template <typename... T> void set_get_analogue_callback(T &&... args) { m_get_analogue_cb.set(std::forward<T>(args)...); }
- template <typename... T> void set_eoc_callback(T &&... args) { m_eoc_cb.set(std::forward<T>(args)...); }
+ auto get_analogue_callback() { return m_get_analogue_cb.bind(); }
+ auto eoc_callback() { return m_eoc_cb.bind(); }
int eoc_r();
uint8_t read(offs_t offset);
void write(offs_t offset, uint8_t data);
protected:
- // device-level overrides
+ // device_t overrides
virtual void device_start() override ATTR_COLD;
virtual void device_reset() override ATTR_COLD;
- TIMER_CALLBACK_MEMBER(conversion_complete);
-
private:
- // internal state
+ TIMER_CALLBACK_MEMBER(conversion_complete);
/* Status Register
D0 and D1 define the currently selected input channel
@@ -53,21 +41,21 @@ private:
D6 0 = busy, 1 = not busy (~busy)
D7 0 = conversion completed, 1 = conversion not completed (~EOC)
*/
- int m_status;
+ uint8_t m_status;
/* High data byte
This byte contains the 8 most significant bits of the analogue to digital conversion. */
- int m_data1;
+ uint8_t m_data1;
/* Low data byte
- In 12 bit mode: Bits 7 to 4 define the four low order bits of the conversion.
+ In 12 bit mode: Bits 7 to 4 define the four low order bits of the conversion, bits 5 to 4 are meaningless.
In 8 bit mode. All bits 7 to 4 are inaccurate.
Bits 3 to 0 are always set to low. */
- int m_data0;
+ uint8_t m_data0;
/* temporary store of the next A to D conversion */
- int m_digitalvalue;
+ uint16_t m_digitalvalue;
/* this counter is used to check a full end of conversion has been reached
if the uPD7002 is half way through one conversion and a new conversion is requested
@@ -75,8 +63,8 @@ private:
only then at the end of the second conversion will the conversion complete function run */
int m_conversion_counter;
- get_analogue_delegate m_get_analogue_cb;
- eoc_delegate m_eoc_cb;
+ devcb_read16 m_get_analogue_cb;
+ devcb_write_line m_eoc_cb;
emu_timer *m_conversion_timer;
};
diff --git a/src/mame/acorn/bbc.h b/src/mame/acorn/bbc.h
index fd1abcb1b90..1a736229f1b 100644
--- a/src/mame/acorn/bbc.h
+++ b/src/mame/acorn/bbc.h
@@ -86,8 +86,6 @@ public:
uint8_t mos_r(offs_t offset);
void mos_w(offs_t offset, uint8_t data);
- int get_analogue_input(int channel_number);
-
void init_bbc();
void init_ltmp();
void init_cfa();
diff --git a/src/mame/acorn/bbc_m.cpp b/src/mame/acorn/bbc_m.cpp
index fee88ae9e8a..2bc75340c53 100644
--- a/src/mame/acorn/bbc_m.cpp
+++ b/src/mame/acorn/bbc_m.cpp
@@ -76,16 +76,6 @@ void bbc_state::mos_w(offs_t offset, uint8_t data)
}
-/**************************************
- Analogue Joystick
-**************************************/
-
-int bbc_state::get_analogue_input(int channel_number)
-{
- return m_analog->ch_r(channel_number) << 8;
-}
-
-
/***************************************
Cassette Motor
****************************************/
diff --git a/src/mame/acorn/bbcb.cpp b/src/mame/acorn/bbcb.cpp
index 7f39640101e..db2f7158edf 100644
--- a/src/mame/acorn/bbcb.cpp
+++ b/src/mame/acorn/bbcb.cpp
@@ -548,8 +548,8 @@ void bbcb_state::bbcb(machine_config &config)
centronics.set_output_latch(latch);
upd7002_device &upd7002(UPD7002(config, "upd7002", 16_MHz_XTAL / 16));
- upd7002.set_get_analogue_callback(FUNC(bbcb_state::get_analogue_input));
- upd7002.set_eoc_callback(m_sysvia, FUNC(via6522_device::write_cb1));
+ upd7002.get_analogue_callback().set(m_analog, FUNC(bbc_analogue_slot_device::ch_r));
+ upd7002.eoc_callback().set(m_sysvia, FUNC(via6522_device::write_cb1));
BBC_ANALOGUE_SLOT(config, m_analog, bbc_analogue_devices, nullptr);
m_analog->lpstb_handler().set(m_sysvia, FUNC(via6522_device::write_cb2));
diff --git a/src/mame/acorn/bbcbp.cpp b/src/mame/acorn/bbcbp.cpp
index 273fd5b240f..409d785356d 100644
--- a/src/mame/acorn/bbcbp.cpp
+++ b/src/mame/acorn/bbcbp.cpp
@@ -598,8 +598,8 @@ void bbcbp_state::bbcbp(machine_config &config)
centronics.set_output_latch(latch);
upd7002_device &upd7002(UPD7002(config, "upd7002", 16_MHz_XTAL / 16));
- upd7002.set_get_analogue_callback(FUNC(bbcbp_state::get_analogue_input));
- upd7002.set_eoc_callback(m_sysvia, FUNC(via6522_device::write_cb1));
+ upd7002.get_analogue_callback().set(m_analog, FUNC(bbc_analogue_slot_device::ch_r));
+ upd7002.eoc_callback().set(m_sysvia, FUNC(via6522_device::write_cb1));
BBC_ANALOGUE_SLOT(config, m_analog, bbc_analogue_devices, nullptr);
m_analog->lpstb_handler().set(m_sysvia, FUNC(via6522_device::write_cb2));
diff --git a/src/mame/acorn/bbcm.cpp b/src/mame/acorn/bbcm.cpp
index e1356f8a4ce..640f2d04358 100644
--- a/src/mame/acorn/bbcm.cpp
+++ b/src/mame/acorn/bbcm.cpp
@@ -770,8 +770,8 @@ void bbcm_state::bbcm(machine_config &config)
centronics.set_output_latch(latch);
upd7002_device &upd7002(UPD7002(config, "upd7002", 16_MHz_XTAL / 16));
- upd7002.set_get_analogue_callback(FUNC(bbcm_state::get_analogue_input));
- upd7002.set_eoc_callback(m_sysvia, FUNC(via6522_device::write_cb1));
+ upd7002.get_analogue_callback().set(m_analog, FUNC(bbc_analogue_slot_device::ch_r));
+ upd7002.eoc_callback().set(m_sysvia, FUNC(via6522_device::write_cb1));
BBC_ANALOGUE_SLOT(config, m_analog, bbc_analogue_devices, nullptr);
m_analog->lpstb_handler().set(m_sysvia, FUNC(via6522_device::write_cb2));