mc146818: add ds1397 variant

This commit is contained in:
Patrick Mackinlay 2023-03-24 17:24:39 +07:00
parent 564fa462ba
commit 04d24d5368
2 changed files with 54 additions and 0 deletions

View File

@ -24,6 +24,7 @@
// device type definition
DEFINE_DEVICE_TYPE(MC146818, mc146818_device, "mc146818", "MC146818 RTC")
DEFINE_DEVICE_TYPE(DS1287, ds1287_device, "ds1287", "DS1287 RTC")
DEFINE_DEVICE_TYPE(DS1397, ds1397_device, "ds1397", "DS1397 RAMified RTC")
//-------------------------------------------------
// mc146818_device - constructor
@ -49,6 +50,11 @@ ds1287_device::ds1287_device(const machine_config &mconfig, const char *tag, dev
{
}
ds1397_device::ds1397_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: mc146818_device(mconfig, DS1397, tag, owner, clock)
{
}
mc146818_device::mc146818_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, type, tag, owner, clock),
device_nvram_interface(mconfig, *this),
@ -721,3 +727,33 @@ void mc146818_device::internal_write(offs_t offset, uint8_t data)
break;
}
}
void ds1397_device::device_start()
{
mc146818_device::device_start();
save_item(NAME(m_xram_page));
}
void ds1397_device::device_reset()
{
mc146818_device::device_reset();
m_xram_page = 0;
}
u8 ds1397_device::xram_r(offs_t offset)
{
if (offset < 0x20)
return m_data[0x40 + m_xram_page * 0x20 + offset];
else
return m_xram_page;
}
void ds1397_device::xram_w(offs_t offset, u8 data)
{
if (offset < 0x20)
m_data[0x40 + m_xram_page * 0x20 + offset] = data;
else
m_xram_page = data & 0x7f;
}

View File

@ -181,8 +181,26 @@ public:
ds1287_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
};
class ds1397_device : public mc146818_device
{
public:
ds1397_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual void device_start() override;
virtual void device_reset() override;
u8 xram_r(offs_t offset);
void xram_w(offs_t offset, u8 data);
protected:
virtual int data_size() const override { return 64 + 4096; }
u8 m_xram_page;
};
// device type definition
DECLARE_DEVICE_TYPE(MC146818, mc146818_device)
DECLARE_DEVICE_TYPE(DS1287, ds1287_device)
DECLARE_DEVICE_TYPE(DS1397, ds1397_device)
#endif // MAME_MACHINE_MC146818_H