2012-05-21 10:56:48 +00:00
|
|
|
//Epson RTC-4513 Real-Time Clock
|
|
|
|
|
2012-05-22 12:10:00 +00:00
|
|
|
struct EpsonRTC : Coprocessor {
|
2015-11-14 00:52:51 +00:00
|
|
|
static auto Enter() -> void;
|
2016-02-09 11:51:12 +00:00
|
|
|
auto main() -> void;
|
2012-05-21 10:56:48 +00:00
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
auto init() -> void;
|
|
|
|
auto load() -> void;
|
|
|
|
auto unload() -> void;
|
|
|
|
auto power() -> void;
|
|
|
|
auto reset() -> void;
|
|
|
|
auto sync() -> void;
|
2012-05-21 10:56:48 +00:00
|
|
|
|
2015-12-14 09:41:06 +00:00
|
|
|
auto read(uint addr, uint8 data) -> uint8;
|
2015-11-14 00:52:51 +00:00
|
|
|
auto write(uint addr, uint8 data) -> void;
|
2012-05-21 10:56:48 +00:00
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
auto serialize(serializer&) -> void;
|
2012-05-21 10:56:48 +00:00
|
|
|
|
2012-05-23 11:27:45 +00:00
|
|
|
uint21 clocks;
|
2015-11-14 00:52:51 +00:00
|
|
|
uint seconds;
|
2012-05-21 10:56:48 +00:00
|
|
|
|
|
|
|
uint2 chipselect;
|
2015-11-14 00:52:51 +00:00
|
|
|
enum class State : uint { Mode, Seek, Read, Write } state;
|
2012-05-21 10:56:48 +00:00
|
|
|
uint4 mdr;
|
|
|
|
uint4 offset;
|
2015-11-14 00:52:51 +00:00
|
|
|
uint wait;
|
Update to v089r06 release.
[Yes, the release number is re-used. -Ed.]
byuu says:
I had some bugs in r07 that I couldn't track down, DKJM2's clock was
getting all out of sync.
So I just reverted to r05, blew away both RTCs entirely, and wrote them
cleanly from scratch (obviously looking off the old code.) A bit
extreme, but it worked.
I believe I found the error in the process, day and month were resetting
the counter to 0 instead of 1, it wasn't handling leap year, etc.
While I was at it, I fixed the day-of-week calculation. The SharpRTC
epoch is actually 1000-01-01, and not 1900-01-01.
I'm sure you guys will be really happy that if it ever becomes 1000AD
again and you're playing a ROM hack that uses the SharpRTC and relies on
its weekday value that it will show the correct day now ...
Kind of a pain to compute, but nothing compared to the seventh circle of
hell that was my IBM dBase III Julian<>Gregorian conversion functions :/
Also found a few bugs in the Epson code this way. And I moved the round
seconds actions and flag clear to +125us after flag set.
So, if you had the old r06 or r07, please delete those.
Unfortunately, this took all of my energy today, so the file names
inside manifest changes will have to be in the next WIP.
EDIT: ran a diff against old r07 and new r06.
- added if(days == 31) case twice in EpsonRTC::tick_day()
- forgot weekday = 0; in SharpRTC::load()
- need to move the cartridge+cheat objects up in sfc/Makefile again
- System::init() needs assert(interface != nullptr /* not 0 */)
2012-05-24 23:26:06 +00:00
|
|
|
uint1 ready;
|
2012-05-23 11:27:45 +00:00
|
|
|
uint1 holdtick;
|
2012-05-21 10:56:48 +00:00
|
|
|
|
|
|
|
uint4 secondlo;
|
|
|
|
uint3 secondhi;
|
|
|
|
uint1 batteryfailure;
|
|
|
|
|
|
|
|
uint4 minutelo;
|
|
|
|
uint3 minutehi;
|
2012-05-23 11:27:45 +00:00
|
|
|
uint1 resync;
|
2012-05-21 10:56:48 +00:00
|
|
|
|
|
|
|
uint4 hourlo;
|
|
|
|
uint2 hourhi;
|
|
|
|
uint1 meridian;
|
|
|
|
|
|
|
|
uint4 daylo;
|
|
|
|
uint2 dayhi;
|
|
|
|
uint1 dayram;
|
|
|
|
|
|
|
|
uint4 monthlo;
|
|
|
|
uint1 monthhi;
|
|
|
|
uint2 monthram;
|
|
|
|
|
|
|
|
uint4 yearlo;
|
|
|
|
uint4 yearhi;
|
|
|
|
|
|
|
|
uint3 weekday;
|
|
|
|
|
|
|
|
uint1 hold;
|
|
|
|
uint1 calendar;
|
|
|
|
uint1 irqflag;
|
|
|
|
uint1 roundseconds;
|
|
|
|
|
|
|
|
uint1 irqmask;
|
|
|
|
uint1 irqduty;
|
|
|
|
uint2 irqperiod;
|
|
|
|
|
|
|
|
uint1 pause;
|
|
|
|
uint1 stop;
|
|
|
|
uint1 atime; //astronomical time (24-hour mode)
|
|
|
|
uint1 test;
|
|
|
|
|
|
|
|
//memory.cpp
|
2015-11-14 00:52:51 +00:00
|
|
|
auto rtc_reset() -> void;
|
|
|
|
auto rtc_read(uint4 addr) -> uint4;
|
|
|
|
auto rtc_write(uint4 addr, uint4 data) -> void;
|
2012-05-21 10:56:48 +00:00
|
|
|
|
2015-11-14 00:52:51 +00:00
|
|
|
auto load(const uint8* data) -> void;
|
|
|
|
auto save(uint8* data) -> void;
|
2012-05-21 10:56:48 +00:00
|
|
|
|
|
|
|
//time.cpp
|
2015-11-14 00:52:51 +00:00
|
|
|
auto irq(uint2 period) -> void;
|
|
|
|
auto duty() -> void;
|
|
|
|
auto round_seconds() -> void;
|
|
|
|
auto tick() -> void;
|
|
|
|
|
|
|
|
auto tick_second() -> void;
|
|
|
|
auto tick_minute() -> void;
|
|
|
|
auto tick_hour() -> void;
|
|
|
|
auto tick_day() -> void;
|
|
|
|
auto tick_month() -> void;
|
|
|
|
auto tick_year() -> void;
|
2012-05-21 10:56:48 +00:00
|
|
|
};
|
|
|
|
|
2012-05-22 12:10:00 +00:00
|
|
|
extern EpsonRTC epsonrtc;
|