mdcr: Moved philips/p2000t_mdcr.cpp->machine/mdcr.cpp to allow use with other machines.

This commit is contained in:
Nigel Barnes 2022-12-12 18:47:14 +00:00
parent 8d06c14709
commit e09c883434
4 changed files with 36 additions and 19 deletions

View File

@ -2398,6 +2398,18 @@ if (MACHINES["MCF5206E"]~=null) then
}
end
---------------------------------------------------
--
--@src/devices/machine/mdcr.h,MACHINES["MDCR"] = true
---------------------------------------------------
if (MACHINES["MDCR"]~=null) then
files {
MAME_DIR .. "src/devices/machine/mdcr.cpp",
MAME_DIR .. "src/devices/machine/mdcr.h",
}
end
---------------------------------------------------
--
--@src/devices/machine/meters.h,MACHINES["METERS"] = true

View File

@ -2,15 +2,15 @@
// copyright-holders:Erwin Jansen
/**********************************************************************
Philips P2000T Mini Digital Cassette Recorder emulation
Philips Mini Digital Cassette Recorder emulation
**********************************************************************/
#include "emu.h"
#include "p2000t_mdcr.h"
#include "mdcr.h"
#include "formats/p2000t_cas.h"
DEFINE_DEVICE_TYPE(MDCR, mdcr_device, "mdcr", "Philips Mini DCR")
DEFINE_DEVICE_TYPE(MDCR, mdcr_device, "mdcr", "Philips Mini-DCR")
READ_LINE_MEMBER(mdcr_device::rdc)
{
@ -86,21 +86,23 @@ WRITE_LINE_MEMBER(mdcr_device::wdc)
void mdcr_device::device_add_mconfig(machine_config &config)
{
CASSETTE(config, m_cassette);
m_cassette->set_default_state(CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED |
CASSETTE_SPEAKER_MUTED);
m_cassette->set_default_state(CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_MUTED);
m_cassette->set_interface("p2000_cass");
m_cassette->set_formats(p2000t_cassette_formats);
}
mdcr_device::mdcr_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, MDCR, tag, owner, clock)
, m_cassette(*this, "cassette")
, m_read_timer(nullptr)
: device_t(mconfig, MDCR, tag, owner, clock)
, m_rdc_cb(*this)
, m_cassette(*this, "cassette")
, m_read_timer(nullptr)
{
}
void mdcr_device::device_start()
{
m_rdc_cb.resolve_safe();
m_read_timer = timer_alloc(FUNC(mdcr_device::read_timer_tick), this);
m_read_timer->adjust(attotime::from_hz(44100), 0, attotime::from_hz(44100));
@ -148,6 +150,7 @@ TIMER_CALLBACK_MEMBER(mdcr_device::read_timer_tick)
m_rda = m_phase_decoder.pull_bit();
}
}
m_rdc_cb(m_rdc);
m_last_tape_time = m_cassette->get_position();
}
@ -184,8 +187,7 @@ void mdcr_device::forward()
m_fwd = true;
m_cassette->set_motor(true);
m_cassette->change_state(m_recording ? CASSETTE_RECORD : CASSETTE_PLAY,
CASSETTE_MASK_UISTATE);
m_cassette->change_state(m_recording ? CASSETTE_RECORD : CASSETTE_PLAY, CASSETTE_MASK_UISTATE);
m_cassette->go_forward();
}
@ -198,8 +200,7 @@ void mdcr_device::stop()
bool mdcr_device::tape_start_or_end()
{
auto pos = m_cassette->get_position();
auto bet = m_cassette->motor_on() &&
(pos <= 0 || pos >= m_cassette->get_length());
auto bet = m_cassette->motor_on() && (pos <= 0 || pos >= m_cassette->get_length());
// Reset phase decoder at tape start/end.
if (bet)

View File

@ -2,7 +2,7 @@
// copyright-holders:Erwin Jansen
/**********************************************************************
Philips P2000t Mini Digital Cassette Recorder Emulation
Philips Mini Digital Cassette Recorder Emulation
**********************************************************************
@ -16,8 +16,8 @@
**********************************************************************/
#ifndef MAME_MACHINE_P2000T_MDCR_H
#define MAME_MACHINE_P2000T_MDCR_H
#ifndef MAME_MACHINE_MDCR_H
#define MAME_MACHINE_MDCR_H
#pragma once
@ -34,7 +34,7 @@
class mdcr_device : public device_t
{
public:
mdcr_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock);
mdcr_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0);
/// \brief The read clock, switches state when a bit is available.
///
@ -71,6 +71,8 @@ public:
/// True if the current wda should be written to tape.
DECLARE_WRITE_LINE_MEMBER(wdc);
auto rdc_cb() { return m_rdc_cb.bind(); }
protected:
virtual void device_start() override;
virtual void device_pre_save() override;
@ -80,6 +82,8 @@ protected:
TIMER_CALLBACK_MEMBER(read_timer_tick);
private:
devcb_write_line m_rdc_cb;
/// \brief A Phase Decoder used in a Philips MDCR220 Mini Cassette Recorder
///
/// A phase decoder is capable of converting a signal stream into a
@ -125,7 +129,7 @@ private:
// add a bit and reset the current clock.
void add_bit(bool bit);
// tries to sync up the signal and calculate the clockperiod.
// tries to sync up the signal and calculate the clock period.
bool sync_signal(bool state);
// y * (1 - tolerance) < x < y * (1 + tolerance)
@ -174,4 +178,4 @@ private:
DECLARE_DEVICE_TYPE(MDCR, mdcr_device)
#endif // MAME_MACHINE_P2000T_MDCR_H
#endif // MAME_MACHINE_MDCR_H

View File

@ -14,7 +14,7 @@
#include "cpu/z80/z80.h"
#include "sound/spkrdev.h"
#include "video/saa5050.h"
#include "p2000t_mdcr.h"
#include "machine/mdcr.h"
#include "machine/ram.h"
#include "emupal.h"