s14001a_new_device: small update, savestates

This commit is contained in:
hap 2016-01-19 12:21:01 +01:00
parent 4fc9eca8a8
commit 74b9d95055
2 changed files with 62 additions and 12 deletions

View File

@ -24,6 +24,8 @@ s14001a_new_device::s14001a_new_device(const machine_config &mconfig, std::strin
// device_start - device-specific startup
//-------------------------------------------------
ALLOW_SAVE_TYPE(s14001a_new_device::states); // allow save_item on a non-fundamental type
void s14001a_new_device::device_start()
{
m_stream = machine().sound().stream_alloc(*this, 0, 1, clock() ? clock() : machine().sample_rate());
@ -32,7 +34,51 @@ void s14001a_new_device::device_start()
m_ext_read_handler.resolve();
m_bsy_handler.resolve();
// note: zerofill is done already by MAME core
ClearStatistics();
m_uOutputP1 = m_uOutputP2 = 7;
// register for savestates
save_item(NAME(m_bPhase1));
save_item(NAME(m_uStateP1));
save_item(NAME(m_uStateP2));
save_item(NAME(m_uDAR13To05P1));
save_item(NAME(m_uDAR13To05P2));
save_item(NAME(m_uDAR04To00P1));
save_item(NAME(m_uDAR04To00P2));
save_item(NAME(m_uCWARP1));
save_item(NAME(m_uCWARP2));
save_item(NAME(m_bStopP1));
save_item(NAME(m_bStopP2));
save_item(NAME(m_bVoicedP1));
save_item(NAME(m_bVoicedP2));
save_item(NAME(m_bSilenceP1));
save_item(NAME(m_bSilenceP2));
save_item(NAME(m_uLengthP1));
save_item(NAME(m_uLengthP2));
save_item(NAME(m_uXRepeatP1));
save_item(NAME(m_uXRepeatP2));
save_item(NAME(m_uDeltaOldP1));
save_item(NAME(m_uDeltaOldP2));
save_item(NAME(m_uOutputP1));
save_item(NAME(m_bDAR04To00CarryP2));
save_item(NAME(m_bPPQCarryP2));
save_item(NAME(m_bRepeatCarryP2));
save_item(NAME(m_bLengthCarryP2));
save_item(NAME(m_RomAddrP1));
save_item(NAME(m_uOutputP2));
save_item(NAME(m_uRomAddrP2));
save_item(NAME(m_bBusyP1));
save_item(NAME(m_bStart));
save_item(NAME(m_uWord));
save_item(NAME(m_uNPitchPeriods));
save_item(NAME(m_uNVoiced));
save_item(NAME(m_uNControlWords));
save_item(NAME(m_uPrintLevel));
}
@ -45,19 +91,22 @@ void s14001a_new_device::sound_stream_update(sound_stream &stream, stream_sample
for (int i = 0; i < samples; i++)
{
Clock();
INT16 sample = INT16(m_uOutputP2) - 7;
outputs[0][i] = sample * 0x4000;
INT16 sample = m_uOutputP2 - 7; // range -7..8
outputs[0][i] = sample * 0xf00;
}
}
/**************************************************************************
External interface
**************************************************************************/
void s14001a_new_device::force_update()
{
m_stream->update();
}
READ_LINE_MEMBER(s14001a_new_device::romclock_r)
READ_LINE_MEMBER(s14001a_new_device::romen_r)
{
m_stream->update();
return (m_bPhase1) ? 1 : 0;
@ -82,14 +131,16 @@ WRITE_LINE_MEMBER(s14001a_new_device::start_w)
if (m_bStart) m_uStateP1 = WORDWAIT;
}
void s14001a_new_device::set_clock(int clock)
void s14001a_new_device::set_clock(UINT32 clock)
{
m_stream->update();
m_stream->set_sample_rate(clock);
}
/**************************************************************************
Device emulation
**************************************************************************/
UINT8 s14001a_new_device::readmem(UINT16 offset, bool phase)
{

View File

@ -22,14 +22,13 @@ public:
template<class _Object> static devcb_base &set_bsy_handler(device_t &device, _Object object) { return downcast<s14001a_new_device &>(device).m_bsy_handler.set_callback(object); }
template<class _Object> static devcb_base &set_ext_read_handler(device_t &device, _Object object) { return downcast<s14001a_new_device &>(device).m_ext_read_handler.set_callback(object); }
DECLARE_READ_LINE_MEMBER(busy_r);
DECLARE_READ_LINE_MEMBER(romclock_r);
DECLARE_WRITE_LINE_MEMBER(start_w);
DECLARE_WRITE8_MEMBER(data_w);
DECLARE_READ_LINE_MEMBER(busy_r); // /BUSY (pin 40)
DECLARE_READ_LINE_MEMBER(romen_r); // ROM /EN (pin 9)
DECLARE_WRITE_LINE_MEMBER(start_w); // START (pin 10)
DECLARE_WRITE8_MEMBER(data_w); // 6-bit word
void set_clock(int clock); /* set VSU-1000 clock */
// void set_volume(int volume); /* set VSU-1000 volume control */
void force_update();
void set_clock(UINT32 clock); // set new CLK frequency
void force_update(); // update stream, eg. before external ROM bankswitch
protected:
// device-level overrides