machine/rp5c01.cpp, seibu/banprestoms.cpp: add preliminary Sharp LH5045 RTC device

This commit is contained in:
angelosa 2022-11-04 21:14:57 +01:00
parent bcaed327ff
commit 00309d4a6c
3 changed files with 44 additions and 16 deletions

View File

@ -13,6 +13,8 @@
- 12 hour clock
- test register
- timer reset
- convert I/O to address maps & views
- lh5045 doesn't really wrap time correctly
*/
@ -23,6 +25,7 @@
// device type definitions
DEFINE_DEVICE_TYPE(RP5C01, rp5c01_device, "rp5c01", "Ricoh RP5C01 RTC")
DEFINE_DEVICE_TYPE(TC8521, tc8521_device, "tc8521", "Toshiba TC8521 RTC")
DEFINE_DEVICE_TYPE(LH5045, lh5045_device, "lh5045", "Sharp LH5045 RTC")
//**************************************************************************
@ -432,3 +435,22 @@ tc8521_device::tc8521_device(const machine_config &mconfig, const char *tag, dev
: rp5c01_device(mconfig, TC8521, tag, owner, clock)
{
}
//-------------------------------------------------
// lh5045_device - constructor
//-------------------------------------------------
lh5045_device::lh5045_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: rp5c01_device(mconfig, LH5045, tag, owner, clock)
{
}
TIMER_CALLBACK_MEMBER(lh5045_device::advance_1hz_clock)
{
// inverted & different bit compared to rp5c01
if (m_1hz && (!BIT(m_mode, 2)))
advance_seconds();
m_1hz = !m_1hz;
set_alarm_line();
}

View File

@ -65,11 +65,11 @@ protected:
virtual bool nvram_read(util::read_stream &file) override;
virtual bool nvram_write(util::write_stream &file) override;
TIMER_CALLBACK_MEMBER(advance_1hz_clock);
virtual TIMER_CALLBACK_MEMBER(advance_1hz_clock);
TIMER_CALLBACK_MEMBER(advance_16hz_clock);
private:
inline void set_alarm_line();
private:
inline int read_counter(int counter);
inline void write_counter(int counter, int value);
inline void check_alarm();
@ -77,6 +77,7 @@ private:
devcb_write_line m_out_alarm_cb;
bool m_battery_backed;
protected:
uint8_t m_reg[2][13]; // clock registers
uint8_t m_ram[13]; // RAM
@ -87,6 +88,7 @@ private:
int m_1hz; // 1 Hz condition
int m_16hz; // 16 Hz condition
private:
// timers
emu_timer *m_clock_timer;
emu_timer *m_16hz_timer;
@ -101,9 +103,19 @@ public:
tc8521_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
};
class lh5045_device : public rp5c01_device
{
public:
// construction/destruction
lh5045_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
private:
virtual TIMER_CALLBACK_MEMBER(advance_1hz_clock) override;
};
// device type definition
DECLARE_DEVICE_TYPE(RP5C01, rp5c01_device)
DECLARE_DEVICE_TYPE(TC8521, tc8521_device)
DECLARE_DEVICE_TYPE(LH5045, lh5045_device)
#endif // MAME_MACHINE_RP5C01_H

View File

@ -41,6 +41,7 @@ TODO:
#include "cpu/m68000/m68000.h"
#include "machine/nvram.h"
#include "machine/rp5c01.h"
#include "machine/ticket.h"
#include "sound/okim6295.h"
@ -61,6 +62,7 @@ public:
, m_gfxdecode(*this, "gfxdecode")
, m_palette(*this, "palette")
, m_ticket(*this, "ticket")
, m_rtc(*this, "rtc")
, m_vram(*this, "vram%u", 0U)
, m_spriteram(*this, "sprite_ram")
, m_okibank(*this, "okibank")
@ -79,6 +81,7 @@ private:
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
required_device<ticket_dispenser_device> m_ticket;
required_device<lh5045_device> m_rtc;
required_shared_ptr_array<uint16_t, 4> m_vram;
required_shared_ptr<uint16_t> m_spriteram;
@ -260,21 +263,9 @@ void banprestoms_state::prg_map(address_map &map)
map(0x0e0002, 0x0e0003).portr("IN1");
map(0x0e0004, 0x0e0005).portr("IN2");
// Expects a '1' when entering RTC test (RTC ready line?)
// Expects a '1' when entering RTC test (RTC /BSY line?)
map(0x0e0006, 0x0e0007).lr8(NAME([](offs_t offset) { return 1; }));
/*
* Unknown RTC type (service mode in tvdenwad -> first item)
* 4-bit access, in lower/upper digit fashion
* [0-2] seconds
* [4-6] minutes
* [8-a] hours
* [c] weekday?
* [e-0x10] day
* [0x12-0x14] month
* [0x16-0x18] year
* [0x1a-0x1e] cleared on POST
*/
// map(0x100000, 0x10001f).ram();
map(0x100000, 0x10001f).rw(m_rtc, FUNC(lh5045_device::read), FUNC(lh5045_device::write)).umask16(0x00ff);
}
void banprestoms_state::oki_map(address_map &map)
@ -285,6 +276,7 @@ void banprestoms_state::oki_map(address_map &map)
static INPUT_PORTS_START( tvdenwad )
PORT_START("IN1")
// TODO: convert to keypad
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 ) // 1
PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 ) // 2
PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON3 ) // 3
@ -469,6 +461,8 @@ void banprestoms_state::banprestoms(machine_config &config)
crtc.layer_en_callback().set(FUNC(banprestoms_state::layer_en_w));
crtc.layer_scroll_callback().set(FUNC(banprestoms_state::layer_scroll_w));
LH5045(config, m_rtc, XTAL(32'768));
GFXDECODE(config, m_gfxdecode, m_palette, gfx_banprestoms);
PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x400); // TODO: copied from other drivers using the same CRTC