mirror of
https://github.com/holub/mame
synced 2025-10-04 16:34:53 +03:00

* Make more #include guards follow standard format - using MAME_ as the prefix makes it easy to see which ones come from our code in a preprocessor dump, and having both src/devices/machine/foo.h and src/mame/machine/foo.h causes issues anyway * Get #include "emu.h" out of headers - it should only be the first thing in a complilation unit or we get differences in behaviour with PCH on/off * Add out-of-line destructors to some devices - it forces the compiler to instantiate the vtable in a certain location and avoids some non-deterministic compiler behaviours
101 lines
2.7 KiB
C++
101 lines
2.7 KiB
C++
// license:BSD-3-Clause
|
|
// copyright-holders:Nigel Barnes
|
|
/**********************************************************************
|
|
|
|
Acorn Cassette Interface
|
|
|
|
Part No. 100,001
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
#include "emu.h"
|
|
#include "cass.h"
|
|
|
|
|
|
//**************************************************************************
|
|
// DEVICE DEFINITIONS
|
|
//**************************************************************************
|
|
|
|
DEFINE_DEVICE_TYPE(ACORN_CASS, acorn_cass_device, "acorn_cass", "Acorn Cassette Interface")
|
|
|
|
|
|
//-------------------------------------------------
|
|
// device_add_mconfig - add device configuration
|
|
//-------------------------------------------------
|
|
|
|
MACHINE_CONFIG_START(acorn_cass_device::device_add_mconfig)
|
|
/* sound hardware */
|
|
SPEAKER(config, "mono").front_center();
|
|
WAVE(config, "wave", "cassette").add_route(ALL_OUTPUTS, "mono", 0.25);
|
|
|
|
CASSETTE(config, "cassette", 0);
|
|
MCFG_TIMER_DRIVER_ADD_PERIODIC("cass_c", acorn_cass_device, cass_c, attotime::from_hz(4800))
|
|
MCFG_TIMER_DRIVER_ADD_PERIODIC("cass_p", acorn_cass_device, cass_p, attotime::from_hz(40000))
|
|
MACHINE_CONFIG_END
|
|
|
|
|
|
//**************************************************************************
|
|
// LIVE DEVICE
|
|
//**************************************************************************
|
|
|
|
//-------------------------------------------------
|
|
// acorn_cass_device - constructor
|
|
//-------------------------------------------------
|
|
|
|
acorn_cass_device::acorn_cass_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
|
: device_t(mconfig, ACORN_CASS, tag, owner, clock)
|
|
, device_acorn_bus_interface(mconfig, *this)
|
|
, m_cass(*this, "cassette")
|
|
{
|
|
}
|
|
|
|
|
|
//-------------------------------------------------
|
|
// device_start - device-specific startup
|
|
//-------------------------------------------------
|
|
|
|
void acorn_cass_device::device_start()
|
|
{
|
|
}
|
|
|
|
|
|
//**************************************************************************
|
|
// IMPLEMENTATION
|
|
//**************************************************************************
|
|
|
|
WRITE_LINE_MEMBER(acorn_cass_device::cass_w)
|
|
{
|
|
m_cass_state = state;
|
|
}
|
|
|
|
TIMER_DEVICE_CALLBACK_MEMBER(acorn_cass_device::cass_c)
|
|
{
|
|
m_cass_data[3]++;
|
|
|
|
if (m_cass_state != m_cassold)
|
|
{
|
|
m_cass_data[3] = 0;
|
|
m_cassold = m_cass_state;
|
|
}
|
|
|
|
if (m_cass_state)
|
|
m_cass->output(BIT(m_cass_data[3], 0) ? -1.0 : +1.0); // 2400Hz
|
|
else
|
|
m_cass->output(BIT(m_cass_data[3], 1) ? -1.0 : +1.0); // 1200Hz
|
|
}
|
|
|
|
TIMER_DEVICE_CALLBACK_MEMBER(acorn_cass_device::cass_p)
|
|
{
|
|
/* cassette - turn 1200/2400Hz to a bit */
|
|
m_cass_data[1]++;
|
|
uint8_t cass_ws = (m_cass->input() > +0.03) ? 1 : 0;
|
|
|
|
if (cass_ws != m_cass_data[0])
|
|
{
|
|
m_cass_data[0] = cass_ws;
|
|
//m_bus->write_pb7(m_cass_data[1] < 12);
|
|
m_cass_data[1] = 0;
|
|
}
|
|
}
|