~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to src/emu/machine/e0516.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Emmanuel Kasper, Jordi Mallach
  • Date: 2012-06-05 20:02:23 UTC
  • mfrom: (0.3.1) (0.1.4)
  • Revision ID: package-import@ubuntu.com-20120605200223-gnlpogjrg6oqe9md
Tags: 0.146-1
[ Emmanuel Kasper ]
* New upstream release
* Drop patch to fix man pages section and patches to link with flac 
  and jpeg system lib: all this has been pushed upstream by Cesare Falco
* Add DM-Upload-Allowed: yes field.

[ Jordi Mallach ]
* Create a "gnu" TARGETOS stanza that defines NO_AFFINITY_NP.
* Stop setting TARGETOS to "unix" in d/rules. It should be autodetected,
  and set to the appropriate value.
* mame_manpage_section.patch: Change mame's manpage section to 6 (games),
  in the TH declaration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**********************************************************************
2
2
 
3
 
    E05-16 Real Time Clock emulation
 
3
    Microelectronic-Marin E050-16 Real Time Clock emulation
4
4
 
5
5
    Copyright MESS Team.
6
6
    Visit http://mamedev.org for licensing and usage restrictions.
27
27
};
28
28
 
29
29
 
30
 
// registers
31
 
enum
32
 
{
33
 
        SECOND = 0,
34
 
        MINUTE,
35
 
        HOUR,
36
 
        DAY,
37
 
        MONTH,
38
 
        DAY_OF_WEEK,
39
 
        YEAR,
40
 
        ALL
41
 
};
42
 
 
43
 
 
44
 
//**************************************************************************
45
 
//  INLINE HELPERS
46
 
//**************************************************************************
47
 
 
48
 
//-------------------------------------------------
49
 
//  advance_seconds -
50
 
//-------------------------------------------------
51
 
 
52
 
inline void e0516_device::advance_seconds()
53
 
{
54
 
        m_register[SECOND]++;
55
 
 
56
 
        if (m_register[SECOND] == 60)
57
 
        {
58
 
                m_register[SECOND] = 0;
59
 
                m_register[MINUTE]++;
60
 
        }
61
 
 
62
 
        if (m_register[MINUTE] == 60)
63
 
        {
64
 
                m_register[MINUTE] = 0;
65
 
                m_register[HOUR]++;
66
 
        }
67
 
 
68
 
        if (m_register[HOUR] == 24)
69
 
        {
70
 
                m_register[HOUR] = 0;
71
 
                m_register[DAY]++;
72
 
                m_register[DAY_OF_WEEK]++;
73
 
        }
74
 
 
75
 
        if (m_register[DAY_OF_WEEK] == 8)
76
 
        {
77
 
                m_register[DAY_OF_WEEK] = 1;
78
 
        }
79
 
 
80
 
        if (m_register[DAY] == 32)
81
 
        {
82
 
                m_register[DAY] = 1;
83
 
                m_register[MONTH]++;
84
 
        }
85
 
 
86
 
        if (m_register[MONTH] == 13)
87
 
        {
88
 
                m_register[MONTH] = 1;
89
 
                m_register[YEAR]++;
90
 
        }
91
 
}
92
 
 
93
 
 
94
30
 
95
31
//**************************************************************************
96
32
//  LIVE DEVICE
129
65
        save_item(NAME(m_state));
130
66
        save_item(NAME(m_bits));
131
67
        save_item(NAME(m_dio));
132
 
        save_item(NAME(m_register));
133
68
}
134
69
 
135
70
 
136
71
//-------------------------------------------------
137
 
//  device_start - device-specific reset
 
72
//  device_reset - device-specific reset
138
73
//-------------------------------------------------
139
74
 
140
75
void e0516_device::device_reset()
141
76
{
 
77
        set_current_time(machine());
142
78
}
143
79
 
144
80
 
153
89
 
154
90
 
155
91
//-------------------------------------------------
156
 
//  rtc_set_time - called to initialize the RTC to
157
 
//  a known state
158
 
//-------------------------------------------------
159
 
 
160
 
void e0516_device::rtc_set_time(int year, int month, int day, int day_of_week, int hour, int minute, int second)
161
 
{
162
 
        m_register[YEAR] = year;
163
 
        m_register[MONTH] = month;
164
 
        m_register[DAY] = day;
165
 
        m_register[DAY_OF_WEEK] = day_of_week + 1;
166
 
        m_register[HOUR] = hour;
167
 
        m_register[MINUTE] = minute;
168
 
        m_register[SECOND] = second;
169
 
}
170
 
 
171
 
 
172
 
//-------------------------------------------------
173
92
//  cs_w - chip select input
174
93
//-------------------------------------------------
175
94
 
176
95
WRITE_LINE_MEMBER( e0516_device::cs_w )
177
96
{
 
97
        if (LOG) logerror("E05-16 '%s' CS %u\n", tag(), state);
 
98
 
178
99
        m_cs = state;
179
100
 
180
101
        if (m_cs)
193
114
 
194
115
WRITE_LINE_MEMBER( e0516_device::clk_w )
195
116
{
 
117
        if (LOG) logerror("E05-16 '%s' CLK %u\n", tag(), state);
 
118
 
196
119
        m_clk = state;
197
120
 
198
121
        if (m_cs || m_clk) return;
215
138
                        if (BIT(m_reg_latch, 0))
216
139
                        {
217
140
                                // load register value to data latch
218
 
                                m_data_latch = m_register[m_reg_latch >> 1];
 
141
                                m_data_latch = convert_to_bcd(get_clock_register(m_reg_latch >> 1));
219
142
                        }
220
143
                }
221
144
        }
247
170
                        if (!BIT(m_reg_latch, 0))
248
171
                        {
249
172
                                // write latched data to register
250
 
                                m_register[m_reg_latch >> 1] = m_data_latch;
 
173
                                set_clock_register(m_reg_latch >> 1, bcd_to_integer(m_data_latch));
251
174
                        }
252
175
                }
253
176
        }
260
183
 
261
184
WRITE_LINE_MEMBER( e0516_device::dio_w )
262
185
{
 
186
        if (LOG) logerror("E05-16 '%s' DIO %u\n", tag(), state);
 
187
 
263
188
        m_dio = state;
264
189
}
265
190