From e7f8f57303ed93e4e9da4e5f0b6f995fbb0acc68 Mon Sep 17 00:00:00 2001 From: Wilbert Pol Date: Thu, 1 Jan 2015 23:57:11 +0100 Subject: Some atari 8bit cassette work, not working yet (nw) --- src/emu/bus/a8sio/a8sio.h | 3 +++ src/emu/bus/a8sio/cassette.c | 48 +++++++++++++++++++++++++++++++++++++++++++- src/emu/bus/a8sio/cassette.h | 5 +++++ src/emu/sound/pokey.c | 12 +++++++++++ src/emu/sound/pokey.h | 1 + src/mess/drivers/atari400.c | 1 + 6 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/emu/bus/a8sio/a8sio.h b/src/emu/bus/a8sio/a8sio.h index ffe305ffd17..29e548946d4 100644 --- a/src/emu/bus/a8sio/a8sio.h +++ b/src/emu/bus/a8sio/a8sio.h @@ -45,6 +45,9 @@ MCFG_DEVICE_SLOT_INTERFACE(a8sio_cards, _def_slot, false) \ a8sio_slot_device::static_set_a8sio_slot(*device, _nbtag, _tag); +#define MCFG_A8SIO_DATA_IN_CB(_devcb) \ + devcb = &a8sio_device::set_data_in_callback(*device, DEVCB_##_devcb); + class a8sio_slot_device : public device_t, public device_slot_interface diff --git a/src/emu/bus/a8sio/cassette.c b/src/emu/bus/a8sio/cassette.c index 395633b2e36..cc2af705dad 100644 --- a/src/emu/bus/a8sio/cassette.c +++ b/src/emu/bus/a8sio/cassette.c @@ -26,10 +26,12 @@ TODO: //************************************************************************** const device_type A8SIO_CASSETTE = &device_creator; +const device_timer_id TIMER_CASSETTE_READ = 1; static MACHINE_CONFIG_FRAGMENT( cassette ) MCFG_CASSETTE_ADD("cassette") - MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_STOPPED) + //MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_STOPPED) + MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_PLAY) MCFG_CASSETTE_INTERFACE("atari8bit_cass") MACHINE_CONFIG_END @@ -46,6 +48,8 @@ a8sio_cassette_device::a8sio_cassette_device(const machine_config &mconfig, cons : device_t(mconfig, A8SIO_CASSETTE, "Atari 8 bit cassette", tag, owner, clock, "a8sio_cass", __FILE__) , device_a8sio_card_interface(mconfig, *this) , m_cassette(*this, "cassette") + , m_old_cass_signal(0) + , m_signal_count(0) { } @@ -53,12 +57,19 @@ a8sio_cassette_device::a8sio_cassette_device(const machine_config &mconfig, devi : device_t(mconfig, type, name, tag, owner, clock, shortname, source) , device_a8sio_card_interface(mconfig, *this) , m_cassette(*this, "cassette") + , m_old_cass_signal(0) + , m_signal_count(0) { } void a8sio_cassette_device::device_start() { set_a8sio_device(); + + save_item(NAME(m_old_cass_signal)); + save_item(NAME(m_signal_count)); + + m_read_timer = timer_alloc(TIMER_CASSETTE_READ); } void a8sio_cassette_device::device_reset() @@ -68,5 +79,40 @@ void a8sio_cassette_device::device_reset() WRITE_LINE_MEMBER( a8sio_cassette_device::motor_w ) { //printf("a8sio_cassette::motor_w %d\n", state); + if (!state) + { + m_cassette->change_state(CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); + m_read_timer->adjust(attotime::zero, 0, attotime::from_hz(44100)); + } + else + { + m_cassette->change_state(CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); + m_read_timer->reset(); + } +} + +void a8sio_cassette_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + switch (id) + { + case TIMER_CASSETTE_READ: + UINT8 cass_signal = m_cassette->input() < 0 ? 0 : 1; + + if (m_signal_count < 20) + { + m_signal_count++; + } + + if (cass_signal != m_old_cass_signal) + { + //printf("cass_signal: %d, count: %d, data: %d\n", cass_signal, m_signal_count, m_signal_count < 5 ? 1 : 0); + // ~4 kHz -> 0 + // ~5 kHz -> 1 + m_a8sio->data_in_w((m_signal_count < 5) ? 1 : 0); + m_signal_count = 0; + m_old_cass_signal = cass_signal; + } + break; + } } diff --git a/src/emu/bus/a8sio/cassette.h b/src/emu/bus/a8sio/cassette.h index 6388c16d196..d9b59568864 100644 --- a/src/emu/bus/a8sio/cassette.h +++ b/src/emu/bus/a8sio/cassette.h @@ -38,8 +38,13 @@ public: protected: virtual void device_start(); virtual void device_reset(); + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); required_device m_cassette; + emu_timer *m_read_timer; + + UINT8 m_old_cass_signal; + UINT8 m_signal_count; }; // device type definition diff --git a/src/emu/sound/pokey.c b/src/emu/sound/pokey.c index 2469a6a2126..8a7e831d32b 100644 --- a/src/emu/sound/pokey.c +++ b/src/emu/sound/pokey.c @@ -1055,6 +1055,18 @@ void pokey_device::write_internal(offs_t offset, UINT8 data) } +WRITE_LINE_MEMBER( pokey_device::sid_w ) +{ + if (state) + { + m_SKSTAT |= SK_SERIN; + } + else + { + m_SKSTAT &= ~SK_SERIN; + } +} + void pokey_device::serin_ready(int after) { timer_set(m_clock_period * after, 5, 0); diff --git a/src/emu/sound/pokey.h b/src/emu/sound/pokey.h index 7812830ab5d..dbfeb8326d6 100644 --- a/src/emu/sound/pokey.h +++ b/src/emu/sound/pokey.h @@ -234,6 +234,7 @@ public: UINT8 read(offs_t offset); void write(offs_t offset, UINT8 data); + DECLARE_WRITE_LINE_MEMBER( sid_w ); // pin 24 void serin_ready(int after); // analog output configuration diff --git a/src/mess/drivers/atari400.c b/src/mess/drivers/atari400.c index 9ffbf09ec93..c800cbdad83 100644 --- a/src/mess/drivers/atari400.c +++ b/src/mess/drivers/atari400.c @@ -2100,6 +2100,7 @@ static MACHINE_CONFIG_START( atari_common_nodac, a400_state ) MCFG_PIA_CB2_HANDLER(DEVWRITELINE("fdc", atari_fdc_device, pia_cb2_w)) MCFG_DEVICE_ADD("a8sio", A8SIO, 0) + MCFG_A8SIO_DATA_IN_CB(DEVWRITELINE("pokey", pokey_device, sid_w)) MCFG_A8SIO_SLOT_ADD("a8sio", "sio", NULL) /* sound hardware */ -- cgit v1.2.3