summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Nigel Barnes <Pernod70@users.noreply.github.com>2018-03-13 16:49:22 +0000
committer Nigel Barnes <Pernod70@users.noreply.github.com>2018-03-20 21:34:22 +0000
commit4385097d994de5aedf74848d31810a454181781b (patch)
tree45b9f1a7bdb494dbacd126d358a49fe0f9c8d7d3
parente64fb7f4aded01b343081c48103a491f36fe1ee9 (diff)
bbcmc: Improved joyport slot interface (nw)
-rw-r--r--src/devices/bus/bbc/joyport/joyport.cpp37
-rw-r--r--src/devices/bus/bbc/joyport/joyport.h27
-rw-r--r--src/devices/bus/bbc/joyport/joystick.cpp11
-rw-r--r--src/devices/bus/bbc/joyport/joystick.h3
-rw-r--r--src/mame/drivers/bbc.cpp11
-rw-r--r--src/mame/includes/bbc.h2
-rw-r--r--src/mame/machine/bbc.cpp26
7 files changed, 64 insertions, 53 deletions
diff --git a/src/devices/bus/bbc/joyport/joyport.cpp b/src/devices/bus/bbc/joyport/joyport.cpp
index cbbe4a49bbd..2a3d3d144b6 100644
--- a/src/devices/bus/bbc/joyport/joyport.cpp
+++ b/src/devices/bus/bbc/joyport/joyport.cpp
@@ -52,7 +52,9 @@ device_bbc_joyport_interface::~device_bbc_joyport_interface()
bbc_joyport_slot_device::bbc_joyport_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, BBC_JOYPORT_SLOT, tag, owner, clock),
device_slot_interface(mconfig, *this),
- m_device(nullptr)
+ m_device(nullptr),
+ m_cb1_handler(*this),
+ m_cb2_handler(*this)
{
}
@@ -78,30 +80,43 @@ void bbc_joyport_slot_device::device_start()
m_device = dynamic_cast<device_bbc_joyport_interface *>(carddev);
if (carddev && !m_device)
fatalerror("Card device %s (%s) does not implement device_bbc_joyport_interface\n", carddev->tag(), carddev->name());
+
+ // resolve callbacks
+ m_cb1_handler.resolve_safe();
+ m_cb2_handler.resolve_safe();
}
-uint8_t bbc_joyport_slot_device::cb_r()
+
+//-------------------------------------------------
+// device_reset - device-specific reset
+//-------------------------------------------------
+
+void bbc_joyport_slot_device::device_reset()
{
- if (m_device)
- return m_device->cb_r();
- else
- return 0xff;
}
-uint8_t bbc_joyport_slot_device::pb_r()
+
+//-------------------------------------------------
+// pb_r
+//-------------------------------------------------
+
+READ8_MEMBER(bbc_joyport_slot_device::pb_r)
{
if (m_device)
- return m_device->pb_r();
+ return m_device->pb_r(space, 0);
else
- return 0x1f;
+ return 0xff;
}
+
//-------------------------------------------------
-// device_reset - device-specific reset
+// pb_w
//-------------------------------------------------
-void bbc_joyport_slot_device::device_reset()
+WRITE8_MEMBER(bbc_joyport_slot_device::pb_w)
{
+ if (m_device)
+ m_device->pb_w(space, 0, data);
}
diff --git a/src/devices/bus/bbc/joyport/joyport.h b/src/devices/bus/bbc/joyport/joyport.h
index beff32079cb..9371ee248d8 100644
--- a/src/devices/bus/bbc/joyport/joyport.h
+++ b/src/devices/bus/bbc/joyport/joyport.h
@@ -37,10 +37,16 @@
// INTERFACE CONFIGURATION MACROS
//**************************************************************************
-#define MCFG_COMPACT_JOYPORT_ADD( _tag, _slot_intf, _def_slot) \
+#define MCFG_BBC_JOYPORT_ADD( _tag, _slot_intf, _def_slot) \
MCFG_DEVICE_ADD(_tag, BBC_JOYPORT_SLOT, 0) \
MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
+#define MCFG_BBC_JOYPORT_CB1_HANDLER(_devcb) \
+ devcb = &downcast<bbc_joyport_slot_device &>(*device).set_cb1_handler(DEVCB_##_devcb);
+
+#define MCFG_BBC_JOYPORT_CB2_HANDLER(_devcb) \
+ devcb = &downcast<bbc_joyport_slot_device &>(*device).set_cb2_handler(DEVCB_##_devcb);
+
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
@@ -55,8 +61,15 @@ public:
// construction/destruction
bbc_joyport_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- uint8_t cb_r();
- uint8_t pb_r();
+ // callbacks
+ template <class Object> devcb_base &set_cb1_handler(Object &&cb) { return m_cb1_handler.set_callback(std::forward<Object>(cb)); }
+ template <class Object> devcb_base &set_cb2_handler(Object &&cb) { return m_cb2_handler.set_callback(std::forward<Object>(cb)); }
+
+ DECLARE_WRITE_LINE_MEMBER(cb1_w) { m_cb1_handler(state); }
+ DECLARE_WRITE_LINE_MEMBER(cb2_w) { m_cb2_handler(state); }
+
+ DECLARE_READ8_MEMBER(pb_r);
+ DECLARE_WRITE8_MEMBER(pb_w);
protected:
// device-level overrides
@@ -65,6 +78,10 @@ protected:
virtual void device_reset() override;
device_bbc_joyport_interface *m_device;
+
+private:
+ devcb_write_line m_cb1_handler;
+ devcb_write_line m_cb2_handler;
};
@@ -76,8 +93,8 @@ public:
// construction/destruction
virtual ~device_bbc_joyport_interface();
- virtual uint8_t cb_r() { return 0xff; }
- virtual uint8_t pb_r() { return 0x1f; }
+ virtual DECLARE_READ8_MEMBER(pb_r) { return 0xff; }
+ virtual DECLARE_WRITE8_MEMBER(pb_w) { }
protected:
device_bbc_joyport_interface(const machine_config &mconfig, device_t &device);
diff --git a/src/devices/bus/bbc/joyport/joystick.cpp b/src/devices/bus/bbc/joyport/joystick.cpp
index ee02a64a56a..5f4047c13a3 100644
--- a/src/devices/bus/bbc/joyport/joystick.cpp
+++ b/src/devices/bus/bbc/joyport/joystick.cpp
@@ -16,6 +16,10 @@
DEFINE_DEVICE_TYPE(BBCMC_JOYSTICK, bbcmc_joystick_device, "bbcmc_joystick", "Master Compact Joystick")
+//-------------------------------------------------
+// INPUT_PORTS( joystick )
+//-------------------------------------------------
+
static INPUT_PORTS_START( joystick )
PORT_START("JOY")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Fire")
@@ -74,12 +78,7 @@ void bbcmc_joystick_device::device_reset()
// IMPLEMENTATION
//**************************************************************************
-uint8_t bbcmc_joystick_device::cb_r()
-{
- return 0xff;
-}
-
-uint8_t bbcmc_joystick_device::pb_r()
+READ8_MEMBER(bbcmc_joystick_device::pb_r)
{
return m_joy->read();
}
diff --git a/src/devices/bus/bbc/joyport/joystick.h b/src/devices/bus/bbc/joyport/joystick.h
index bfbc67543df..0e9cea22716 100644
--- a/src/devices/bus/bbc/joyport/joystick.h
+++ b/src/devices/bus/bbc/joyport/joystick.h
@@ -36,8 +36,7 @@ protected:
virtual void device_start() override;
virtual void device_reset() override;
- virtual uint8_t cb_r() override;
- virtual uint8_t pb_r() override;
+ virtual DECLARE_READ8_MEMBER(pb_r) override;
private:
required_ioport m_joy;
diff --git a/src/mame/drivers/bbc.cpp b/src/mame/drivers/bbc.cpp
index 70369ea08f5..c7e216ae333 100644
--- a/src/mame/drivers/bbc.cpp
+++ b/src/mame/drivers/bbc.cpp
@@ -1648,6 +1648,12 @@ MACHINE_CONFIG_START(bbc_state::bbcmc)
MCFG_MACHINE_START_OVERRIDE(bbc_state, bbcmc)
MCFG_MACHINE_RESET_OVERRIDE(bbc_state, bbcmc)
+ /* user via */
+ MCFG_DEVICE_MODIFY("via6522_1")
+ // TODO: Joyport connected to PB0-PB4 only. PB5-PB7 are expansion port.
+ MCFG_VIA6522_READPB_HANDLER(DEVREAD8("joyport", bbc_joyport_slot_device, pb_r))
+ MCFG_VIA6522_WRITEPB_HANDLER(DEVWRITE8("joyport", bbc_joyport_slot_device, pb_w))
+
/* cartridge sockets */
MCFG_DEVICE_REMOVE("exp_rom1")
MCFG_DEVICE_REMOVE("exp_rom2")
@@ -1664,8 +1670,11 @@ MACHINE_CONFIG_START(bbc_state::bbcmc)
MCFG_SOFTWARE_LIST_COMPATIBLE_ADD("flop_ls_pro128s", "pro128s_flop")
/* expansion ports */
+ MCFG_BBC_JOYPORT_ADD("joyport", bbc_joyport_devices, "joystick")
+ MCFG_BBC_JOYPORT_CB1_HANDLER(DEVWRITELINE("via6522_1", via6522_device, write_cb1))
+ MCFG_BBC_JOYPORT_CB2_HANDLER(DEVWRITELINE("via6522_1", via6522_device, write_cb2))
+
MCFG_DEVICE_REMOVE("analogue")
- MCFG_COMPACT_JOYPORT_ADD("joyport", bbc_joyport_devices, "joystick")
MCFG_DEVICE_REMOVE("intube")
MCFG_DEVICE_REMOVE("extube")
MACHINE_CONFIG_END
diff --git a/src/mame/includes/bbc.h b/src/mame/includes/bbc.h
index b78520e6f8c..49d014ea4b4 100644
--- a/src/mame/includes/bbc.h
+++ b/src/mame/includes/bbc.h
@@ -178,8 +178,6 @@ public:
DECLARE_WRITE8_MEMBER(bbcb_via_system_write_portb);
DECLARE_READ8_MEMBER(bbcb_via_system_read_porta);
DECLARE_READ8_MEMBER(bbcb_via_system_read_portb);
- DECLARE_READ8_MEMBER(bbcb_via_user_read_portb);
- DECLARE_WRITE8_MEMBER(bbcb_via_user_write_portb);
DECLARE_WRITE_LINE_MEMBER(bbc_hsync_changed);
DECLARE_WRITE_LINE_MEMBER(bbc_vsync_changed);
DECLARE_WRITE_LINE_MEMBER(bbc_de_changed);
diff --git a/src/mame/machine/bbc.cpp b/src/mame/machine/bbc.cpp
index 943ae075275..fe7b66257a3 100644
--- a/src/mame/machine/bbc.cpp
+++ b/src/mame/machine/bbc.cpp
@@ -1017,32 +1017,6 @@ READ8_MEMBER(bbc_state::bbcb_via_system_read_portb)
}
-/**********************************************************************
-USER VIA
-Port A output is buffered before being connected to the printer connector.
-This means that they can only be operated as output lines.
-CA1 is pulled high by a 4K7 resistor. CA1 normally acts as an acknowledge
-line when a printer is used. CA2 is buffered so that it has become an open
-collector output only. It usually acts as the printer strobe line.
-***********************************************************************/
-
-/* USER VIA 6522 port B is connected to the BBC user port */
-READ8_MEMBER(bbc_state::bbcb_via_user_read_portb)
-{
- // D0 of portb is joystick FIRE (Compact)
- // D1 of portb is joystick LEFT (Compact)
- // D2 of portb is joystick DOWN (Compact)
- // D3 of portb is joystick UP (Compact)
- // D4 of portb is joystick RIGHT (Compact)
- return ((m_joyport ? m_joyport->pb_r() : 0x1f) | 0xe0);
-}
-
-WRITE8_MEMBER(bbc_state::bbcb_via_user_write_portb)
-{
- m_userport = data;
-}
-
-
/**************************************
BBC Joystick Support
**************************************/