apple2: //e, //c, and friends now have No-Slot Clock support. [R. Belmont]

ds1315: Added support to emulate DS121x parts where the RTC sits in a
ROM's address space. [R. Belmont]
This commit is contained in:
arbee 2017-11-05 09:22:58 -05:00
parent b03a8f7f61
commit ab0aebccec
3 changed files with 73 additions and 23 deletions

View File

@ -1,12 +1,16 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Tim Lindner // copyright-holders:Tim Lindner, R. Belmont
/***************************************************************************************** /*****************************************************************************************
ds1315.c ds1315.cpp
Dallas Semiconductor's Phantom Time Chip DS1315. Dallas Semiconductor's Phantom Time Chip DS1315.
NOTE: writes are decoded, but the host's time will always be returned when asked. NOTE: writes are decoded, but the host's time will always be returned when asked.
November 2017: R. Belmont added capability to emulate DS1216 and other DS121x
parts where the clock sits in the same place as a ROM. The backing callback
returns the ROM contents when the RTC is locked.
April 2015: chip enable / chip reset / phantom writes by Karl-Ludwig Deisenhofer April 2015: chip enable / chip reset / phantom writes by Karl-Ludwig Deisenhofer
November 2001: implementation by Tim Lindner November 2001: implementation by Tim Lindner
@ -29,7 +33,10 @@
DEFINE_DEVICE_TYPE(DS1315, ds1315_device, "ds1315", "Dallas DS1315 Phantom Time Chip") DEFINE_DEVICE_TYPE(DS1315, ds1315_device, "ds1315", "Dallas DS1315 Phantom Time Chip")
ds1315_device::ds1315_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) ds1315_device::ds1315_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, DS1315, tag, owner, clock), m_mode(), m_count(0) : device_t(mconfig, DS1315, tag, owner, clock),
m_backing_read(*this),
m_mode(),
m_count(0)
{ {
} }
@ -39,6 +46,8 @@ ds1315_device::ds1315_device(const machine_config &mconfig, const char *tag, dev
void ds1315_device::device_start() void ds1315_device::device_start()
{ {
m_backing_read.resolve_safe(0xff);
save_item(NAME(m_count)); save_item(NAME(m_count));
save_item(NAME(m_mode)); save_item(NAME(m_mode));
save_item(NAME(m_raw_data)); save_item(NAME(m_raw_data));
@ -77,6 +86,37 @@ static const uint8_t ds1315_pattern[] =
IMPLEMENTATION IMPLEMENTATION
***************************************************************************/ ***************************************************************************/
// automated read, does all the work the real Dallas chip does
READ8_MEMBER( ds1315_device::read )
{
if (m_mode == DS_SEEK_MATCHING)
{
if (offset & 1)
{
read_1(space, 0);
}
else
{
read_0(space, 0);
}
if (offset & 4)
{
m_count = 0;
m_mode = DS_SEEK_MATCHING;
}
return m_backing_read(offset);
}
else if (m_mode == DS_CALENDAR_IO)
{
return read_data(space, offset);
}
return 0xff; // shouldn't happen, but compilers don't know that
}
/*------------------------------------------------- /*-------------------------------------------------
read_0 (actual data) read_0 (actual data)
-------------------------------------------------*/ -------------------------------------------------*/
@ -92,7 +132,6 @@ READ8_MEMBER( ds1315_device::read_0 )
m_mode = DS_CALENDAR_IO; m_mode = DS_CALENDAR_IO;
fill_raw_data(); fill_raw_data();
} }
return 0; return 0;
} }
@ -246,7 +285,7 @@ void ds1315_device::input_raw_data()
raw[6] = bcd_2_dec(raw[6]); // month raw[6] = bcd_2_dec(raw[6]); // month
raw[7] = bcd_2_dec(raw[7]); // year (two digits) raw[7] = bcd_2_dec(raw[7]); // year (two digits)
printf("\nDS1315 RTC INPUT (WILL BE IGNORED) mm/dd/yy hh:mm:ss - %02d/%02d/%02d %02d/%02d/%02d", logerror("\nDS1315 RTC INPUT (WILL BE IGNORED) mm/dd/yy hh:mm:ss - %02d/%02d/%02d %02d/%02d/%02d",
raw[6], raw[5], raw[7], raw[3], raw[2], raw[1] raw[6], raw[5], raw[7], raw[3], raw[2], raw[1]
); );
} }

View File

