summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author holub <andrei.holub@gmail.com>2025-07-09 21:27:53 -0400
committer GitHub <noreply@github.com>2025-07-09 21:27:53 -0400
commitb16e68366435439ada4832c232594c569967596f (patch)
treee324667db3ac50974db606d99d9631d7c874e51a
parent4ea4ceb21d540982d16a0611d8b12587f641ed5e (diff)
sinclair/glukrs.cpp: Replaced custom RTC with verified KR512VI1/MC146818 (#13932)
* machine/ds1307.cpp: Dropped i2c prefix in the file name
-rw-r--r--scripts/src/machine.lua6
-rw-r--r--src/devices/machine/ds1307.cpp (renamed from src/devices/machine/i2cds1307.cpp)2
-rw-r--r--src/devices/machine/ds1307.h (renamed from src/devices/machine/i2cds1307.h)6
-rw-r--r--src/devices/machine/mc146818.h6
-rw-r--r--src/mame/sinclair/glukrs.cpp48
-rw-r--r--src/mame/sinclair/glukrs.h27
-rw-r--r--src/mame/sinclair/pentevo.cpp12
-rw-r--r--src/mame/sinclair/specnext.cpp2
-rw-r--r--src/mame/sinclair/tsconf.cpp2
-rw-r--r--src/mame/sinclair/tsconf_m.cpp8
10 files changed, 48 insertions, 71 deletions
diff --git a/scripts/src/machine.lua b/scripts/src/machine.lua
index e2f95bfe99f..a086d09da25 100644
--- a/scripts/src/machine.lua
+++ b/scripts/src/machine.lua
@@ -1524,13 +1524,13 @@ if (MACHINES["1MB5"]~=null) then
end
---------------------------------------------------
---@src/devices/machine/i2cds1307.h,MACHINES["I2C_DS1307"] = true
+--@src/devices/machine/ds1307.h,MACHINES["I2C_DS1307"] = true
---------------------------------------------------
if (MACHINES["I2C_DS1307"]~=null) then
files {
- MAME_DIR .. "src/devices/machine/i2cds1307.cpp",
- MAME_DIR .. "src/devices/machine/i2cds1307.h",
+ MAME_DIR .. "src/devices/machine/ds1307.cpp",
+ MAME_DIR .. "src/devices/machine/ds1307.h",
}
end
diff --git a/src/devices/machine/i2cds1307.cpp b/src/devices/machine/ds1307.cpp
index d5eda632ddc..c9a098b9682 100644
--- a/src/devices/machine/i2cds1307.cpp
+++ b/src/devices/machine/ds1307.cpp
@@ -6,7 +6,7 @@
#include "emu.h"
-#include "i2cds1307.h"
+#include "ds1307.h"
DEFINE_DEVICE_TYPE(I2C_DS1307, i2c_ds1307_device, "i2c_ds1307", "I2C DS1307 RTC/SRAM")
diff --git a/src/devices/machine/i2cds1307.h b/src/devices/machine/ds1307.h
index 248c8b7e246..4332ceedc12 100644
--- a/src/devices/machine/i2cds1307.h
+++ b/src/devices/machine/ds1307.h
@@ -1,7 +1,7 @@
// license:BSD-3-Clause
// copyright-holders:Andrei I. Holub
-#ifndef MAME_MACHINE_I2CDS1307_H
-#define MAME_MACHINE_I2CDS1307_H
+#ifndef MAME_MACHINE_DS1307_H
+#define MAME_MACHINE_DS1307_H
#include "dirtc.h"
#include "i2chle.h"
@@ -33,4 +33,4 @@ private:
DECLARE_DEVICE_TYPE(I2C_DS1307, i2c_ds1307_device)
-#endif // MAME_MACHINE_I2CDS1307_H
+#endif // MAME_MACHINE_DS1307_H
diff --git a/src/devices/machine/mc146818.h b/src/devices/machine/mc146818.h
index 8fc89185e6a..b4ef57e05e4 100644
--- a/src/devices/machine/mc146818.h
+++ b/src/devices/machine/mc146818.h
@@ -39,9 +39,9 @@ public:
void set_epoch(int epoch) { m_epoch = epoch; }
// read/write access
- void address_w(uint8_t data);
- uint8_t data_r();
- void data_w(uint8_t data);
+ virtual void address_w(uint8_t data);
+ virtual uint8_t data_r();
+ virtual void data_w(uint8_t data);
// direct-mapped read/write access
uint8_t read_direct(offs_t offset);
diff --git a/src/mame/sinclair/glukrs.cpp b/src/mame/sinclair/glukrs.cpp
index 9c6f33f2453..cd738cc942e 100644
--- a/src/mame/sinclair/glukrs.cpp
+++ b/src/mame/sinclair/glukrs.cpp
@@ -3,7 +3,7 @@
/***************************************************************************
Mr Gluk Reset Service
- TODO implementation must be based on KR512VI1 clone MC146818
+ KR512VI1 clone MC146818
Refs:
https://zxart.ee/spa/software/prikladnoe-po/electronics/pzu/mr-gluk-reset-service-663/mr-gluk-reset-service-663/action:viewFile/id:250389/fileId:814961/
@@ -13,46 +13,34 @@
#include "emu.h"
#include "glukrs.h"
-glukrs_device::glukrs_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, GLUKRS, tag, owner, clock),
- device_rtc_interface(mconfig, *this),
- m_nvram(*this, "nvram") {}
-
-void glukrs_device::device_add_mconfig(machine_config &config)
+glukrs_device::glukrs_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : mc146818_device(mconfig, GLUKRS, tag, owner, clock)
{
- NVRAM(config, m_nvram, nvram_device::DEFAULT_ALL_1);
+ switch (clock)
+ {
+ case 4'194'304:
+ case 1'048'576:
+ m_tuc = 248;
+ break;
+ case 32'768:
+ m_tuc = 1984;
+ break;
+ }
+ set_24hrs(true);
}
void glukrs_device::device_start()
{
- save_item(NAME(m_glukrs_active));
- save_item(NAME(m_address));
-
- m_nvram->set_base(&m_cmos, sizeof(m_cmos));
+ mc146818_device::device_start();
- m_timer = timer_alloc(FUNC(glukrs_device::timer_callback), this);
- m_timer->adjust(attotime::from_hz(clock() / XTAL(32'768)), 0, attotime::from_hz(clock() / XTAL(32'768)));
+ save_item(NAME(m_glukrs_active));
}
void glukrs_device::device_reset()
{
- m_glukrs_active = false;
-}
+ mc146818_device::device_reset();
-void glukrs_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
-{
- m_cmos[0x00] = convert_to_bcd(second);
- m_cmos[0x02] = convert_to_bcd(minute);
- m_cmos[0x04] = convert_to_bcd(hour);
- m_cmos[0x06] = convert_to_bcd(day_of_week);
- m_cmos[0x07] = convert_to_bcd(day);
- m_cmos[0x08] = convert_to_bcd(month);
- m_cmos[0x09] = convert_to_bcd(year % 100);
-}
-
-TIMER_CALLBACK_MEMBER(glukrs_device::timer_callback)
-{
- advance_seconds();
+ m_glukrs_active = false;
}
// device type definition
diff --git a/src/mame/sinclair/glukrs.h b/src/mame/sinclair/glukrs.h
index 9dadd02b044..2a446497cb3 100644
--- a/src/mame/sinclair/glukrs.h
+++ b/src/mame/sinclair/glukrs.h
@@ -6,38 +6,31 @@
#pragma once
-#include "machine/nvram.h"
-#include "dirtc.h"
+#include "machine/mc146818.h"
-class glukrs_device : public device_t,
- public device_rtc_interface
+
+class glukrs_device : public mc146818_device
{
public:
- glukrs_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 32'768);
+ glukrs_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
void enable() { m_glukrs_active = true; }
void disable() { m_glukrs_active = false; }
bool is_active() { return m_glukrs_active; }
- u8 address_r() { return m_glukrs_active ? m_address : 0xff; }
- void address_w(u8 address) { if (m_glukrs_active) m_address = address; }
- u8 data_r() { return m_glukrs_active ? m_cmos[m_address] : 0xff; }
- void data_w(u8 data) { if (m_glukrs_active) { m_cmos[m_address] = data; } }
- TIMER_CALLBACK_MEMBER(timer_callback);
+ u8 address_r() { return m_glukrs_active ? mc146818_device::get_address() : 0xff; }
+ virtual void address_w(u8 address) override { if (m_glukrs_active) mc146818_device::address_w(address); }
+ virtual u8 data_r() override { return m_glukrs_active ? mc146818_device::data_r() : 0xff; }
+ virtual void data_w(u8 data) override { if (m_glukrs_active) { mc146818_device::data_w(data); } }
protected:
- void device_add_mconfig(machine_config &config) override ATTR_COLD;
void device_start() override ATTR_COLD;
void device_reset() override ATTR_COLD;
- void rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second) override;
+
+ virtual int data_size() const override { return 0xff; }
private:
bool m_glukrs_active;
- u8 m_address;
-
- u8 m_cmos[0x100];
- required_device<nvram_device> m_nvram;
- emu_timer *m_timer;
};
DECLARE_DEVICE_TYPE(GLUKRS, glukrs_device)
diff --git a/src/mame/sinclair/pentevo.cpp b/src/mame/sinclair/pentevo.cpp
index fd8fd90ed1e..dca4537dda9 100644
--- a/src/mame/sinclair/pentevo.cpp
+++ b/src/mame/sinclair/pentevo.cpp
@@ -536,26 +536,24 @@ void pentevo_state::gluk_data_w(offs_t offset, u8 data)
if (!m_glukrs->is_active())
return;
- u8 addr = m_glukrs->address_r();
+ const u8 addr = m_glukrs->address_r();
if (addr >= 0xf0 && addr <= 0xf0)
{
m_gluk_ext = data;
u8 m_fx[0xf] = {0x00};
if (data == 0 || data == 1) // BASECONF_VERSION + BOOTLOADER_VERSION
{
- strcpy((char *)m_fx, "M.A.M.E.");
+ strcpy((char *)m_fx, "MAME");
PAIR16 m_ver;
- m_ver.w = ((22 << 9) | (9 << 5) | 3); // y.m.d
+ m_ver.w = ((25 << 9) | (7 << 5) | 31); // y.m.d
m_fx[0x0c] = m_ver.b.l;
m_fx[0x0d] = m_ver.b.h;
}
for (u8 i = 0; i < 0xf; i++)
{
- m_glukrs->address_w(0xf0 + i);
- m_glukrs->data_w(m_fx[i]);
+ m_glukrs->write_direct(0xf0 + i, m_fx[i]);
}
- m_glukrs->address_w(addr);
}
else
{
@@ -740,7 +738,7 @@ void pentevo_state::pentevo(machine_config &config)
m_ram->set_default_size("4M");
RAM(config, m_char_ram).set_default_size("2048").set_default_value(0);
- GLUKRS(config, m_glukrs);
+ GLUKRS(config, m_glukrs, 4'194'304);
SPI_SDCARD(config, m_sdcard, 0);
m_sdcard->set_prefer_sdhc();
m_sdcard->spi_miso_callback().set(FUNC(pentevo_state::spi_miso_w));
diff --git a/src/mame/sinclair/specnext.cpp b/src/mame/sinclair/specnext.cpp
index c808b696cce..05d3f1ce2a2 100644
--- a/src/mame/sinclair/specnext.cpp
+++ b/src/mame/sinclair/specnext.cpp
@@ -34,7 +34,7 @@
#include "bus/spectrum/zxbus/bus.h"
#include "cpu/z80/z80n.h"
-#include "machine/i2cds1307.h"
+#include "machine/ds1307.h"
#include "machine/spi_sdcard.h"
#include "sound/ay8910.h"
#include "sound/dac.h"
diff --git a/src/mame/sinclair/tsconf.cpp b/src/mame/sinclair/tsconf.cpp
index b2e14797714..cffd9ac802f 100644
--- a/src/mame/sinclair/tsconf.cpp
+++ b/src/mame/sinclair/tsconf.cpp
@@ -296,7 +296,7 @@ void tsconf_state::tsconf(machine_config &config)
m_ram->set_default_size("4096K").set_default_value(0x00); // must be random but 0x00 behaves better than 0xff in tested software
- GLUKRS(config, m_glukrs);
+ GLUKRS(config, m_glukrs, 4'194'304);
TSCONF_DMA(config, m_dma, 28_MHz_XTAL);
m_dma->in_mreq_callback().set(FUNC(tsconf_state::ram_read16));
diff --git a/src/mame/sinclair/tsconf_m.cpp b/src/mame/sinclair/tsconf_m.cpp
index 257f5280835..1d4a5fac35f 100644
--- a/src/mame/sinclair/tsconf_m.cpp
+++ b/src/mame/sinclair/tsconf_m.cpp
@@ -769,9 +769,9 @@ void tsconf_state::tsconf_port_f7_w(offs_t offset, u8 data)
{
case CONF_VERSION:
{
- strcpy((char *)m_fx, "M.A.M.E.");
+ strcpy((char *)m_fx, "MAME");
PAIR16 m_ver;
- m_ver.w = ((22 << 9) | (02 << 5) | 8); // y.m.d
+ m_ver.w = ((25 << 9) | (07 << 5) | 31); // y.m.d
m_fx[0x0c] = m_ver.b.l;
m_fx[0x0d] = m_ver.b.h;
break;
@@ -785,10 +785,8 @@ void tsconf_state::tsconf_port_f7_w(offs_t offset, u8 data)
}
for (u8 i = 0; i < 0xf; i++)
{
- m_glukrs->address_w(0xf0 + i);
- m_glukrs->data_w(m_fx[i]);
+ m_glukrs->write_direct(0xf0 + i, m_fx[i]);
}
- m_glukrs->address_w(0xf0);
}
else
{