summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/machine/macrtc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mess/machine/macrtc.c')
-rw-r--r--src/mess/machine/macrtc.c117
1 files changed, 58 insertions, 59 deletions
diff --git a/src/mess/machine/macrtc.c b/src/mess/machine/macrtc.c
index c267f1f8428..bf4d41966f8 100644
--- a/src/mess/machine/macrtc.c
+++ b/src/mess/machine/macrtc.c
@@ -13,9 +13,9 @@
#include "macrtc.h"
#ifdef MAME_DEBUG
-#define LOG_RTC 0
+#define LOG_RTC 0
#else
-#define LOG_RTC 0
+#define LOG_RTC 0
#endif
enum
@@ -39,9 +39,9 @@ const device_type RTC3430042 = &device_creator<rtc3430042_device>;
//-------------------------------------------------
rtc3430042_device::rtc3430042_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, RTC3430042, "Apple 343-0042 clock/PRAM", tag, owner, clock),
- device_rtc_interface(mconfig, *this),
- device_nvram_interface(mconfig, *this)
+ : device_t(mconfig, RTC3430042, "Apple 343-0042 clock/PRAM", tag, owner, clock),
+ device_rtc_interface(mconfig, *this),
+ device_nvram_interface(mconfig, *this)
{
}
@@ -62,7 +62,7 @@ void rtc3430042_device::device_reset()
{
set_current_time(machine());
- m_rtc_rTCEnb = 0;
+ m_rtc_rTCEnb = 0;
m_rtc_rTCClk = 0;
m_rtc_bit_count = 0;
m_rtc_data_dir = 0;
@@ -81,7 +81,7 @@ void rtc3430042_device::device_reset()
void rtc3430042_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
- advance_seconds();
+ advance_seconds();
}
//-------------------------------------------------
@@ -90,35 +90,35 @@ void rtc3430042_device::device_timer(emu_timer &timer, device_timer_id id, int p
void rtc3430042_device::rtc_clock_updated(int year, int month, int day, int day_of_week, int hour, int minute, int second)
{
- struct tm cur_time, mac_reference;
- UINT32 seconds;
-
- cur_time.tm_sec = second;
- cur_time.tm_min = minute;
- cur_time.tm_hour = hour;
- cur_time.tm_mday = day;
- cur_time.tm_mon = month-1;
- cur_time.tm_year = year+100; // assumes post-2000 current system time
- cur_time.tm_isdst = 0;
-
- /* The count starts on 1st January 1904 */
- mac_reference.tm_sec = 0;
- mac_reference.tm_min = 0;
- mac_reference.tm_hour = 0;
- mac_reference.tm_mday = 1;
- mac_reference.tm_mon = 0;
- mac_reference.tm_year = 4;
- mac_reference.tm_isdst = 0;
-
- seconds = difftime(mktime(&cur_time), mktime(&mac_reference));
-
- if (LOG_RTC)
- logerror("second count 0x%lX\n", (unsigned long) seconds);
-
- m_rtc_seconds[0] = seconds & 0xff;
- m_rtc_seconds[1] = (seconds >> 8) & 0xff;
- m_rtc_seconds[2] = (seconds >> 16) & 0xff;
- m_rtc_seconds[3] = (seconds >> 24) & 0xff;
+ struct tm cur_time, mac_reference;
+ UINT32 seconds;
+
+ cur_time.tm_sec = second;
+ cur_time.tm_min = minute;
+ cur_time.tm_hour = hour;
+ cur_time.tm_mday = day;
+ cur_time.tm_mon = month-1;
+ cur_time.tm_year = year+100; // assumes post-2000 current system time
+ cur_time.tm_isdst = 0;
+
+ /* The count starts on 1st January 1904 */
+ mac_reference.tm_sec = 0;
+ mac_reference.tm_min = 0;
+ mac_reference.tm_hour = 0;
+ mac_reference.tm_mday = 1;
+ mac_reference.tm_mon = 0;
+ mac_reference.tm_year = 4;
+ mac_reference.tm_isdst = 0;
+
+ seconds = difftime(mktime(&cur_time), mktime(&mac_reference));
+
+ if (LOG_RTC)
+ logerror("second count 0x%lX\n", (unsigned long) seconds);
+
+ m_rtc_seconds[0] = seconds & 0xff;
+ m_rtc_seconds[1] = (seconds >> 8) & 0xff;
+ m_rtc_seconds[2] = (seconds >> 16) & 0xff;
+ m_rtc_seconds[3] = (seconds >> 24) & 0xff;
}
/* write the rTCEnb state */
@@ -141,27 +141,27 @@ WRITE_LINE_MEMBER( rtc3430042_device::ce_w )
m_rtc_state = RTC_STATE_NORMAL;
}
- m_rtc_rTCEnb = state;
+ m_rtc_rTCEnb = state;
}
WRITE_LINE_MEMBER( rtc3430042_device::clk_w )
{
if ((!state) && (m_rtc_rTCClk))
- {
+ {
rtc_shift_data(m_data_latch & 0x01);
- }
+ }
- m_rtc_rTCClk = state;
+ m_rtc_rTCClk = state;
}
READ_LINE_MEMBER( rtc3430042_device::data_r )
{
- return m_rtc_data_out;
+ return m_rtc_data_out;
}
WRITE_LINE_MEMBER( rtc3430042_device::data_w )
{
- m_data_latch = state;
+ m_data_latch = state;
}
/* shift data (called on rTCClk high-to-low transition (?)) */
@@ -172,17 +172,17 @@ void rtc3430042_device::rtc_shift_data(int data)
return;
if (m_rtc_data_dir)
- { /* RTC -> VIA transmission */
+ { /* RTC -> VIA transmission */
m_rtc_data_out = (m_rtc_data_byte >> --m_rtc_bit_count) & 0x01;
if (LOG_RTC)
logerror("RTC shifted new data %d\n", m_rtc_data_out);
}
else
- { /* VIA -> RTC transmission */
+ { /* VIA -> RTC transmission */
m_rtc_data_byte = (m_rtc_data_byte << 1) | (data ? 1 : 0);
if (++m_rtc_bit_count == 8)
- { /* if one byte received, send to command interpreter */
+ { /* if one byte received, send to command interpreter */
rtc_execute_cmd(m_rtc_data_byte);
}
}
@@ -237,19 +237,19 @@ void rtc3430042_device::rtc_execute_cmd(int data)
return;
switch(i)
{
- case 0: case 1: case 2: case 3: /* seconds register */
- case 4: case 5: case 6: case 7: /* ??? (not described in IM III) */
- {
- /* after various tries, I assumed m_rtc_seconds[4+i] is mapped to m_rtc_seconds[i] */
- if (LOG_RTC)
- logerror("RTC clock write, address = %X, data = %X\n", i, (int) m_rtc_data_byte);
- m_rtc_seconds[i & 3] = m_rtc_data_byte;
-
- // TODO: call the base class's time set here
- }
+ case 0: case 1: case 2: case 3: /* seconds register */
+ case 4: case 5: case 6: case 7: /* ??? (not described in IM III) */
+ {
+ /* after various tries, I assumed m_rtc_seconds[4+i] is mapped to m_rtc_seconds[i] */
+ if (LOG_RTC)
+ logerror("RTC clock write, address = %X, data = %X\n", i, (int) m_rtc_data_byte);
+ m_rtc_seconds[i & 3] = m_rtc_data_byte;
+
+ // TODO: call the base class's time set here
+ }
break;
- case 8: case 9: case 10: case 11: /* RAM address $10-$13 */
+ case 8: case 9: case 10: case 11: /* RAM address $10-$13 */
if (LOG_RTC)
printf("PRAM write, address = %X, data = %X\n", i, (int) m_rtc_data_byte);
m_pram[i] = m_rtc_data_byte;
@@ -268,7 +268,7 @@ void rtc3430042_device::rtc_execute_cmd(int data)
m_rtc_write_protect = (m_rtc_data_byte & 0x80) ? TRUE : FALSE;
break;
- case 16: case 17: case 18: case 19: /* RAM address $00-$0f */
+ case 16: case 17: case 18: case 19: /* RAM address $00-$0f */
case 20: case 21: case 22: case 23:
case 24: case 25: case 26: case 27:
case 28: case 29: case 30: case 31:
@@ -287,7 +287,7 @@ void rtc3430042_device::rtc_execute_cmd(int data)
// always save this byte to m_rtc_cmd
m_rtc_cmd = m_rtc_data_byte;
- if ((m_rtc_cmd & 0x78) == 0x38) // extended command
+ if ((m_rtc_cmd & 0x78) == 0x38) // extended command
{
m_rtc_state = RTC_STATE_XPCOMMAND;
m_rtc_data_byte = 0;
@@ -361,4 +361,3 @@ void rtc3430042_device::nvram_write(emu_file &file)
{
file.write(m_pram, 0x100);
}
-