@ -15,7 +15,15 @@
#pragma once #pragma once
/***************************************************************************
DEVICE CONFIGURATION MACROS
***************************************************************************/
#define MCFG_DS1315_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, DS1315, 0)
#define MCFG_DS1315_BACKING_HANDLER(_devcb) \
devcb = &ds1315_device::set_backing_handler(*device, DEVCB_##_devcb);
/*************************************************************************** /***************************************************************************
MACROS MACROS
@ -27,6 +35,9 @@ public:
ds1315_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); ds1315_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
~ds1315_device() {} ~ds1315_device() {}
// this handler automates the bits 0/2 stuff
DECLARE_READ8_MEMBER(read);
DECLARE_READ8_MEMBER(read_0); DECLARE_READ8_MEMBER(read_0);
DECLARE_READ8_MEMBER(read_1); DECLARE_READ8_MEMBER(read_1);
DECLARE_READ8_MEMBER(read_data); DECLARE_READ8_MEMBER(read_data);
@ -35,12 +46,17 @@ public:
bool chip_enable(); bool chip_enable();
void chip_reset(); void chip_reset();
template <class Object> static devcb_base &set_backing_handler(device_t &device, Object &&cb)
{ return downcast<ds1315_device &>(device).m_backing_read.set_callback(std::forward<Object>(cb)); }
protected: protected:
// device-level overrides // device-level overrides
virtual void device_start() override; virtual void device_start() override;
virtual void device_reset() override; virtual void device_reset() override;
private: private:
devcb_read8 m_backing_read;
enum mode_t : u8 enum mode_t : u8
{ {
DS_SEEK_MATCHING, DS_SEEK_MATCHING,
@ -61,12 +77,4 @@ ALLOW_SAVE_TYPE(ds1315_device::mode_t);
DECLARE_DEVICE_TYPE(DS1315, ds1315_device) DECLARE_DEVICE_TYPE(DS1315, ds1315_device)
/***************************************************************************
DEVICE CONFIGURATION MACROS
***************************************************************************/
#define MCFG_DS1315_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, DS1315, 0)
#endif // MAME_MACHINE_DS1315_H #endif // MAME_MACHINE_DS1315_H

View File

@ -113,6 +113,7 @@ Address bus A0-A11 is Y0-Y11
#include "machine/ram.h" #include "machine/ram.h"
#include "machine/sonydriv.h" #include "machine/sonydriv.h"
#include "machine/timer.h" #include "machine/timer.h"
#include "machine/ds1315.h"
#include "bus/a2bus/a2bus.h" #include "bus/a2bus/a2bus.h"
#include "bus/a2bus/a2diskii.h" #include "bus/a2bus/a2diskii.h"
@ -241,7 +242,8 @@ public:
m_acia1(*this, IIC_ACIA1_TAG), m_acia1(*this, IIC_ACIA1_TAG),
m_acia2(*this, IIC_ACIA2_TAG), m_acia2(*this, IIC_ACIA2_TAG),
m_laserudc(*this, LASER128_UDC_TAG), m_laserudc(*this, LASER128_UDC_TAG),
m_iicpiwm(*this, IICP_IWM_TAG) m_iicpiwm(*this, IICP_IWM_TAG),
m_ds1315(*this, "nsc")
{ } { }
required_device<cpu_device> m_maincpu; required_device<cpu_device> m_maincpu;
@ -274,6 +276,7 @@ public:
optional_device<mos6551_device> m_acia1, m_acia2; optional_device<mos6551_device> m_acia1, m_acia2;
optional_device<applefdc_base_device> m_laserudc; optional_device<applefdc_base_device> m_laserudc;
optional_device<iwm_device> m_iicpiwm; optional_device<iwm_device> m_iicpiwm;
required_device<ds1315_device> m_ds1315;
TIMER_DEVICE_CALLBACK_MEMBER(apple2_interrupt); TIMER_DEVICE_CALLBACK_MEMBER(apple2_interrupt);
TIMER_DEVICE_CALLBACK_MEMBER(ay3600_repeat); TIMER_DEVICE_CALLBACK_MEMBER(ay3600_repeat);
@ -356,6 +359,7 @@ public:
DECLARE_WRITE_LINE_MEMBER(ay3600_ako_w); DECLARE_WRITE_LINE_MEMBER(ay3600_ako_w);
DECLARE_READ8_MEMBER(memexp_r); DECLARE_READ8_MEMBER(memexp_r);
DECLARE_WRITE8_MEMBER(memexp_w); DECLARE_WRITE8_MEMBER(memexp_w);
DECLARE_READ8_MEMBER(nsc_backing_r);
private: private:
int m_speaker_state; int m_speaker_state;
@ -2171,17 +2175,12 @@ void apple2e_state::write_slot_rom(address_space &space, int slotbias, int offse
uint8_t apple2e_state::read_int_rom(address_space &space, int slotbias, int offset) uint8_t apple2e_state::read_int_rom(address_space &space, int slotbias, int offset)
{ {
#if 0 //return m_rom_ptr[slotbias + offset];
if ((m_cnxx_slot == CNXX_UNCLAIMED) && (!machine().side_effect_disabled())) return m_ds1315->read(space, slotbias + offset);
{
m_cnxx_slot = CNXX_INTROM;
update_slotrom_banks();
}
#endif
return m_rom_ptr[slotbias + offset];
} }
READ8_MEMBER(apple2e_state::nsc_backing_r) { return m_rom_ptr[offset]; }
READ8_MEMBER(apple2e_state::c100_r) { return read_slot_rom(space, 1, offset); } READ8_MEMBER(apple2e_state::c100_r) { return read_slot_rom(space, 1, offset); }
READ8_MEMBER(apple2e_state::c100_int_r) { return read_int_rom(space, 0x100, offset); } READ8_MEMBER(apple2e_state::c100_int_r) { return read_int_rom(space, 0x100, offset); }
READ8_MEMBER(apple2e_state::c100_int_bank_r) { return read_int_rom(space, 0x4100, offset); } READ8_MEMBER(apple2e_state::c100_int_bank_r) { return read_int_rom(space, 0x4100, offset); }
@ -3856,6 +3855,10 @@ static MACHINE_CONFIG_START( apple2e )
MCFG_SOUND_ADD(A2_SPEAKER_TAG, SPEAKER_SOUND, 0) MCFG_SOUND_ADD(A2_SPEAKER_TAG, SPEAKER_SOUND, 0)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
/* DS1315 for no-slot clock */
MCFG_DS1315_ADD("nsc")
MCFG_DS1315_BACKING_HANDLER(READ8(apple2e_state, nsc_backing_r))
/* RAM */ /* RAM */
MCFG_RAM_ADD(RAM_TAG) MCFG_RAM_ADD(RAM_TAG)
MCFG_RAM_DEFAULT_SIZE("64K") MCFG_RAM_DEFAULT_SIZE("64K")