mirror of
https://github.com/holub/mame
synced 2025-05-24 14:56:21 +03:00
Fixed 6821pia and 7474, fixes for 6522via incoming. carpolo now works again. No whatsnew.
This commit is contained in:
parent
b22a727640
commit
0445eff6ba
@ -82,7 +82,27 @@ device_t *pia6821_device_config::alloc_device(running_machine &machine) const
|
||||
|
||||
void pia6821_device_config::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const pia6821_interface *intf = reinterpret_cast<const pia6821_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<pia6821_interface *>(this) = *intf;
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&m_in_a_func, 0, sizeof(m_in_a_func));
|
||||
memset(&m_in_b_func, 0, sizeof(m_in_b_func));
|
||||
memset(&m_in_ca1_func, 0, sizeof(m_in_ca1_func));
|
||||
memset(&m_in_cb1_func, 0, sizeof(m_in_cb1_func));
|
||||
memset(&m_in_ca2_func, 0, sizeof(m_in_ca2_func));
|
||||
memset(&m_in_cb2_func, 0, sizeof(m_in_cb2_func));
|
||||
memset(&m_out_a_func, 0, sizeof(m_out_a_func));
|
||||
memset(&m_out_b_func, 0, sizeof(m_out_b_func));
|
||||
memset(&m_out_ca2_func, 0, sizeof(m_out_ca2_func));
|
||||
memset(&m_out_cb2_func, 0, sizeof(m_out_cb2_func));
|
||||
memset(&m_irq_a_func, 0, sizeof(m_irq_a_func));
|
||||
memset(&m_irq_b_func, 0, sizeof(m_irq_b_func));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,6 +76,29 @@ device_t *ttl7474_device_config::alloc_device(running_machine &machine) const
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void ttl7474_device_config::device_config_complete()
|
||||
{
|
||||
m_target_tag = reinterpret_cast<const char *>(m_inline_data[INLINE_TARGET_TAG]);
|
||||
m_base_output_cb = reinterpret_cast<void (*)(device_t *device, INT32)>(m_inline_data[INLINE_OUTPUT_CB]);
|
||||
m_base_comp_output_cb = reinterpret_cast<void (*)(device_t *device, INT32)>(m_inline_data[INLINE_COMP_OUTPUT_CB]);
|
||||
|
||||
m_output_cb.type = DEVCB_TYPE_DEVICE;
|
||||
m_output_cb.tag = m_target_tag;
|
||||
m_output_cb.writeline = m_base_output_cb;
|
||||
|
||||
m_comp_output_cb.type = DEVCB_TYPE_DEVICE;
|
||||
m_comp_output_cb.tag = m_target_tag;
|
||||
m_comp_output_cb.writeline = m_base_comp_output_cb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
@ -97,7 +120,15 @@ ttl7474_device::ttl7474_device(running_machine &_machine, const ttl7474_device_c
|
||||
|
||||
void ttl7474_device::device_start()
|
||||
{
|
||||
register_globals();
|
||||
state_save_register_device_item(this, 0, m_clear);
|
||||
state_save_register_device_item(this, 0, m_preset);
|
||||
state_save_register_device_item(this, 0, m_clk);
|
||||
state_save_register_device_item(this, 0, m_d);
|
||||
state_save_register_device_item(this, 0, m_output);
|
||||
state_save_register_device_item(this, 0, m_output_comp);
|
||||
state_save_register_device_item(this, 0, m_last_clock);
|
||||
state_save_register_device_item(this, 0, m_last_output);
|
||||
state_save_register_device_item(this, 0, m_last_output_comp);
|
||||
|
||||
devcb_resolve_write_line(&m_output_cb, &m_config.m_output_cb, this);
|
||||
devcb_resolve_write_line(&m_comp_output_cb, &m_config.m_comp_output_cb, this);
|
||||
@ -112,6 +143,11 @@ void ttl7474_device::device_reset()
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// update - update internal state
|
||||
//-------------------------------------------------
|
||||
|
||||
void ttl7474_device::update()
|
||||
{
|
||||
if (!m_preset && m_clear) /* line 1 in truth table */
|
||||
@ -129,32 +165,34 @@ void ttl7474_device::update()
|
||||
m_output = 1;
|
||||
m_output_comp = 1;
|
||||
}
|
||||
else if (!m_last_clock && m_clock) /* line 4 in truth table */
|
||||
else if (!m_last_clock && m_clk) /* line 4 in truth table */
|
||||
{
|
||||
m_output = m_d;
|
||||
m_output_comp = !m_d;
|
||||
}
|
||||
|
||||
m_last_clock = m_clock;
|
||||
m_last_clock = m_clk;
|
||||
|
||||
|
||||
/* call callback if any of the outputs changed */
|
||||
if (m_output != m_last_output)
|
||||
{
|
||||
m_last_output = m_output;
|
||||
if (m_output_cb.write != NULL)
|
||||
devcb_call_write_line(&m_output_cb, m_output);
|
||||
}
|
||||
/* call callback if any of the outputs changed */
|
||||
if (m_output_comp != m_last_output_comp)
|
||||
{
|
||||
m_last_output_comp = m_output_comp;
|
||||
if (m_comp_output_cb.write != NULL)
|
||||
devcb_call_write_line(&m_comp_output_cb, m_output_comp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// clear_w - set the clear line state
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_DEVICE_HANDLER( ttl7474_clear_w )
|
||||
{
|
||||
downcast<ttl7474_device *>(device)->clear_w(state);
|
||||
@ -166,6 +204,11 @@ void ttl7474_device::clear_w(UINT8 state)
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// clear_w - set the clear line state
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_DEVICE_HANDLER( ttl7474_preset_w )
|
||||
{
|
||||
downcast<ttl7474_device *>(device)->preset_w(state);
|
||||
@ -177,6 +220,11 @@ void ttl7474_device::preset_w(UINT8 state)
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// clock_w - set the clock line state
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_DEVICE_HANDLER( ttl7474_clock_w )
|
||||
{
|
||||
downcast<ttl7474_device *>(device)->clock_w(state);
|
||||
@ -184,10 +232,15 @@ WRITE_LINE_DEVICE_HANDLER( ttl7474_clock_w )
|
||||
|
||||
void ttl7474_device::clock_w(UINT8 state)
|
||||
{
|
||||
m_clock = state & 1;
|
||||
m_clk = state & 1;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// d_w - set the d line state
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_DEVICE_HANDLER( ttl7474_d_w )
|
||||
{
|
||||
downcast<ttl7474_device *>(device)->d_w(state);
|
||||
@ -200,6 +253,10 @@ void ttl7474_device::d_w(UINT8 state)
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// output_r - get the output line state
|
||||
//-------------------------------------------------
|
||||
|
||||
READ_LINE_DEVICE_HANDLER( ttl7474_output_r )
|
||||
{
|
||||
return downcast<ttl7474_device *>(device)->output_r();
|
||||
@ -210,6 +267,11 @@ UINT8 ttl7474_device::output_r()
|
||||
return m_output;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// output_comp_r - get the output-compare line state
|
||||
//-----------------------------------------------------
|
||||
|
||||
READ_LINE_DEVICE_HANDLER( ttl7474_output_comp_r )
|
||||
{
|
||||
return downcast<ttl7474_device *>(device)->output_comp_r();
|
||||
@ -224,7 +286,7 @@ void ttl7474_device::init()
|
||||
{
|
||||
m_clear = 1;
|
||||
m_preset = 1;
|
||||
m_clock = 1;
|
||||
m_clk = 1;
|
||||
m_d = 1;
|
||||
|
||||
m_output = -1;
|
||||
@ -232,17 +294,4 @@ void ttl7474_device::init()
|
||||
m_last_output = -1;
|
||||
}
|
||||
|
||||
void ttl7474_device::register_globals()
|
||||
{
|
||||
state_save_register_device_item(this, 0, m_clear);
|
||||
state_save_register_device_item(this, 0, m_preset);
|
||||
state_save_register_device_item(this, 0, m_clock);
|
||||
state_save_register_device_item(this, 0, m_d);
|
||||
state_save_register_device_item(this, 0, m_output);
|
||||
state_save_register_device_item(this, 0, m_output_comp);
|
||||
state_save_register_device_item(this, 0, m_last_clock);
|
||||
state_save_register_device_item(this, 0, m_last_output);
|
||||
state_save_register_device_item(this, 0, m_last_output_comp);
|
||||
}
|
||||
|
||||
const device_type MACHINE_TTL7474 = ttl7474_device_config::static_alloc_device_config;
|
||||
|
@ -52,14 +52,19 @@
|
||||
|
||||
#define MDRV_7474_ADD(_tag, _target_tag, _output_cb, _comp_output_cb) \
|
||||
MDRV_DEVICE_ADD(_tag, MACHINE_TTL7474, 0) \
|
||||
MDRV_7474_TARGET_TAG(_target_tag) \
|
||||
MDRV_7474_OUTPUT_CB(_output_cb) \
|
||||
MDRV_7474_COMP_OUTPUT_CB(_comp_output_cb)
|
||||
|
||||
#define MDRV_7474_REPLACE(_tag, _target_tag, _output_cb, _comp_output_cb) \
|
||||
MDRV_DEVICE_REPLACE(_tag, TTL7474, 0) \
|
||||
MDRV_7474_TARGET_TAG(_target_tag) \
|
||||
MDRV_7474_OUTPUT_CB(_output_cb) \
|
||||
MDRV_7474_COMP_OUTPUT_CB(_comp_output_cb)
|
||||
|
||||
#define MDRV_7474_TARGET_TAG(_target_tag) \
|
||||
MDRV_DEVICE_INLINE_DATAPTR(ttl7474_device_config::INLINE_TARGET_TAG, _target_tag)
|
||||
|
||||
#define MDRV_7474_OUTPUT_CB(_cb) \
|
||||
MDRV_DEVICE_INLINE_DATAPTR(ttl7474_device_config::INLINE_OUTPUT_CB, _cb)
|
||||
|
||||
@ -86,19 +91,23 @@ public:
|
||||
static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
|
||||
virtual device_t *alloc_device(running_machine &machine) const;
|
||||
|
||||
// inline configuration indexes go here (none yet)
|
||||
|
||||
// indexes to inline data
|
||||
// inline configuration indexes go here
|
||||
enum
|
||||
{
|
||||
INLINE_TARGET_TAG,
|
||||
INLINE_OUTPUT_CB,
|
||||
INLINE_COMP_OUTPUT_CB
|
||||
};
|
||||
|
||||
protected:
|
||||
// device_config overrides (none yet)
|
||||
// device_config overrides
|
||||
virtual void device_config_complete();
|
||||
|
||||
// internal state goes here
|
||||
const char *m_target_tag;
|
||||
void (*m_base_output_cb)(device_t *device, INT32);
|
||||
void (*m_base_comp_output_cb)(device_t *device, INT32);
|
||||
|
||||
// internal state goes here (none yet)
|
||||
devcb_write_line m_output_cb;
|
||||
devcb_write_line m_comp_output_cb;
|
||||
};
|
||||
@ -140,7 +149,7 @@ private:
|
||||
/* inputs */
|
||||
UINT8 m_clear; /* pin 1/13 */
|
||||
UINT8 m_preset; /* pin 4/10 */
|
||||
UINT8 m_clock; /* pin 3/11 */
|
||||
UINT8 m_clk; /* pin 3/11 */
|
||||
UINT8 m_d; /* pin 2/12 */
|
||||
|
||||
/* outputs */
|
||||
@ -153,7 +162,6 @@ private:
|
||||
UINT8 m_last_output_comp;
|
||||
|
||||
void update();
|
||||
void register_globals();
|
||||
void init();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user