Skip to content

Commit

Permalink
machine/rp5c15.cpp: implement set_year_offset setter, fix x68k defaul…
Browse files Browse the repository at this point in the history
…t year setup to be current rather than -20 (#11530)

* machine/rp5c15.cpp: implement set_year_offset setter, fix x68k default year setup to be current rather than -20

* machine/ds1386.cpp: remove non-existant set_current_time fn override
  • Loading branch information
angelosa authored Sep 8, 2023
1 parent ec641c5 commit cf83939
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/devices/machine/ds1386.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ class ds1386_device : public device_t,
void safe_intb_cb(int state);
void safe_sqw_cb(int state);

void set_current_time();

void check_tod_alarm();
void time_of_day_alarm();
void watchdog_alarm();
Expand Down
8 changes: 8 additions & 0 deletions src/devices/machine/rp5c15.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ enum
DEFINE_DEVICE_TYPE(RP5C15, rp5c15_device, "rp5c15", "Ricoh RP5C15 RTC")


// x68k wants an epoch base (1980-2079) on init, mz2500 do not ("print date$" under basicv2)
// megast_* tbd
void rp5c15_device::set_current_time(const system_time &systime)
{
const system_time::full_time &time = m_use_utc ? systime.utc_time : systime.local_time;
set_time(true, time.year + m_year_offset, time.month + 1, time.mday, time.weekday + 1,
time.hour, time.minute, time.second);
}

//**************************************************************************
// INLINE HELPERS
Expand Down
5 changes: 5 additions & 0 deletions src/devices/machine/rp5c15.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ class rp5c15_device : public device_t,

auto alarm() { return m_out_alarm_cb.bind(); }
auto clkout() { return m_out_clkout_cb.bind(); }
void set_year_offset(int year) { m_year_offset = year; }

uint8_t read(offs_t offset);
void write(offs_t offset, uint8_t data);

virtual void set_current_time(const system_time &systime) override;

protected:
// device-level overrides
virtual void device_start() override;
Expand Down Expand Up @@ -70,6 +73,8 @@ class rp5c15_device : public device_t,
int m_16hz; // 16 Hz condition
int m_clkout; // clock output

int m_year_offset = 0;

// timers
emu_timer *m_clock_timer;
emu_timer *m_16hz_timer;
Expand Down
2 changes: 1 addition & 1 deletion src/emu/dirtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class device_rtc_interface : public device_interface
void set_use_utc(bool use_utc) { m_use_utc = use_utc; }

void set_time(bool update, int year, int month, int day, int day_of_week, int hour, int minute, int second);
void set_current_time(const system_time &systime);
virtual void set_current_time(const system_time &systime);

bool has_battery() const { return rtc_battery_backed(); }

Expand Down
1 change: 1 addition & 0 deletions src/mame/sharp/x68k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,7 @@ void x68k_state::x68000_base(machine_config &config)

RP5C15(config, m_rtc, 32.768_kHz_XTAL);
m_rtc->alarm().set(m_mfpdev, FUNC(mc68901_device::i0_w));
m_rtc->set_year_offset(20);

/* video hardware */
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
Expand Down

0 comments on commit cf83939

Please sign in to comment.