summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/cat702.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/machine/cat702.c')
-rw-r--r--src/mame/machine/cat702.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/mame/machine/cat702.c b/src/mame/machine/cat702.c
index 8c362e65267..9c322e0ff52 100644
--- a/src/mame/machine/cat702.c
+++ b/src/mame/machine/cat702.c
@@ -87,17 +87,20 @@
const device_type CAT702 = &device_creator<cat702_device>;
cat702_device::cat702_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
- psxsiodev_device(mconfig, CAT702, "CAT702", tag, owner, clock, "cat702", __FILE__)
+ device_t(mconfig, CAT702, "CAT702", tag, owner, clock, "cat702", __FILE__),
+ m_dataout_handler(*this)
{
}
void cat702_device::device_start()
{
- psxsiodev_device::device_start();
+ m_dataout_handler.resolve_safe();
save_item(NAME(m_select));
save_item(NAME(m_state));
save_item(NAME(m_bit));
+
+ m_dataout_handler(1);
}
// Given the value for x7..x0 and linear transform coefficients a7..a0
@@ -159,29 +162,29 @@ void cat702_device::init(const UINT8 *transform)
m_transform = transform;
}
-void cat702_device::select(int select)
+WRITE_LINE_MEMBER(cat702_device::write_select)
{
- if (m_select != select)
+ if (m_select != state)
{
- if (!select)
+ if (!state)
{
m_state = 0xfc;
m_bit = 0;
}
else
{
- data_out(0, PSX_SIO_IN_DATA);
+ m_dataout_handler(1);
}
- m_select = select;
+ m_select = state;
}
}
-void cat702_device::data_in( int data, int mask )
+WRITE_LINE_MEMBER(cat702_device::write_clock)
{
static const UINT8 initial_sbox[8] = { 0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x7f };
- if ( !m_select && (mask & PSX_SIO_OUT_CLOCK) != 0 && (data & PSX_SIO_OUT_CLOCK) == 0)
+ if (!state && m_clock && !m_select)
{
if (m_bit==0)
{
@@ -190,12 +193,22 @@ void cat702_device::data_in( int data, int mask )
}
// Compute the output and change the state
- data_out(((m_state >> m_bit) & 1) != 0 ? PSX_SIO_IN_DATA : 0, PSX_SIO_IN_DATA);
+ m_dataout_handler(((m_state >> m_bit) & 1) != 0);
+ }
- if((data & PSX_SIO_OUT_DATA)==0)
+ if (state && !m_clock && !m_select)
+ {
+ if (!m_datain)
apply_bit_sbox(m_bit);
m_bit++;
m_bit&=7;
}
+
+ m_clock = state;
+}
+
+WRITE_LINE_MEMBER(cat702_device::write_datain)
+{
+ m_datain = state;
}