Previous 15994 Revisions Next

r11209 Saturday 16th April, 2011 at 22:08:35 UTC by Curt Coder
- Fixed RP5C01 alarm output. [Curt Coder]
- Removed the old incomplete TC8521 emulation, and refactored all drivers to use RP5C01 instead, as it is the same chip. [Curt Coder]
- [NC100] Removed deprecated serial device. [Curt Coder]
- [NC100] Fixed screen size. [Curt Coder]
- [NC200] Demoted to GNW as it does not boot due to a bug in MC146818 UIP bit. [Curt Coder]
[src/emu/machine]rp5c01.c rp5c01.h
[src/mess]mess.mak
[src/mess/drivers]avigo.c msx.c nc.c pc4.c rex6000.c
[src/mess/includes]msx.h
[src/mess/machine]msx.c tc8521.c tc8521.h

src/emu/machine/rp5c01.c
r11208r11209
168168//**************************************************************************
169169
170170//-------------------------------------------------
171//  set_alarm_line -
172//-------------------------------------------------
173
174inline void rp5c01_device::set_alarm_line()
175{
176   int alarm = ((m_mode & MODE_ALARM_EN) ? m_alarm_on : 1) &
177            ((m_reset & RESET_16_HZ) ? 1 : m_16hz) &
178            ((m_reset & RESET_1_HZ) ? 1 : m_1hz);
179   
180   if (m_alarm != alarm)
181   {
182      if (LOG) logerror("RP5C01 '%s' Alarm %u\n", tag(), alarm);
183
184      devcb_call_write_line(&m_out_alarm_func, alarm);
185      m_alarm = alarm;
186   }
187}
188
189
190//-------------------------------------------------
171191//  read_counter -
172192//-------------------------------------------------
173193
r11208r11209
206226   }
207227
208228   write_counter(REGISTER_1_SECOND, seconds);
209   
210   if (!(m_mode & RESET_1_HZ))
211   {
212      // pulse 1Hz alarm signal
213      trigger_alarm();
214   }
215229}
216230
217231
r11208r11209
275289   m_reg[MODE00][REGISTER_DAY_OF_THE_WEEK] = day_of_week;
276290
277291   check_alarm();
292   set_alarm_line();
278293}
279294
280295
r11208r11209
284299
285300inline void rp5c01_device::check_alarm()
286301{
287   if (m_mode & MODE_ALARM_EN)
302   bool all_match = true;
303   bool all_zeroes = true;
304
305   for (int i = REGISTER_1_MINUTE; i < REGISTER_1_MONTH; i++)
288306   {
289      for (int i = REGISTER_1_MINUTE; i < REGISTER_1_MONTH; i++)
290      {
291         if (m_reg[MODE01][i] != m_reg[MODE00][i]) return;
292      }
293
294      trigger_alarm();
307      if (m_reg[MODE01][i] != 0) all_zeroes = false;
308      if (m_reg[MODE01][i] != m_reg[MODE00][i]) all_match = false;
295309   }
296}
297310
298
299//-------------------------------------------------
300//  trigger_alarm -
301//-------------------------------------------------
302
303inline void rp5c01_device::trigger_alarm()
304{
305   devcb_call_write_line(&m_out_alarm_func, 0);
306   devcb_call_write_line(&m_out_alarm_func, 1);
311   m_alarm_on = (all_match || (!m_alarm_on && all_zeroes)) ? 0 : 1;
307312}
308313
309314
r11208r11209
319324rp5c01_device::rp5c01_device(running_machine &_machine, const rp5c01_device_config &config)
320325    : device_t(_machine, config),
321326     device_nvram_interface(_machine, config, *this),
327     m_alarm(1),
328     m_alarm_on(1),
329     m_1hz(1),
330     m_16hz(1),
322331      m_config(config)
323332{
324333}
r11208r11209
335344
336345   // allocate timers
337346   m_clock_timer = timer_alloc(TIMER_CLOCK);
338   m_clock_timer->adjust(attotime::from_hz(clock() / 32768), 0, attotime::from_hz(clock() / 32768));
347   m_clock_timer->adjust(attotime::from_hz(clock() / 16384), 0, attotime::from_hz(clock() / 16384));
339348   
340   m_alarm_timer = timer_alloc(TIMER_ALARM);
341   m_alarm_timer->adjust(attotime::from_hz(clock() / 2048), 0, attotime::from_hz(clock() / 2048));
349   m_16hz_timer = timer_alloc(TIMER_16HZ);
350   m_16hz_timer->adjust(attotime::from_hz(clock() / 1024), 0, attotime::from_hz(clock() / 1024));
342351
343352   // state saving
344353   save_item(NAME(m_reg[MODE00]));
345354   save_item(NAME(m_reg[MODE01]));
346355   save_item(NAME(m_mode));
347356   save_item(NAME(m_reset));
357   save_item(NAME(m_alarm));
358   save_item(NAME(m_alarm_on));
359   save_item(NAME(m_1hz));
360   save_item(NAME(m_16hz));
348361}
349362
350363
r11208r11209
357370   switch (id)
358371   {
359372   case TIMER_CLOCK:
360      advance_seconds();
361      break;
362
363   case TIMER_ALARM:
364      if (!(m_reset & RESET_16_HZ))
373      if (m_1hz && (m_mode & MODE_TIMER_EN))
365374      {
366         trigger_alarm();
375         advance_seconds();
367376      }
377
378      m_1hz = !m_1hz;
379      set_alarm_line();
368380      break;
381
382   case TIMER_16HZ:
383      m_16hz = !m_16hz;
384      set_alarm_line();
385      break;
369386   }
370387}
371388
r11208r11209
449466      break;
450467   }
451468
452   return data;
469   if (LOG) logerror("RP5C01 '%s' Register %u Read %02x\n", tag(), offset & 0x0f, data);
470
471   return data & 0x0f;
453472}
454473
455474
r11208r11209
464483   switch (offset & 0x0f)
465484   {
466485   case REGISTER_MODE:
467      m_mode = data;
486      m_mode = data & 0x0f;
468487
469      m_clock_timer->enable(data & MODE_TIMER_EN);
470
471488      if (LOG)
472489      {
473490         logerror("RP5C01 '%s' Mode %u\n", tag(), data & MODE_MASK);
r11208r11209
481498      break;
482499
483500   case REGISTER_RESET:
484      m_reset = data;
501      m_reset = data & 0x0f;
485502
486503      if (data & RESET_ALARM)
487504      {
src/emu/machine/rp5c01.h
r11208r11209
1111                    CS   2 |             | 17  OSCOUT
1212                   ADJ   3 |             | 16  OSCIN
1313                    A0   4 |   RP5C01    | 15  _ALARM
14                    A1   5 |   RP5C01   | 14  D3
14                    A1   5 |   RP5C01A   | 14  D3
1515                    A2   6 |   RF5C01A   | 13  D2
16                    A3   7 |             | 12  D1
16                    A3   7 |   TC8521    | 12  D1
1717                   _RD   8 |             | 11  D0
1818                   GND   9 |_____________| 10  _WR
1919
r11208r11209
104104   virtual void nvram_write(emu_file &file);
105105
106106private:
107   inline void set_alarm_line();
107108   inline int read_counter(int counter);
108109   inline void write_counter(int counter, int value);
109110   inline void advance_seconds();
110111   inline void advance_minutes();
111   inline void trigger_alarm();
112112   inline void check_alarm();
113113
114114   static const device_timer_id TIMER_CLOCK = 0;
115   static const device_timer_id TIMER_ALARM = 1;
115   static const device_timer_id TIMER_16HZ = 1;
116116
117117   devcb_resolved_write_line   m_out_alarm_func;
118118
r11208r11209
121121
122122   UINT8 m_mode;            // mode register
123123   UINT8 m_reset;            // reset register
124   int m_alarm;            // alarm output
125   int m_alarm_on;            // alarm condition
126   int m_1hz;               // 1 Hz condition
127   int m_16hz;               // 16 Hz condition
124128
125129   // timers
126130   emu_timer *m_clock_timer;
127   emu_timer *m_alarm_timer;
131   emu_timer *m_16hz_timer;
128132
129133   const rp5c01_device_config &m_config;
130134};
src/mess/machine/tc8521.c
r11208r11209
1/*********************************************************************
2
3    tc8521.h
4
5    Toshiba TC8251 Real Time Clock code
6
7    (or RICOH RF5C01A)
8
9    Registers:
10
11        Page 0/Mode 0 (timer):
12
13        0x00: 1-second counter
14        0x01: 10-second counter
15        0x02: 1-minute counter
16        0x03: 10-minute counter
17        0x04: 1-hour counter
18        0x05: 10-hour counter
19        0x06: day-of-the-week counter
20        0x07: 1-day counter
21        0x08: 10-day counter
22        0x09: 1-month counter
23        0x0A: 10-month counter
24        0x0b: 1-year counter
25        0x0c: 10-year counter
26
27        Page 1/Mode 1 (alarm):
28        0x00: unused
29        0x01: unused
30        0x02: 1-minute alarm
31        0x03: 10-minute alarm
32        0x04: 1-hour alarm
33        0x05: 10-hour alarm
34        0x06: day-of-the-week alarm
35        0x07: 1-day alarm
36        0x08: 10-day alarm
37        0x09: unused
38        0x0a: 12/24 hour select register
39        0x0b: leap year counter
40        0x0c: unused
41
42        Page 2/Mode 2 (ram block 1) and
43        Page 3/Mode 3 (ram block 2):
44        0x00: ram
45        0x01: ram
46        0x02: ram
47        0x03: ram
48        0x04: ram
49        0x05: ram
50        0x06: ram
51        0x07: ram
52        0x08: ram
53        0x09: ram
54        0x0a: ram
55        0x0b: ram
56        0x0c: ram
57
58
59        registers common to all modes:
60
61        0x0d: MODE register
62            bit 3: timer enable
63            bit 2: alarm enable
64            bit 1,0: mode/page select
65        0x0e: test register
66            bit 3: test 3
67            bit 2: test 2
68            bit 1: test 1
69            bit 0: test 0
70        0x0f: RESET etc
71            bit 3: 1 Hz enable
72            bit 2: 16 Hz enable
73            bit 1: timer reset
74            bit 0: alarm reset
75
76*********************************************************************/
77
78#include "emu.h"
79#include "tc8521.h"
80
81
82/***************************************************************************
83    CONSTANTS
84***************************************************************************/
85
86#define TC8521_TIMER_1_SECOND_COUNTER 0x00
87#define TC8521_TIMER_10_SECOND_COUNTER 0x01
88#define TC8521_TIMER_1_MINUTE_COUNTER 0x02
89#define TC8521_TIMER_10_MINUTE_COUNTER 0x03
90#define TC8521_TIMER_1_HOUR_COUNTER 0x04
91#define TC8521_TIMER_10_HOUR_COUNTER 0x05
92#define TC8521_TIMER_DAY_OF_THE_WEEK_COUNTER 0x06
93#define TC8521_TIMER_1_DAY_COUNTER 0x07
94#define TC8521_TIMER_10_DAY_COUNTER 0x08
95#define TC8521_TIMER_1_MONTH_COUNTER 0x09
96#define TC8521_TIMER_10_MONTH_COUNTER 0x0a
97#define TC8521_TIMER_1_YEAR_COUNTER 0x0b
98#define TC8521_TIMER_10_YEAR_COUNTER 0x0c
99
100#define TC8521_MODE_REGISTER 0x0d
101#define TC8521_TEST_REGISTER 0x0e
102#define TC8521_RESET_REGISTER 0x0f
103
104#define TC8521_ALARM_1_MINUTE_REGISTER 0x012
105#define TC8521_ALARM_10_MINUTE_REGISTER 0x013
106#define TC8521_ALARM_1_HOUR_REGISTER 0x014
107#define TC8521_ALARM_10_HOUR_REGISTER 0x015
108#define TC8521_ALARM_DAY_OF_THE_WEEK_REGISTER 0x016
109#define TC8521_ALARM_1_DAY_REGISTER 0x017
110#define TC8521_ALARM_10_DAY_REGISTER 0x018
111
112#define VERBOSE 0
113#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
114
115#define ALARM_OUTPUT_16HZ   0x01
116#define ALARM_OUTPUT_1HZ   0x02
117#define ALARM_OUTPUT_ALARM   0X04
118
119
120/***************************************************************************
121    TYPE DEFINITIONS
122***************************************************************************/
123
124typedef struct _tc8521_t tc8521_t;
125struct _tc8521_t
126{
127   /* 4 register pages (timer, alarm, ram1 and ram2) */
128    unsigned char registers[16*4];
129   UINT32 alarm_outputs;
130   UINT32 thirty_two_hz_counter;
131};
132
133
134/***************************************************************************
135    INLINE FUNCTIONS
136***************************************************************************/
137
138INLINE tc8521_t *get_token(device_t *device)
139{
140   assert(device != NULL);
141   assert(device->type() == TC8521);
142   return (tc8521_t *) downcast<legacy_device_base *>(device)->token();
143}
144
145
146INLINE const tc8521_interface *get_interface(device_t *device)
147{
148   assert(device != NULL);
149   assert(device->type() == TC8521);
150   return (tc8521_interface *) device->baseconfig().static_config();
151}
152
153
154/***************************************************************************
155    GLOBAL VARIABLES
156***************************************************************************/
157
158const tc8521_interface default_tc8521_interface = {0, };
159
160
161/***************************************************************************
162    LOCAL VARIABLES
163***************************************************************************/
164
165/* mask data with these values when writing */
166static const UINT8 rtc_write_masks[16*4]=
167{
168   0x0f,0x07,0x0f,0x07,0x0f,0x03,0x07,0x0f,0x03,0x0f,0x03,0x0f,0x0f,0x0f, 0x0f, 0x0f,
169   0x00,0x00,0x0f,0x07,0x0f,0x03,0x07,0x0f,0x03,0x00,0x01,0x03,0x00,0x0f, 0x0f, 0x0f,
170   0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, 0x0f, 0x0f,
171   0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f, 0x0f, 0x0f,
172};
173
174
175
176/***************************************************************************
177    IMPLEMENTATION
178***************************************************************************/
179
180/*-------------------------------------------------
181    tc8521_load_stream - read tc8521 data from
182    supplied file
183-------------------------------------------------*/
184
185void tc8521_load_stream(device_t *device, emu_file *file)
186{
187   tc8521_t *rtc = get_token(device);
188
189   if (file)
190   {
191      file->read(&rtc->registers[0], sizeof(unsigned char)*16*4);
192      file->read(&rtc->alarm_outputs, sizeof(UINT32));
193      file->read(&rtc->thirty_two_hz_counter, sizeof(UINT32));
194   }
195}
196
197
198
199/*-------------------------------------------------
200    tc8521_save_stream - write tc8521 data to
201    supplied file
202-------------------------------------------------*/
203
204void tc8521_save_stream(device_t *device, emu_file *file)
205{
206   tc8521_t *rtc = get_token(device);
207
208   if (file)
209   {
210      file->write(&rtc->registers[0], sizeof(unsigned char)*16*4);
211      file->write(&rtc->alarm_outputs, sizeof(UINT32));
212      file->write(&rtc->thirty_two_hz_counter, sizeof(UINT32));
213   }
214}
215
216
217
218/*-------------------------------------------------
219    tc8521_set_alarm_output
220-------------------------------------------------*/
221
222static void tc8521_set_alarm_output(device_t *device)
223{
224   tc8521_t *rtc = get_token(device);
225   const tc8521_interface *rtc_interface = get_interface(device);
226   unsigned char alarm_output;
227
228   alarm_output = 0;
229
230   /* what happens when all are enabled? I assume they are all or'd together */
231
232   /* 16 Hz enabled? */
233    if ((rtc->registers[TC8521_RESET_REGISTER] & (1<<2))==0)
234    {
235      /* yes */
236
237      /* add in state of 16 Hz output */
238      alarm_output |= (rtc->alarm_outputs & ALARM_OUTPUT_16HZ);
239   }
240
241   if ((rtc->registers[TC8521_RESET_REGISTER] & (1<<3))==0)
242   {
243      /* yes */
244      /* add in stat of 1 Hz output */
245      alarm_output |= ((rtc->alarm_outputs & ALARM_OUTPUT_1HZ)>>1);
246   }
247
248   alarm_output |= ((rtc->alarm_outputs & ALARM_OUTPUT_ALARM)>>2);
249
250   /* if it's not enabled, then there is no output */
251   if (!((rtc->registers[TC8521_MODE_REGISTER] & (1<<2))!=0))
252   {
253      /* alarm output enabled? */
254      alarm_output &= ~1;
255   }
256
257    if (rtc_interface->alarm_output_callback != NULL)
258    {
259      (*rtc_interface->alarm_output_callback)(device, alarm_output);
260   }
261}
262
263
264
265/*-------------------------------------------------
266    tc8521_alarm_check
267-------------------------------------------------*/
268
269static void tc8521_alarm_check(device_t *device)
270{
271   tc8521_t *rtc = get_token(device);
272
273   rtc->alarm_outputs &= ~ALARM_OUTPUT_ALARM;
274   if (
275      (rtc->registers[TC8521_TIMER_1_MINUTE_COUNTER]==rtc->registers[TC8521_ALARM_1_MINUTE_REGISTER]) &&
276      (rtc->registers[TC8521_TIMER_10_MINUTE_COUNTER]==rtc->registers[TC8521_ALARM_10_MINUTE_REGISTER]) &&
277      (rtc->registers[TC8521_TIMER_1_HOUR_COUNTER]==rtc->registers[TC8521_ALARM_1_HOUR_REGISTER]) &&
278      (rtc->registers[TC8521_TIMER_10_HOUR_COUNTER]==rtc->registers[TC8521_ALARM_10_HOUR_REGISTER]) &&
279      (rtc->registers[TC8521_TIMER_1_DAY_COUNTER]==rtc->registers[TC8521_ALARM_1_DAY_REGISTER]) &&
280      (rtc->registers[TC8521_TIMER_10_DAY_COUNTER]==rtc->registers[TC8521_ALARM_10_DAY_REGISTER]) &&
281      (rtc->registers[TC8521_TIMER_DAY_OF_THE_WEEK_COUNTER]==rtc->registers[TC8521_ALARM_DAY_OF_THE_WEEK_REGISTER])
282      )
283   {
284      rtc->alarm_outputs |= ALARM_OUTPUT_ALARM;
285   }
286
287   tc8521_set_alarm_output(device);
288}
289
290
291
292/*-------------------------------------------------
293    tc8521_timer_callback
294-------------------------------------------------*/
295
296static TIMER_CALLBACK(tc8521_timer_callback)
297{
298   device_t *device = (device_t *)ptr;
299   tc8521_t *rtc = get_token(device);
300
301   /* Assumption how it works */
302   /* 16 Hz output = 16 cycles per second, 16 cycles of high-low from counter */
303
304   /* toggle 16 Hz wave state */
305   rtc->alarm_outputs ^= ALARM_OUTPUT_16HZ;
306   /* set in alarm output */
307   tc8521_set_alarm_output(device);
308
309   rtc->thirty_two_hz_counter++;
310
311   if (rtc->thirty_two_hz_counter==16)
312   {
313      rtc->thirty_two_hz_counter = 0;
314
315      /* toggle 1 Hz output */
316      rtc->alarm_outputs ^= ALARM_OUTPUT_1HZ;
317      /* set in alarm output */
318      tc8521_set_alarm_output(device);
319
320      if ((rtc->alarm_outputs & ALARM_OUTPUT_1HZ)==0)
321      {
322         /* timer enable? */
323         if ((rtc->registers[0x0d] & (1<<3))!=0)
324         {
325            /* seconds; units */
326            rtc->registers[0]++;
327
328            if (rtc->registers[0]==10)
329            {
330               rtc->registers[0] = 0;
331
332               /* seconds; tens */
333               rtc->registers[1]++;
334
335               if (rtc->registers[1]==6)
336               {
337                 rtc->registers[1] = 0;
338
339                 /* minutes; units */
340                 rtc->registers[2]++;
341
342                 if (rtc->registers[2]==10)
343                 {
344                    rtc->registers[2] = 0;
345
346                    /* minutes; tens */
347                    rtc->registers[3]++;
348
349                    if (rtc->registers[3] == 6)
350                    {
351                      rtc->registers[3] = 0;
352
353                      /* hours; units */
354                      rtc->registers[4]++;
355
356                      if (rtc->registers[4] == 10)
357                      {
358                        rtc->registers[4] = 0;
359
360                        /* hours; tens */
361                        rtc->registers[4]++;
362
363                        if (rtc->registers[4] == 24)
364                        {
365                           /* TODO: finish rest of increments here! */
366                           rtc->registers[4] = 0;
367                        }
368                      }
369                    }
370                 }
371
372                 tc8521_alarm_check(device);
373               }
374            }
375         }
376      }
377   }
378}
379
380
381
382/*-------------------------------------------------
383    DEVICE_START( tc8521 )
384-------------------------------------------------*/
385
386static DEVICE_START( tc8521 )
387{
388   tc8521_t *rtc = get_token(device);
389   memset(rtc, 0, sizeof(*rtc));
390   device->machine().scheduler().timer_pulse(attotime::from_hz(32), FUNC(tc8521_timer_callback), 0, (void *) device);
391}
392
393
394
395/*-------------------------------------------------
396    tc8521_r
397-------------------------------------------------*/
398
399READ8_DEVICE_HANDLER(tc8521_r)
400{
401   tc8521_t *rtc = get_token(device);
402   UINT32 register_index;
403
404   switch (offset)
405   {
406      /* control registers */
407      case 0x0d:
408      case 0x0e:
409      case 0x0f:
410         LOG(("8521 RTC R: %04x %02x\n", offset, rtc->registers[offset]));
411         return rtc->registers[offset];
412
413      default:
414         break;
415   }
416
417   /* register in selected page */
418   register_index = ((rtc->registers[TC8521_MODE_REGISTER] & 0x03)<<4) | (offset & 0x0f);
419   LOG(("8521 RTC R: %04x %02x\n", offset, rtc->registers[register_index]));
420   /* data from selected page */
421   return rtc->registers[register_index];
422}
423
424
425
426/*-------------------------------------------------
427    tc8521_w
428-------------------------------------------------*/
429
430WRITE8_DEVICE_HANDLER(tc8521_w)
431{
432   tc8521_t *rtc = get_token(device);
433   UINT32 register_index;
434
435   LOG(("8521 RTC W: %04x %02x\n", offset, data));
436
437   switch (offset)
438   {
439      case 0x0D:
440      {
441         if (data & 0x08)
442         {
443            LOG(("timer enable\n"));
444         }
445
446         if (data & 0x04)
447         {
448            LOG(("alarm enable\n"));
449         }
450
451         logerror("page %02x selected\n", data & 0x03);
452      }
453      break;
454
455      case 0x0e:
456      {
457         if (data & 0x08)
458         {
459            LOG(("test 3\n"));
460         }
461
462         if (data & 0x04)
463         {
464            LOG(("test 2\n"));
465         }
466
467         if (data & 0x02)
468         {
469            LOG(("test 1\n"));
470         }
471
472         if (data & 0x01)
473         {
474            LOG(("test 0\n"));
475         }
476      }
477      break;
478
479      case 0x0f:
480      {
481         if ((data & 0x08)==0)
482         {
483            LOG(("1 Hz enable\n"));
484         }
485
486         if ((data & 0x04)==0)
487         {
488            LOG(("16 Hz enable\n"));
489         }
490
491         if (data & 0x02)
492         {
493            LOG(("reset timer\n"));
494         }
495
496         if (data & 0x01)
497         {
498            LOG(("reset alarm\n"));
499         }
500      }
501      break;
502
503      default:
504         break;
505   }
506
507   switch (offset)
508   {
509      /* control registers */
510      case 0x0d:
511      case 0x0e:
512      case 0x0f:
513         rtc->registers[offset] = data & rtc_write_masks[offset];
514         return;
515      default:
516         break;
517   }
518
519   /* register in selected page */
520   register_index = ((rtc->registers[TC8521_MODE_REGISTER] & 0x03)<<4) | (offset & 0x0f);
521
522   /* write and mask data */
523   rtc->registers[register_index] = data & rtc_write_masks[register_index];
524}
525
526
527
528/*-------------------------------------------------
529    DEVICE_GET_INFO( tc8521 )
530-------------------------------------------------*/
531
532DEVICE_GET_INFO( tc8521 )
533{
534   switch (state)
535   {
536      /* --- the following bits of info are returned as 64-bit signed integers --- */
537      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(tc8521_t);               break;
538      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
539
540      /* --- the following bits of info are returned as pointers to data or functions --- */
541      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(tc8521);   break;
542      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
543      case DEVINFO_FCT_RESET:                     /* Nothing */                        break;
544
545      /* --- the following bits of info are returned as NULL-terminated strings --- */
546      case DEVINFO_STR_NAME:                     strcpy(info->s, "Toshiba 8521 RTC");      break;
547      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Toshiba 8521 RTC");      break;
548      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
549      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
550      case DEVINFO_STR_CREDITS:                  /* Nothing */                        break;
551   }
552}
553
554DEFINE_LEGACY_DEVICE(TC8521, tc8521);
src/mess/machine/tc8521.h
r11208r11209
1/*********************************************************************
2
3    tc8521.h
4
5    Toshiba TC8251 Real Time Clock code
6
7*********************************************************************/
8
9#ifndef __TC8521_H__
10#define __TC8525_H__
11
12
13/***************************************************************************
14    MACROS
15***************************************************************************/
16
17DECLARE_LEGACY_DEVICE(TC8521, tc8521);
18
19#define MCFG_TC8521_ADD(_tag, _intrf) \
20   MCFG_DEVICE_ADD(_tag, TC8521, 0) \
21   MCFG_DEVICE_CONFIG(_intrf)
22
23#define MCFG_TC8521_REMOVE(_tag) \
24   MCFG_DEVICE_REMOVE(_tag)
25
26
27
28/***************************************************************************
29    TYPE DEFINITIONS
30***************************************************************************/
31
32typedef struct _tc8521_interface tc8521_interface;
33struct _tc8521_interface
34{
35   /* output of alarm */
36   void (*alarm_output_callback)(device_t *device, int);
37};
38
39
40
41/***************************************************************************
42    FUNCTION PROTOTYPES
43***************************************************************************/
44
45extern const tc8521_interface default_tc8521_interface;
46
47READ8_DEVICE_HANDLER(tc8521_r);
48WRITE8_DEVICE_HANDLER(tc8521_w);
49
50void tc8521_load_stream(device_t *device, emu_file *file);
51void tc8521_save_stream(device_t *device, emu_file *file);
52
53
54#endif /* __TC8521_H__ */
src/mess/machine/msx.c
r11208r11209
1515#include "machine/i8255a.h"
1616#include "includes/msx_slot.h"
1717#include "includes/msx.h"
18#include "machine/tc8521.h"
18#include "machine/rp5c01.h"
1919#include "machine/wd17xx.h"
2020#include "imagedev/flopdrv.h"
2121#include "formats/basicdsk.h"
r11208r11209
672672WRITE8_HANDLER (msx_rtc_reg_w)
673673{
674674   msx_state *state = space->machine().driver_data<msx_state>();
675   device_t *rtc = space->machine().device("rtc");
676   tc8521_w(rtc, state->m_rtc_latch, data);
675   rp5c01_device *rtc = space->machine().device<rp5c01_device>(TC8521_TAG);
676   rtc->write(*space, state->m_rtc_latch, data);
677677}
678678
679679READ8_HANDLER (msx_rtc_reg_r)
680680{
681681   msx_state *state = space->machine().driver_data<msx_state>();
682   device_t *rtc = space->machine().device("rtc");
683   return tc8521_r(rtc, state->m_rtc_latch);
682   rp5c01_device *rtc = space->machine().device<rp5c01_device>(TC8521_TAG);
683   return rtc->read(*space, state->m_rtc_latch);
684684}
685685
686NVRAM_HANDLER( msx2 )
687{
688   device_t *rtc = machine.device("rtc");
689   if (file)
690   {
691      if (read_or_write)
692         tc8521_save_stream (rtc, file);
693      else
694         tc8521_load_stream (rtc, file);
695   }
696}
697
698686/*
699687From: erbo@xs4all.nl (erik de boer)
700688
src/mess/includes/msx.h
r11208r11209
1212
1313#define MSX_MAX_CARTS   (2)
1414
15#define TC8521_TAG   "rtc"
16
1517class msx_state : public driver_device
1618{
1719public:
r11208r11209
6264extern MACHINE_RESET( msx2 );
6365extern INTERRUPT_GEN( msx_interrupt );
6466extern INTERRUPT_GEN( msx2_interrupt );
65extern NVRAM_HANDLER( msx2 );
6667
6768DEVICE_IMAGE_LOAD( msx_cart );
6869DEVICE_IMAGE_UNLOAD( msx_cart );
src/mess/mess.mak
r11208r11209
537537   $(MESS_MACHINE)/smartmed.o   \
538538   $(MESS_MACHINE)/smc92x4.o   \
539539   $(MESS_MACHINE)/sst39vfx.o   \
540   $(MESS_MACHINE)/tc8521.o   \
541540   $(MESS_MACHINE)/terminal.o   \
542541   $(MESS_MACHINE)/teleprinter.o   \
543542   $(MESS_MACHINE)/upd7002.o   \
src/mess/drivers/rex6000.c
r11208r11209
2020
2121#include "emu.h"
2222#include "cpu/z80/z80.h"
23#include "machine/tc8521.h"
23#include "machine/rp5c01.h"
2424#include "machine/ram.h"
2525#include "imagedev/snapquik.h"
2626#include "sound/beep.h"
r11208r11209
3737#define   IRQ_FLAG_IRQ1      0x40
3838#define   IRQ_FLAG_EVENT      0x80
3939
40#define TC8521_TAG   "rtc"
41
4042class rex6000_state : public driver_device
4143{
4244public:
r11208r11209
322324   AM_RANGE( 0x10, 0x10 ) AM_READ_PORT("INPUT")
323325   AM_RANGE( 0x15, 0x19 ) AM_READWRITE(beep_r, beep_w)
324326   AM_RANGE( 0x22, 0x23 ) AM_READWRITE(lcd_base_r, lcd_base_w)
325   AM_RANGE( 0x30, 0x3f ) AM_DEVREADWRITE_LEGACY("rtc", tc8521_r, tc8521_w)
327   AM_RANGE( 0x30, 0x3f ) AM_DEVREADWRITE(TC8521_TAG, rp5c01_device, read, write)
326328   AM_RANGE( 0x40, 0x47 ) AM_MIRROR(0x08)   AM_NOP   //SIO
327329   AM_RANGE( 0x50, 0x51 ) AM_READWRITE(lcd_io_r, lcd_io_w)
328330   AM_RANGE( 0x60, 0x6f ) AM_READWRITE(touchscreen_r, touchscreen_w)
r11208r11209
526528GFXDECODE_END
527529
528530
529static const tc8521_interface rex6000_tc8521_interface =
531static RP5C01_INTERFACE( rtc_intf )
530532{
531   NULL
533   DEVCB_NULL
532534};
533535
534536static MACHINE_CONFIG_START( rex6000, rex6000_state )
r11208r11209
556558   /* quickload */
557559   MCFG_QUICKLOAD_ADD("quickload", rex6000, "rex,ds2", 0)
558560
559   MCFG_TC8521_ADD("rtc", rex6000_tc8521_interface)
561   MCFG_RP5C01_ADD(TC8521_TAG, XTAL_32_768kHz, rtc_intf)
560562
561563   /* internal ram */
562564   MCFG_RAM_ADD(RAM_TAG)
src/mess/drivers/nc.c
r11208r11209
101101#include "machine/ctronics.h"
102102#include "machine/msm8251.h"   /* for NC100 uart */
103103#include "machine/mc146818.h"   /* for NC200 real time clock */
104#include "machine/tc8521.h"   /* for NC100 real time clock */
104#include "machine/rp5c01.h"   /* for NC100 real time clock */
105105#include "machine/upd765.h"      /* for NC200 disk drive interface */
106106#include "imagedev/flopdrv.h"   /* for NC200 disk image */
107107#include "formats/pc_dsk.h"      /* for NC200 disk image */
r11208r11209
466466   nc_state *state = machine.driver_data<nc_state>();
467467   char filename[MAX_DRIVER_NAME_CHARS + 5];
468468
469   sprintf(filename,"%s.nv", machine.system().name);
469   sprintf(filename,"%s.hack", machine.system().name);
470470
471471   state->m_file = global_alloc(emu_file(machine.options().memcard_directory(), OPEN_FLAG_WRITE));
472472   state->m_file->open(filename);
r11208r11209
477477   nc_state *state = machine.driver_data<nc_state>();
478478   char filename[MAX_DRIVER_NAME_CHARS + 5];
479479
480   sprintf(filename,"%s.nv", machine.system().name);
480   sprintf(filename,"%s.hack", machine.system().name);
481481   
482482   state->m_file = global_alloc(emu_file(machine.options().memcard_directory(), OPEN_FLAG_WRITE));
483483   state->m_file->open(filename);
r11208r11209
850850}
851851
852852
853static void nc100_tc8521_alarm_callback(device_t *device, int state)
853static WRITE_LINE_DEVICE_HANDLER(nc100_tc8521_alarm_callback)
854854{
855   nc_state *drvstate = device->machine().driver_data<nc_state>();
856   /* I'm assuming that the nmi is edge triggered */
857   /* a interrupt from the fdc will cause a change in line state, and
858    the nmi will be triggered, but when the state changes because the int
859    is cleared this will not cause another nmi */
860   /* I'll emulate it like this to be sure */
861
862   if (state != drvstate->m_previous_alarm_state)
863   {
864      if (state)
865      {
866         /* I'll pulse it because if I used hold-line I'm not sure
867            it would clear - to be checked */
868         cputag_set_input_line(device->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE);
869      }
870   }
871
872   drvstate->m_previous_alarm_state = state;
855   // TODO
873856}
874857
875858static WRITE_LINE_DEVICE_HANDLER( nc100_txrdy_callback )
r11208r11209
908891}
909892
910893
911static const tc8521_interface nc100_tc8521_interface =
894static RP5C01_INTERFACE( rtc_intf )
912895{
913   nc100_tc8521_alarm_callback,
896   DEVCB_LINE(nc100_tc8521_alarm_callback)
914897};
915898
916899static const msm8251_interface nc100_uart_interface =
r11208r11209
961944   nc_common_init_machine(machine);
962945
963946   nc_common_open_stream_for_reading(machine);
964
965   {
966      device_t *rtc = machine.device("rtc");
967      tc8521_load_stream(rtc, state->m_file);
968   }
969
970947   nc_common_restore_memory_from_stream(machine);
971
972948   nc_common_close_stream(machine);
973949
974950   /* serial */
r11208r11209
977953
978954static void nc100_machine_stop(running_machine &machine)
979955{
980   nc_state *state = machine.driver_data<nc_state>();
981956   nc_common_open_stream_for_writing(machine);
982   {
983      device_t *rtc = machine.device("rtc");
984      tc8521_save_stream(rtc, state->m_file);
985   }
986957   nc_common_store_memory_to_stream(machine);
987958   nc_common_close_stream(machine);
988959}
r11208r11209
10681039   AM_RANGE(0xb0, 0xb9) AM_READ(nc_key_data_in_r)
10691040   AM_RANGE(0xc0, 0xc0) AM_DEVREADWRITE("uart", msm8251_data_r, msm8251_data_w)
10701041   AM_RANGE(0xc1, 0xc1) AM_DEVREADWRITE("uart", msm8251_status_r, msm8251_control_w)
1071   AM_RANGE(0xd0, 0xdf) AM_DEVREADWRITE("rtc", tc8521_r, tc8521_w)
1042   AM_RANGE(0xd0, 0xdf) AM_DEVREADWRITE_MODERN("rtc", rp5c01_device, read, write)
10721043ADDRESS_MAP_END
10731044
10741045
r11208r11209
16411612   PORT_DIPSETTING(   0x02, DEF_STR( On) )
16421613INPUT_PORTS_END
16431614
1644
1645/* Serial */
1646static DEVICE_IMAGE_LOAD( nc_serial )
1647{
1648   device_t *uart = image.device().machine().device("uart");
1649
1650   /* filename specified */
1651   if (device_load_serial(image)==IMAGE_INIT_PASS)
1652   {
1653      /* setup transmit parameters */
1654      serial_device_setup(&image.device(), 9600, 8, 1, SERIAL_PARITY_NONE);
1655
1656      /* connect serial chip to serial device */
1657      msm8251_connect_to_serial_device(uart, &image.device());
1658
1659      /* and start transmit */
1660      serial_device_set_transmit_state(&image.device(),1);
1661
1662      return IMAGE_INIT_PASS;
1663   }
1664
1665   return IMAGE_INIT_FAIL;
1666
1667}
1668
1669DEVICE_GET_INFO( nc_serial )
1670{
1671   switch ( state )
1672   {
1673      case DEVINFO_FCT_IMAGE_LOAD:              info->f = (genf *) DEVICE_IMAGE_LOAD_NAME( nc_serial );    break;
1674      case DEVINFO_STR_NAME:                      strcpy(info->s, "NC serial port");                       break;
1675      case DEVINFO_STR_IMAGE_FILE_EXTENSIONS:       strcpy(info->s, "txt");                                         break;
1676      case DEVINFO_INT_IMAGE_READABLE:            info->i = 1;                                           break;
1677      case DEVINFO_INT_IMAGE_WRITEABLE:         info->i = 0;                                           break;
1678      case DEVINFO_INT_IMAGE_CREATABLE:          info->i = 0;                                           break;
1679      default:                           DEVICE_GET_INFO_CALL(serial);   break;
1680   }
1681}
1682
1683DECLARE_LEGACY_IMAGE_DEVICE(NC_SERIAL, nc_serial);
1684DEFINE_LEGACY_IMAGE_DEVICE(NC_SERIAL, nc_serial);
1685
1686#define MCFG_NC_SERIAL_ADD(_tag) \
1687   MCFG_DEVICE_ADD(_tag, NC_SERIAL, 0)
1688
16891615/**********************************************************************************************************/
16901616
16911617static MACHINE_CONFIG_START( nc100, nc_state )
r11208r11209
17031629   MCFG_SCREEN_REFRESH_RATE(50)
17041630   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
17051631   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1706   MCFG_SCREEN_SIZE(640 /*NC_SCREEN_WIDTH*/, 480 /*NC_SCREEN_HEIGHT*/)
1707   MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
1632   MCFG_SCREEN_SIZE(480, 64)
1633   MCFG_SCREEN_VISIBLE_AREA(0, 480-1, 0, 64-1)
17081634   MCFG_SCREEN_UPDATE( nc )
17091635
17101636   MCFG_PALETTE_LENGTH(NC_NUM_COLOURS)
r11208r11209
17271653   MCFG_MSM8251_ADD("uart", nc100_uart_interface)
17281654
17291655   /* rtc */
1730   MCFG_TC8521_ADD("rtc", nc100_tc8521_interface)
1656   MCFG_RP5C01_ADD("rtc", XTAL_32_768kHz, rtc_intf)
17311657
17321658   /* cartridge */
17331659   MCFG_CARTSLOT_ADD("cart")
r11208r11209
17411667   MCFG_RAM_ADD(RAM_TAG)
17421668   MCFG_RAM_DEFAULT_SIZE("64K")
17431669
1744   MCFG_NC_SERIAL_ADD("serial")
1745
17461670   /* dummy timer */
17471671   MCFG_TIMER_ADD_PERIODIC("dummy_timer", dummy_timer_callback, attotime::from_hz(50))
17481672MACHINE_CONFIG_END
r11208r11209
18261750/*    YEAR  NAME    PARENT  COMPAT  MACHINE INPUT   INIT    COMPANY         FULLNAME    FLAGS */
18271751COMP( 1992, nc100,  0,      0,      nc100,  nc100,  0,      "Amstrad plc",  "NC100",    0 )
18281752COMP( 1992, nc150,  nc100,  0,      nc100,  nc100,  0,      "Amstrad plc",  "NC150",    0 )
1829COMP( 1993, nc200,  0,      0,      nc200,  nc200,  0,      "Amstrad plc",  "NC200",    0 )
1830
1753COMP( 1993, nc200,  0,      0,      nc200,  nc200,  0,      "Amstrad plc",  "NC200",    GAME_NOT_WORKING ) // boot hangs while checking the MC146818 UIP (update in progress) bit
src/mess/drivers/msx.c
r11208r11209
279279#include "cpu/z80/z80.h"
280280#include "deprecat.h"
281281#include "machine/i8255a.h"
282#include "machine/tc8521.h"
282#include "machine/rp5c01.h"
283283#include "machine/wd17xx.h"
284284#include "video/tms9928a.h"
285285#include "video/v9938.h"
r11208r11209
11021102#define MSX2_VISIBLE_XBORDER_PIXELS   8 * 2
11031103#define MSX2_VISIBLE_YBORDER_PIXELS   14 * 2
11041104
1105static RP5C01_INTERFACE( rtc_intf )
1106{
1107   DEVCB_NULL
1108};
1109
11051110static MACHINE_CONFIG_START( msx2, msx_state )
11061111   /* basic machine hardware */
11071112   MCFG_CPU_ADD("maincpu", Z80, 3579545)        /* 3.579545 MHz */
r11208r11209
11441149   MCFG_SOUND_ADD("ym2413", YM2413, 3579545)
11451150   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
11461151
1147   MCFG_NVRAM_HANDLER( msx2 )
1148
11491152   /* printer */
11501153   MCFG_CENTRONICS_ADD("centronics", standard_centronics)
11511154
r11208r11209
11531156   MCFG_CASSETTE_ADD( "cassette", msx_cassette_config )
11541157
11551158   /* real time clock */
1156   MCFG_TC8521_ADD("rtc", default_tc8521_interface)
1159   MCFG_RP5C01_ADD("rtc", XTAL_32_768kHz, rtc_intf)
11571160
11581161   MCFG_WD179X_ADD("wd179x", msx_wd17xx_interface )
11591162
src/mess/drivers/pc4.c
r11208r11209
2626#include "emu.h"
2727#include "cpu/z80/z80.h"
2828#include "includes/pc4.h"
29#include "machine/tc8521.h"
29#include "machine/rp5c01.h"
3030#include "sound/beep.h"
3131#include "rendlay.h"
3232
r11208r11209
6262
6363static ADDRESS_MAP_START(pc4_io, AS_IO, 8, pc4_state)
6464   ADDRESS_MAP_UNMAP_HIGH
65   AM_RANGE(0x0000, 0x000f) AM_DEVREADWRITE_LEGACY("rtc", tc8521_r, tc8521_w)
65   AM_RANGE(0x0000, 0x000f) AM_DEVREADWRITE("rtc", rp5c01_device, read, write)
6666   AM_RANGE(0x1000, 0x1000) AM_WRITE(beep_w)
6767   AM_RANGE(0x1fff, 0x1fff) AM_WRITE(bank_w)
6868
r11208r11209
203203   m_blink = 0;
204204}
205205
206static const tc8521_interface pc4_tc8521_interface =
206static RP5C01_INTERFACE( rtc_intf )
207207{
208   NULL
208   DEVCB_NULL
209209};
210210
211211static MACHINE_CONFIG_START( pc4, pc4_state )
r11208r11209
230230   MCFG_SOUND_ADD( "beep", BEEP, 0 )
231231   MCFG_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 )
232232
233   MCFG_TC8521_ADD("rtc", pc4_tc8521_interface)
233   MCFG_RP5C01_ADD("rtc", XTAL_32_768kHz, rtc_intf)
234234MACHINE_CONFIG_END
235235
236236ROM_START( pc4 )
src/mess/drivers/avigo.c
r11208r11209
4141#include "emu.h"
4242#include "cpu/z80/z80.h"
4343#include "includes/avigo.h"
44#include "machine/tc8521.h"
44#include "machine/rp5c01.h"
4545#include "machine/ins8250.h"
4646#include "sound/speaker.h"
4747#include "machine/ram.h"
r11208r11209
260260}
261261
262262/* does not do anything yet */
263static void avigo_tc8521_alarm_int(device_t *device, int state)
263WRITE_LINE_DEVICE_HANDLER( avigo_tc8521_alarm_int )
264264{
265265   avigo_state *drvstate = device->machine().driver_data<avigo_state>();
266266//#if 0
r11208r11209
276276}
277277
278278
279static const tc8521_interface avigo_tc8521_interface =
279static RP5C01_INTERFACE( rtc_intf )
280280{
281   avigo_tc8521_alarm_int
281   DEVCB_LINE(avigo_tc8521_alarm_int)
282282};
283283
284284static void avigo_refresh_memory(running_machine &machine)
r11208r11209
807807   AM_RANGE(0x008, 0x008) AM_READWRITE( avigo_ram_bank_h_r, avigo_ram_bank_h_w )
808808   AM_RANGE(0x009, 0x009) AM_READWRITE( avigo_ad_control_status_r, avigo_ad_control_status_w )
809809   AM_RANGE(0x00a, 0x00f) AM_READ( avigo_unmapped_r)
810   AM_RANGE(0x010, 0x01f) AM_DEVREADWRITE("rtc", tc8521_r, tc8521_w )
810   AM_RANGE(0x010, 0x01f) AM_DEVREADWRITE_MODERN("rtc", rp5c01_device, read, write)
811811   AM_RANGE(0x020, 0x02c) AM_READ( avigo_unmapped_r)
812812   AM_RANGE(0x028, 0x028) AM_WRITE( avigo_speaker_w)
813813   AM_RANGE(0x02d, 0x02d) AM_READ( avigo_ad_data_r)
r11208r11209
972972   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
973973
974974   /* real time clock */
975   MCFG_TC8521_ADD("rtc", avigo_tc8521_interface)
975   MCFG_RP5C01_ADD("rtc", XTAL_32_768kHz, rtc_intf)
976976
977977   /* flash ROMs */
978978   MCFG_INTEL_E28F008SA_ADD("flash0")

Previous 15994 Revisions Next


© 1998-2018 The MESS Team