mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
bbcmc: Improved joyport slot interface (nw)
This commit is contained in:
parent
e64fb7f4ad
commit
4385097d99
@ -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,23 +80,12 @@ 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()
|
||||
{
|
||||
if (m_device)
|
||||
return m_device->cb_r();
|
||||
else
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
uint8_t bbc_joyport_slot_device::pb_r()
|
||||
{
|
||||
if (m_device)
|
||||
return m_device->pb_r();
|
||||
else
|
||||
return 0x1f;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_reset - device-specific reset
|
||||
@ -105,6 +96,30 @@ void bbc_joyport_slot_device::device_reset()
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// pb_r
|
||||
//-------------------------------------------------
|
||||
|
||||
READ8_MEMBER(bbc_joyport_slot_device::pb_r)
|
||||
{
|
||||
if (m_device)
|
||||
return m_device->pb_r(space, 0);
|
||||
else
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// pb_w
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE8_MEMBER(bbc_joyport_slot_device::pb_w)
|
||||
{
|
||||
if (m_device)
|
||||
m_device->pb_w(space, 0, data);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// SLOT_INTERFACE( bbc_joyport_devices )
|
||||
//-------------------------------------------------
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
**************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user