mirror of
https://github.com/holub/mame
synced 2025-04-25 01:40:16 +03:00
bitbanger_device: converted to devcb2 (nw)
Loading coco doesn't crash, but someone familiar with the system should test it. Thanks!
This commit is contained in:
parent
eb436c17f2
commit
8f416aa020
@ -9,16 +9,12 @@ null_modem_device::null_modem_device(const machine_config &mconfig, const char *
|
||||
{
|
||||
}
|
||||
|
||||
static bitbanger_config null_modem_image_config =
|
||||
{
|
||||
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, null_modem_device, read),
|
||||
BITBANGER_MODEM,
|
||||
BITBANGER_9600,
|
||||
BITBANGER_0PERCENT
|
||||
};
|
||||
|
||||
static MACHINE_CONFIG_FRAGMENT(null_modem_config)
|
||||
MCFG_BITBANGER_ADD("bitbanger", null_modem_image_config);
|
||||
MCFG_DEVICE_ADD("bitbanger", BITBANGER, 0)
|
||||
MCFG_BITBANGER_INPUT_CB(WRITELINE(null_modem_device, read)) /* callback */
|
||||
MCFG_BITBANGER_DEFAULT_MODE(BITBANGER_MODEM) /* default mode */
|
||||
MCFG_BITBANGER_DEFAULT_BAUD(BITBANGER_9600) /* default output baud */
|
||||
MCFG_BITBANGER_DEFAULT_TUNE(BITBANGER_0PERCENT) /* default fine tune adjustment */
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
machine_config_constructor null_modem_device::device_mconfig_additions() const
|
||||
|
@ -23,7 +23,8 @@ const device_type BITBANGER = &device_creator<bitbanger_device>;
|
||||
|
||||
bitbanger_device::bitbanger_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, BITBANGER, "Bitbanger", tag, owner, clock, "bitbanger", __FILE__),
|
||||
device_image_interface(mconfig, *this)
|
||||
device_image_interface(mconfig, *this),
|
||||
m_input_cb(*this)
|
||||
{
|
||||
m_output_timer = NULL;
|
||||
m_input_timer = NULL;
|
||||
@ -314,13 +315,10 @@ void bitbanger_device::device_start(void)
|
||||
m_input_buffer_cursor = 0;
|
||||
|
||||
/* defaults */
|
||||
m_mode = m_default_mode;
|
||||
m_baud = m_default_baud;
|
||||
m_tune = m_default_tune;
|
||||
m_current_baud = attotime::from_hz(baud_value());
|
||||
|
||||
/* callback */
|
||||
m_input_func.resolve(m_input_callback, *this);
|
||||
m_input_cb.resolve_safe();
|
||||
}
|
||||
|
||||
|
||||
@ -331,18 +329,6 @@ void bitbanger_device::device_start(void)
|
||||
|
||||
void bitbanger_device::device_config_complete(void)
|
||||
{
|
||||
const bitbanger_config *intf = reinterpret_cast<const bitbanger_config *>(static_config());
|
||||
if(intf != NULL)
|
||||
{
|
||||
*static_cast<bitbanger_config *>(this) = *intf;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&m_input_callback, 0, sizeof(m_input_callback));
|
||||
m_default_mode = 0;
|
||||
m_default_baud = 0;
|
||||
m_default_tune = 0;
|
||||
}
|
||||
update_names(BITBANGER, "bitbngr", "bitb");
|
||||
}
|
||||
|
||||
@ -443,7 +429,7 @@ void bitbanger_device::set_input_line(UINT8 line)
|
||||
if (m_current_input != line)
|
||||
{
|
||||
m_current_input = line;
|
||||
m_input_func(line ? ASSERT_LINE : CLEAR_LINE);
|
||||
m_input_cb(line ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,40 +55,35 @@ enum
|
||||
CONSTANTS
|
||||
***************************************************************************/
|
||||
|
||||
#define MCFG_BITBANGER_ADD(_tag, _intrf) \
|
||||
MCFG_DEVICE_ADD(_tag, BITBANGER, 0) \
|
||||
MCFG_DEVICE_CONFIG(_intrf)
|
||||
#define MCFG_BITBANGER_INPUT_CB(_devcb) \
|
||||
devcb = &bitbanger_device::set_input_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_BITBANGER_DEFAULT_MODE(_mode) \
|
||||
bitbanger_device::set_default_mode(*device, _mode);
|
||||
|
||||
#define MCFG_BITBANGER_DEFAULT_BAUD(_baud) \
|
||||
bitbanger_device::set_default_baud(*device, _baud);
|
||||
|
||||
#define MCFG_BITBANGER_DEFAULT_TUNE(_tune) \
|
||||
bitbanger_device::set_default_tune(*device, _tune);
|
||||
|
||||
/***************************************************************************
|
||||
TYPE DEFINITIONS
|
||||
***************************************************************************/
|
||||
|
||||
struct bitbanger_config
|
||||
{
|
||||
/* callback to driver */
|
||||
devcb_write_line m_input_callback;
|
||||
|
||||
/* emulating a printer or modem */
|
||||
int m_default_mode;
|
||||
|
||||
/* output bits per second */
|
||||
int m_default_baud;
|
||||
|
||||
/* fine tune adjustment to the baud */
|
||||
int m_default_tune;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class bitbanger_device : public device_t,
|
||||
public device_image_interface,
|
||||
public bitbanger_config
|
||||
public device_image_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
bitbanger_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
template<class _Object> static devcb2_base &set_input_callback(device_t &device, _Object object) { return downcast<bitbanger_device &>(device).m_input_cb.set_callback(object); }
|
||||
static void set_default_mode(device_t &device, int default_mode) { downcast<bitbanger_device &>(device).m_mode = default_mode; }
|
||||
static void set_default_baud(device_t &device, int default_baud) { downcast<bitbanger_device &>(device).m_baud = default_baud; }
|
||||
static void set_default_tune(device_t &device, int default_tune) { downcast<bitbanger_device &>(device).m_tune = default_tune; }
|
||||
|
||||
// image-level overrides
|
||||
virtual bool call_load();
|
||||
virtual void call_unload();
|
||||
@ -145,7 +140,8 @@ private:
|
||||
// variables
|
||||
emu_timer * m_output_timer;
|
||||
emu_timer * m_input_timer;
|
||||
devcb_resolved_write_line m_input_func;
|
||||
|
||||
devcb2_write_line m_input_cb; /* callback to driver */
|
||||
int m_output_value;
|
||||
int m_build_count;
|
||||
int m_build_byte;
|
||||
@ -153,9 +149,9 @@ private:
|
||||
attotime m_current_baud;
|
||||
UINT32 m_input_buffer_size;
|
||||
UINT32 m_input_buffer_cursor;
|
||||
int m_mode;
|
||||
int m_baud;
|
||||
int m_tune;
|
||||
int m_mode; /* emulating a printer or modem */
|
||||
int m_baud; /* output bits per second */
|
||||
int m_tune; /* fine tune adjustment to the baud */
|
||||
UINT8 m_current_input;
|
||||
UINT8 m_input_buffer[1000];
|
||||
};
|
||||
|
@ -293,7 +293,11 @@ static MACHINE_CONFIG_START( coco, coco12_state )
|
||||
MCFG_SAM6883_ADD(SAM_TAG, XTAL_3_579545MHz, coco12_state::sam6883_config)
|
||||
MCFG_SAM6883_RES_CALLBACK(READ8(coco12_state, sam_read))
|
||||
MCFG_CASSETTE_ADD("cassette", coco_state::coco_cassette_interface)
|
||||
MCFG_BITBANGER_ADD(BITBANGER_TAG, coco_state::coco_bitbanger_config)
|
||||
MCFG_DEVICE_ADD(BITBANGER_TAG, BITBANGER, 0)
|
||||
MCFG_BITBANGER_INPUT_CB(WRITELINE(coco_state, bitbanger_callback)) /* callback */
|
||||
MCFG_BITBANGER_DEFAULT_MODE(BITBANGER_PRINTER) /* default mode */
|
||||
MCFG_BITBANGER_DEFAULT_BAUD(BITBANGER_600) /* default output baud */
|
||||
MCFG_BITBANGER_DEFAULT_TUNE(BITBANGER_0PERCENT) /* default fine tune adjustment */
|
||||
MCFG_COCO_CARTRIDGE_ADD(CARTRIDGE_TAG, coco_state::cartridge_config, coco_cart, "pak")
|
||||
|
||||
// video hardware
|
||||
|
@ -262,7 +262,11 @@ static MACHINE_CONFIG_START( coco3, coco3_state )
|
||||
MCFG_PIA_IRQB_HANDLER(WRITELINE(coco_state, pia1_firq_b))
|
||||
|
||||
MCFG_CASSETTE_ADD("cassette", coco_state::coco_cassette_interface)
|
||||
MCFG_BITBANGER_ADD(BITBANGER_TAG, coco_state::coco_bitbanger_config)
|
||||
MCFG_DEVICE_ADD(BITBANGER_TAG, BITBANGER, 0)
|
||||
MCFG_BITBANGER_INPUT_CB(WRITELINE(coco_state, bitbanger_callback)) /* callback */
|
||||
MCFG_BITBANGER_DEFAULT_MODE(BITBANGER_PRINTER) /* default mode */
|
||||
MCFG_BITBANGER_DEFAULT_BAUD(BITBANGER_600) /* default output baud */
|
||||
MCFG_BITBANGER_DEFAULT_TUNE(BITBANGER_0PERCENT) /* default fine tune adjustment */
|
||||
MCFG_COCO_CARTRIDGE_ADD(CARTRIDGE_TAG, coco_state::cartridge_config, coco_cart, "fdcv11")
|
||||
MCFG_COCO_VHD_ADD(VHD0_TAG)
|
||||
MCFG_COCO_VHD_ADD(VHD1_TAG)
|
||||
|
@ -97,7 +97,6 @@ public:
|
||||
optional_device<coco_vhd_image_device> m_vhd_1;
|
||||
|
||||
static const cococart_interface cartridge_config;
|
||||
static const bitbanger_config coco_bitbanger_config;
|
||||
static const cassette_interface coco_cassette_interface;
|
||||
|
||||
// driver update handlers
|
||||
@ -135,6 +134,9 @@ public:
|
||||
|
||||
// floating bus
|
||||
DECLARE_READ8_MEMBER( floating_bus_read ) { return floating_bus_read(); }
|
||||
|
||||
// bitbanger
|
||||
DECLARE_WRITE_LINE_MEMBER( bitbanger_callback );
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
@ -214,7 +216,6 @@ private:
|
||||
void poll_hires_joystick(void);
|
||||
void update_cassout(int cassout);
|
||||
void update_prinout(bool prinout);
|
||||
DECLARE_WRITE_LINE_MEMBER( bitbanger_callback );
|
||||
void diecom_lightgun_clock(void);
|
||||
|
||||
// thin wrappers for PIA output
|
||||
|
@ -1039,22 +1039,6 @@ WRITE_LINE_MEMBER( coco_state::bitbanger_callback )
|
||||
bitbanger_changed(state ? true : false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// bitbanger_config
|
||||
//-------------------------------------------------
|
||||
|
||||
const bitbanger_config coco_state::coco_bitbanger_config =
|
||||
{
|
||||
DEVCB_DRIVER_LINE_MEMBER(coco_state, bitbanger_callback), /* callback */
|
||||
BITBANGER_PRINTER, /* default mode */
|
||||
BITBANGER_600, /* default output baud */
|
||||
BITBANGER_0PERCENT /* default fine tune adjustment */
|
||||
};
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// poll_hires_joystick
|
||||
//-------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user