From ab7af50b132498aabb58022f55ee07ce0b77bd82 Mon Sep 17 00:00:00 2001 From: yz70s Date: Fri, 4 Jan 2019 20:30:21 +0100 Subject: [PATCH] ds128x.cpp: add device ds12885ext same as ds12885 but 256 bytes ram (nw) --- src/devices/machine/ds128x.cpp | 58 +++++++++++++++++++++++++++++++++- src/devices/machine/ds128x.h | 25 ++++++++++++++- 2 files changed, 81 insertions(+), 2 deletions(-) diff --git a/src/devices/machine/ds128x.cpp b/src/devices/machine/ds128x.cpp index 7a397aab303..a234e3abf82 100644 --- a/src/devices/machine/ds128x.cpp +++ b/src/devices/machine/ds128x.cpp @@ -10,7 +10,12 @@ DEFINE_DEVICE_TYPE(DS12885, ds12885_device, "ds12885", "DS12885 RTC/NVRAM") //------------------------------------------------- ds12885_device::ds12885_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : mc146818_device(mconfig, DS12885, tag, owner, clock) + : ds12885_device(mconfig, DS12885, tag, owner, clock) +{ +} + +ds12885_device::ds12885_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) + : mc146818_device(mconfig, type, tag, owner, clock) { } @@ -23,3 +28,54 @@ int ds12885_device::get_timer_bypass() return 22; // No tick } + +DEFINE_DEVICE_TYPE(DS12885EXT, ds12885ext_device, "ds12885ext", "DS12885 RTC/NVRAM size 256 bytes") + +//------------------------------------------------- +// ds12885ext_device - constructor +//------------------------------------------------- + +ds12885ext_device::ds12885ext_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : ds12885_device(mconfig, DS12885EXT, tag, owner, clock) +{ +} + +//------------------------------------------------- +// ds12885ext_device - handlers that allow acces to extended memory size +//------------------------------------------------- + +READ8_MEMBER(ds12885ext_device::read_extended) +{ + switch (offset) + { + case 0: + case 1: + return read(space, offset, mem_mask); + break; + case 2: + case 3: + return read(space, offset - 2, mem_mask); + break; + default: + return 0xff; + } +} + +WRITE8_MEMBER(ds12885ext_device::write_extended) +{ + switch (offset) + { + case 0: + write(space, offset, data & 127, mem_mask); + break; + case 1: + write(space, offset, data, mem_mask); + break; + case 2: + write(space, offset - 2, data, mem_mask); + break; + case 3: + write(space, offset - 2, data, mem_mask); + break; + } +} diff --git a/src/devices/machine/ds128x.h b/src/devices/machine/ds128x.h index 671d3ee0a6f..5f5e4016000 100644 --- a/src/devices/machine/ds128x.h +++ b/src/devices/machine/ds128x.h @@ -8,13 +8,17 @@ #define MCFG_DS12885_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, DS12885, XTAL(32'768)) -// ======================> mc146818_device +#define MCFG_DS12885EXT_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, DS12885EXT, XTAL(32'768)) + +// ======================> ds12885_device class ds12885_device : public mc146818_device { public: // construction/destruction ds12885_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 32'768); + ds12885_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock = 32'768); protected: virtual int data_size() override { return 128; } @@ -24,4 +28,23 @@ protected: // device type definition DECLARE_DEVICE_TYPE(DS12885, ds12885_device) +// ======================> ds12885ext_device + +class ds12885ext_device : public ds12885_device +{ +public: + // construction/destruction + ds12885ext_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 32'768); + + // read/write access to extended ram + DECLARE_READ8_MEMBER(read_extended); + DECLARE_WRITE8_MEMBER(write_extended); + +protected: + virtual int data_size() override { return 256; } +}; + +// device type definition +DECLARE_DEVICE_TYPE(DS12885EXT, ds12885ext_device) + #endif // MAME_MACHINE_DS128X_H