Previous 15994 Revisions Next

r13737 Tuesday 27th December, 2011 at 11:29:58 UTC by Olivier Galibert
8530scc: Modernize. Hopefully nothing broke [O. Galibert]
[src/mess/drivers]abc1600.c apple2gs.c atarist.c ip20.c mac.c x68k.c
[src/mess/includes]abc1600.h mac.h
[src/mess/machine]8530scc.c 8530scc.h apple2gs.c mac.c

src/mess/machine/8530scc.c
r13736r13737
1010#include "emu.h"
1111#include "8530scc.h"
1212
13const device_type SCC8530 = &device_creator<scc8530_t>;
1314
15
1416/***************************************************************************
1517    PARAMETERS
1618***************************************************************************/
1719
18#define LOG_SCC   (0)
20#define LOG_SCC   (1)
1921
20
21
2222/***************************************************************************
23    TYPE DEFINITIONS
23    IMPLEMENTATION
2424***************************************************************************/
2525
26typedef enum
26scc8530_t::scc8530_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, SCC8530, "Zilog 8530 SCC", tag, owner, clock)
2727{
28   IRQ_NONE,
29   IRQ_A_RX,
30   IRQ_A_RX_SPECIAL,
31   IRQ_B_RX,
32   IRQ_B_RX_SPECIAL,
33   IRQ_A_TX,
34   IRQ_B_TX,
35   IRQ_A_EXT,
36   IRQ_B_EXT
37} SCCIRQType;
38
39typedef struct
40{
41   int txIRQEnable;
42   int rxIRQEnable;
43   int extIRQEnable;
44   int baudIRQEnable;
45   int txIRQPending;
46   int rxIRQPending;
47   int extIRQPending;
48   int baudIRQPending;
49   int txEnable;
50   int rxEnable;
51   int txUnderrun;
52   int txUnderrunEnable;
53   int syncHunt;
54   int DCDEnable;
55   int CTSEnable;
56   int rxData;
57   int txData;
58
59   emu_timer *baudtimer;
60
61   UINT8 reg_val[16];
62} sccChan;
63
64typedef struct _scc8530_t scc8530_t;
65struct _scc8530_t
66{
67   int mode;
68   int reg;
69   int status;
70   int IRQV;
71   int MasterIRQEnable;
72   int lastIRQStat;
73   int clock;
74   SCCIRQType IRQType;
75
76   sccChan channel[2];
77};
78
79
80
81/***************************************************************************
82    INLINE FUNCTIONS
83***************************************************************************/
84
85INLINE scc8530_t *get_token(device_t *device)
86{
87   assert(device != NULL);
88   assert(device->type() == SCC8530);
89
90   return (scc8530_t *) downcast<legacy_device_base *>(device)->token();
9128}
9229
93
94INLINE const scc8530_interface *get_interface(device_t *device)
30void scc8530_t::set_intrq_cb(intrq_cb_t cb)
9531{
96   assert(device != NULL);
97   assert(device->type() == SCC8530);
98
99   return (const scc8530_interface *) downcast<const legacy_device_base *>(device)->inline_config();
32   intrq_cb = cb;
10033}
10134
102
103/***************************************************************************
104    IMPLEMENTATION
105***************************************************************************/
106
10735/*-------------------------------------------------
10836    scc_updateirqs
10937-------------------------------------------------*/
11038
111static void scc_updateirqs(device_t *device)
39void scc8530_t::updateirqs()
11240{
113   scc8530_t *scc = get_token(device);
11441   int irqstat;
11542
11643   irqstat = 0;
117   if (scc->MasterIRQEnable)
44   if (MasterIRQEnable)
11845   {
119      if ((scc->channel[0].txIRQEnable) && (scc->channel[0].txIRQPending))
46      if ((channel[0].txIRQEnable) && (channel[0].txIRQPending))
12047      {
121         scc->IRQType = IRQ_B_TX;
48         IRQType = IRQ_B_TX;
12249         irqstat = 1;
12350      }
124      else if ((scc->channel[1].txIRQEnable) && (scc->channel[1].txIRQPending))
51      else if ((channel[1].txIRQEnable) && (channel[1].txIRQPending))
12552      {
126         scc->IRQType = IRQ_A_TX;
53         IRQType = IRQ_A_TX;
12754         irqstat = 1;
12855      }
129      else if ((scc->channel[0].extIRQEnable) && (scc->channel[0].extIRQPending))
56      else if ((channel[0].extIRQEnable) && (channel[0].extIRQPending))
13057      {
131         scc->IRQType = IRQ_B_EXT;
58         IRQType = IRQ_B_EXT;
13259         irqstat = 1;
13360      }
134      else if ((scc->channel[1].extIRQEnable) && (scc->channel[1].extIRQPending))
61      else if ((channel[1].extIRQEnable) && (channel[1].extIRQPending))
13562      {
136         scc->IRQType = IRQ_A_EXT;
63         IRQType = IRQ_A_EXT;
13764         irqstat = 1;
13865      }
13966   }
14067   else
14168   {
142      scc->IRQType = IRQ_NONE;
69      IRQType = IRQ_NONE;
14370   }
14471
145//  printf("SCC: irqstat %d, last %d\n", irqstat, scc->lastIRQStat);
146//  printf("ch0: en %d pd %d  ch1: en %d pd %d\n", scc->channel[0].txIRQEnable, scc->channel[0].txIRQPending, scc->channel[1].txIRQEnable, scc->channel[1].txIRQPending);
72//  printf("SCC: irqstat %d, last %d\n", irqstat, lastIRQStat);
73//  printf("ch0: en %d pd %d  ch1: en %d pd %d\n", channel[0].txIRQEnable, channel[0].txIRQPending, channel[1].txIRQEnable, channel[1].txIRQPending);
14774
14875   // don't spam the driver with unnecessary transitions
149   if (irqstat != scc->lastIRQStat)
76   if (irqstat != lastIRQStat)
15077   {
151      const scc8530_interface *intf = get_interface(device);
78      lastIRQStat = irqstat;
15279
153      scc->lastIRQStat = irqstat;
154
15580      // tell the driver the new IRQ line status if possible
156      if ((intf != NULL) && (intf->irq != NULL))
157      {
158         #if LOG_SCC
159         printf("SCC8530 IRQ status => %d\n", irqstat);
160         #endif
161         (*intf->irq)(device, irqstat);
162      }
81#if LOG_SCC
82      printf("SCC8530 IRQ status => %d\n", irqstat);
83#endif
84      if(!intrq_cb.isnull())
85         intrq_cb(irqstat);
16386   }
16487}
16588
16689/*-------------------------------------------------
16790    scc_initchannel
16891-------------------------------------------------*/
169static void scc8530_initchannel(scc8530_t *scc, int ch)
92void scc8530_t::initchannel(int ch)
17093{
171   scc->channel[ch].syncHunt = 1;
94   channel[ch].syncHunt = 1;
17295}
17396
17497/*-------------------------------------------------
17598    scc_resetchannel
17699-------------------------------------------------*/
177static void scc8530_resetchannel(scc8530_t *scc, int ch)
100void scc8530_t::resetchannel(int ch)
178101{
179   emu_timer *timersave = scc->channel[ch].baudtimer;
102   emu_timer *timersave = channel[ch].baudtimer;
180103
181   memset(&scc->channel[ch], 0, sizeof(sccChan));
104   memset(&channel[ch], 0, sizeof(Chan));
182105
183   scc->channel[ch].txUnderrun = 1;
184   scc->channel[ch].baudtimer = timersave;
106   channel[ch].txUnderrun = 1;
107   channel[ch].baudtimer = timersave;
185108
186   scc->channel[ch].baudtimer->adjust(attotime::never, ch);
109   channel[ch].baudtimer->adjust(attotime::never, ch);
187110}
188111
189112/*-------------------------------------------------
190113    scc8530_baud_expire - baud rate timer expiry
191114-------------------------------------------------*/
192115
193static TIMER_CALLBACK( scc8530_baud_expire )
116void scc8530_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
194117{
195   device_t *device = (device_t *)ptr;
196   scc8530_t *scc = get_token(device);
197   sccChan *pChan = &scc->channel[param];
118   Chan *pChan = &channel[id];
198119   int brconst = pChan->reg_val[13]<<8 | pChan->reg_val[14];
199120   int rate;
200121
201122   if (brconst)
202123   {
203      rate = scc->clock / brconst;
124      rate = clock() / brconst;
204125   }
205126   else
206127   {
r13736r13737
216137      {
217138         pChan->extIRQPending = 1;
218139         pChan->baudIRQPending = 0;
219         scc_updateirqs(device);
140         updateirqs();
220141      }
221142   }
222143
223144   // reset timer according to current register values
224145   if (rate)
225146   {
226      pChan->baudtimer->adjust(attotime::from_hz(rate), param, attotime::from_hz(rate));
147      timer.adjust(attotime::from_hz(rate), 0, attotime::from_hz(rate));
227148   }
228149   else
229150   {
230      pChan->baudtimer->adjust(attotime::never, param, attotime::never);
151      timer.adjust(attotime::never, 0, attotime::never);
231152   }
232153}
233154
r13736r13737
235156    DEVICE_START( scc8530 )
236157-------------------------------------------------*/
237158
238static DEVICE_START( scc8530 )
159void scc8530_t::device_start()
239160{
240   scc8530_t *scc = get_token(device);
241   memset(scc, 0, sizeof(*scc));
242   scc->clock = device->clock();
161   memset(channel, 0, sizeof(channel));
243162
244   scc->channel[0].baudtimer = device->machine().scheduler().timer_alloc(FUNC(scc8530_baud_expire), (void *)device);
245   scc->channel[1].baudtimer = device->machine().scheduler().timer_alloc(FUNC(scc8530_baud_expire), (void *)device);
163   mode = 0;
164   reg = 0;
165   status = 0;
166   IRQV = 0;
167   MasterIRQEnable = 0;
168   lastIRQStat = 0;
169   IRQType = IRQ_NONE;
170
171   channel[0].baudtimer = timer_alloc(0);
172   channel[1].baudtimer = timer_alloc(1);
246173}
247174
248175
249176/*-------------------------------------------------
250177    DEVICE_RESET( scc8530 )
251178-------------------------------------------------*/
252static DEVICE_RESET( scc8530 )
179void scc8530_t::device_reset()
253180{
254   scc8530_t *scc = get_token(device);
181   IRQType = IRQ_NONE;
182   MasterIRQEnable = 0;
183   IRQV = 0;
255184
256   scc->IRQType = IRQ_NONE;
257   scc->MasterIRQEnable = 0;
258   scc->IRQV = 0;
259
260   scc8530_initchannel(scc, 0);
261   scc8530_initchannel(scc, 1);
262   scc8530_resetchannel(scc, 0);
263   scc8530_resetchannel(scc, 1);
185   initchannel(0);
186   initchannel(1);
187   resetchannel(0);
188   resetchannel(1);
264189}
265190
266191/*-------------------------------------------------
267192    scc_set_status
268193-------------------------------------------------*/
269194
270void scc8530_set_status(device_t *device, int status)
195void scc8530_t::set_status(int _status)
271196{
272   scc8530_t *scc = get_token(device);
273   scc->status = status;
197   status = _status;
274198}
275199
276200/*-------------------------------------------------
277201    scc_acknowledge
278202-------------------------------------------------*/
279203
280static void scc_acknowledge(device_t *device)
204void scc8530_t::acknowledge()
281205{
282   const scc8530_interface *intf = get_interface(device);
283   if ((intf != NULL) && (intf->irq != NULL))
284      (*intf->irq)(device, 0);
206   if(!intrq_cb.isnull())
207      intrq_cb(0);
285208}
286209
287210/*-------------------------------------------------
288211    scc_getareg
289212-------------------------------------------------*/
290213
291static int scc_getareg(device_t *device)
214UINT8 scc8530_t::getareg()
292215{
293   scc8530_t *scc = get_token(device);
294
295216   /* Not yet implemented */
296217   #if LOG_SCC
297   printf("SCC: port A reg %d read 0x%02x\n", scc->reg, scc->channel[0].reg_val[scc->reg]);
218   printf("SCC: port A reg %d read 0x%02x\n", reg, channel[0].reg_val[reg]);
298219   #endif
299220
300   if (scc->reg == 0)
221   if (reg == 0)
301222   {
302      UINT8 rv = 0;
223      UINT8 rv = 5; // TX buffer empty, RX available
303224
304      sccChan *ourCh = &scc->channel[0];
225      Chan *ourCh = &channel[0];
305226
306227      rv |= (ourCh->txUnderrun) ? 0x40 : 0;
307228      rv |= (ourCh->syncHunt) ? 0x10 : 0;
308229
309230      return rv;
310231   }
311   else if (scc->reg == 10)
232   else if (reg == 10)
312233   {
313234      return 0;
314235   }
315   return scc->channel[0].reg_val[scc->reg];
236   return channel[0].reg_val[reg];
316237}
317238
318239
r13736r13737
321242    scc_getareg
322243-------------------------------------------------*/
323244
324static int scc_getbreg(device_t *device)
245UINT8 scc8530_t::getbreg()
325246{
326   scc8530_t *scc = get_token(device);
327
328247   #if LOG_SCC
329   printf("SCC: port B reg %i read 0x%02x\n", scc->reg, scc->channel[1].reg_val[scc->reg]);
248   printf("SCC: port B reg %i read 0x%02x\n", reg, channel[1].reg_val[reg]);
330249   #endif
331250
332   if (scc->reg == 0)
251   if (reg == 0)
333252   {
334      UINT8 rv = 0;
253      UINT8 rv = 5; // TX buffer empty, RX available
335254
336      sccChan *ourCh = &scc->channel[1];
255      Chan *ourCh = &channel[1];
337256
338257      rv |= (ourCh->txUnderrun) ? 0x40 : 0;
339258      rv |= (ourCh->syncHunt) ? 0x10 : 0;
r13736r13737
341260
342261      return rv;
343262   }
344   else if (scc->reg == 2)
263   else if (reg == 2)
345264   {
346265      /* HACK! but lets the Mac Plus mouse move again.  Needs further investigation. */
347      scc_acknowledge(device);
266      acknowledge();
348267
349      return scc->status;
268      return status;
350269   }
351   else if (scc->reg == 10)
270   else if (reg == 10)
352271   {
353272      return 0;
354273   }
355274
356   return scc->channel[1].reg_val[scc->reg];
275   return channel[1].reg_val[reg];
357276}
358277
359278
r13736r13737
362281    scc_putreg
363282-------------------------------------------------*/
364283
365static void scc_putreg(device_t *device, int ch, int data)
284void scc8530_t::putreg(int ch, UINT8 data)
366285{
367   scc8530_t *scc = get_token(device);
368   sccChan *pChan = &scc->channel[ch];
286   Chan *pChan = &channel[ch];
369287
370   scc->channel[ch].reg_val[scc->reg] = data;
288   channel[ch].reg_val[reg] = data;
371289   #if LOG_SCC
372   printf("SCC: port %c reg %d write 0x%02x\n", 'A'+ch, scc->reg, data);
290   printf("SCC: port %c reg %d write 0x%02x\n", 'A'+ch, reg, data);
373291   #endif
374292
375   switch (scc->reg)
293   switch (reg)
376294   {
377295      case 0:   // command register
378296         switch ((data >> 3) & 7)
r13736r13737
386304
387305            case 5: // ack Tx IRQ
388306               pChan->txIRQPending = 0;
389               scc_updateirqs(device);
307               updateirqs();
390308               break;
391309
392310            case 0:   // nothing
r13736r13737
404322         pChan->extIRQEnable = (data & 1);
405323         pChan->txIRQEnable = (data & 2) ? 1 : 0;
406324         pChan->rxIRQEnable = (data >> 3) & 3;
407         scc_updateirqs(device);
325         updateirqs();
408326         break;
409327
410328      case 2: // IRQ vector
411         scc->IRQV = data;
329         IRQV = data;
412330         break;
413331
414332      case 3: // Rx parameters and controls
r13736r13737
432350         break;
433351
434352      case 9: // master IRQ control
435         scc->MasterIRQEnable = (data & 8) ? 1 : 0;
436         scc_updateirqs(device);
353         MasterIRQEnable = (data & 8) ? 1 : 0;
354         updateirqs();
437355
438356         // channel reset command
439357         switch ((data>>6) & 3)
r13736r13737
442360               break;
443361
444362            case 1:   // reset channel B
445               scc8530_resetchannel(scc, 0);
363               resetchannel(0);
446364               break;
447365
448366            case 2: // reset channel A
449               scc8530_resetchannel(scc, 1);
367               resetchannel(1);
450368               break;
451369
452370            case 3: // force h/w reset (entire chip)
453               scc->IRQType = IRQ_NONE;
454               scc->MasterIRQEnable = 0;
455               scc->IRQV = 0;
371               IRQType = IRQ_NONE;
372               MasterIRQEnable = 0;
373               IRQV = 0;
456374
457               scc8530_initchannel(scc, 0);
458               scc8530_initchannel(scc, 1);
459               scc8530_resetchannel(scc, 0);
460               scc8530_resetchannel(scc, 1);
375               initchannel(0);
376               initchannel(1);
377               resetchannel(0);
378               resetchannel(1);
461379
462380               // make sure we stop yanking the IRQ line if we were
463               scc_updateirqs(device);
381               updateirqs();
464382               break;
465383
466384         }
r13736r13737
476394         if (data & 0x01)   // baud rate generator enable?
477395         {
478396            int brconst = pChan->reg_val[13]<<8 | pChan->reg_val[14];
479            int rate = scc->clock / brconst;
397            int rate = clock() / brconst;
480398
481            pChan->baudtimer->adjust(attotime::from_hz(rate), ch, attotime::from_hz(rate));
399            pChan->baudtimer->adjust(attotime::from_hz(rate), 0, attotime::from_hz(rate));
482400         }
483401         break;
484402
r13736r13737
495413    scc8530_get_reg_a
496414-------------------------------------------------*/
497415
498UINT8 scc8530_get_reg_a(device_t *device, int reg)
416UINT8 scc8530_t::get_reg_a(int reg)
499417{
500   scc8530_t *scc = get_token(device);
501   return scc->channel[0].reg_val[reg];
418   return channel[0].reg_val[reg];
502419}
503420
504421
r13736r13737
507424    scc8530_get_reg_b
508425-------------------------------------------------*/
509426
510UINT8 scc8530_get_reg_b(device_t *device, int reg)
427UINT8 scc8530_t::get_reg_b(int reg)
511428{
512   scc8530_t *scc = get_token(device);
513   return scc->channel[1].reg_val[reg];
429   return channel[1].reg_val[reg];
514430}
515431
516432
r13736r13737
519435    scc8530_set_reg_a
520436-------------------------------------------------*/
521437
522void scc8530_set_reg_a(device_t *device, int reg, UINT8 data)
438void scc8530_t::set_reg_a(int reg, UINT8 data)
523439{
524   scc8530_t *scc = get_token(device);
525   scc->channel[0].reg_val[reg] = data;
440   channel[0].reg_val[reg] = data;
526441}
527442
528443
r13736r13737
531446    scc8530_set_reg_a
532447-------------------------------------------------*/
533448
534void scc8530_set_reg_b(device_t *device, int reg, UINT8 data)
449void scc8530_t::set_reg_b(int reg, UINT8 data)
535450{
536   scc8530_t *scc = get_token(device);
537   scc->channel[1].reg_val[reg] = data;
451   channel[1].reg_val[reg] = data;
538452}
539453
540454
r13736r13737
543457    scc8530_r
544458-------------------------------------------------*/
545459
546READ8_DEVICE_HANDLER(scc8530_r)
460READ8_MEMBER( scc8530_t::reg_r)
547461{
548   scc8530_t *scc = get_token(device);
549462   UINT8 result = 0;
550463
551464   offset %= 4;
r13736r13737
554467   {
555468      case 0:
556469         /* Channel B (Printer Port) Control */
557         if (scc->mode == 1)
558            scc->mode = 0;
470         if (mode == 1)
471            mode = 0;
559472         else
560            scc->reg = 0;
473            reg = 0;
561474
562         result = scc_getbreg(device);
475         result = getbreg();
563476         break;
564477
565478      case 1:
566479         /* Channel A (Modem Port) Control */
567         if (scc->mode == 1)
568            scc->mode = 0;
480         if (mode == 1)
481            mode = 0;
569482         else
570            scc->reg = 0;
483            reg = 0;
571484
572         result = scc_getareg(device);
485         result = getareg();
573486         break;
574487
575488      case 2:
576489         /* Channel B (Printer Port) Data */
577         return scc->channel[1].rxData;
490         return channel[1].rxData;
578491         break;
579492
580493      case 3:
581494         /* Channel A (Modem Port) Data */
582         return scc->channel[0].rxData;
495         return channel[0].rxData;
583496         break;
584497   }
585498   return result;
r13736r13737
591504    scc8530_w
592505-------------------------------------------------*/
593506
594WRITE8_DEVICE_HANDLER(scc8530_w)
507WRITE8_MEMBER( scc8530_t::reg_w )
595508{
596   scc8530_t *scc = get_token(device);
597   sccChan *pChan;
509   Chan *pChan;
598510
599511   offset &= 3;
600512
601//  printf(" mode %d data %x offset %d  \n", scc->mode, data, offset);
513//  printf(" mode %d data %x offset %d  \n", mode, data, offset);
602514
603515   switch(offset)
604516   {
605517      case 0:
606518         /* Channel B (Printer Port) Control */
607         if (scc->mode == 0)
519         if (mode == 0)
608520         {
609521            if((data & 0xf0) == 0)  // not a reset command
610522            {
611               scc->mode = 1;
612               scc->reg = data & 0x0f;
613//                  scc_putbreg(device, data & 0xf0);
523               mode = 1;
524               reg = data & 0x0f;
525//                  putbreg(data & 0xf0);
614526            }
615527            else if (data == 0x10)
616528            {
617               pChan = &scc->channel[1];
529               pChan = &channel[1];
618530               // clear ext. interrupts
619531               pChan->extIRQPending = 0;
620532               pChan->baudIRQPending = 0;
621               scc_updateirqs(device);
533               updateirqs();
622534            }
623535         }
624536         else
625537         {
626            scc->mode = 0;
627            scc_putreg(device, 1, data);
538            mode = 0;
539            putreg(1, data);
628540         }
629541         break;
630542
631543      case 1:
632544         /* Channel A (Modem Port) Control */
633         if (scc->mode == 0)
545         if (mode == 0)
634546         {
635547            if((data & 0xf0) == 0)  // not a reset command
636548            {
637               scc->mode = 1;
638               scc->reg = data & 0x0f;
639//                  scc_putareg(device, data & 0xf0);
549               mode = 1;
550               reg = data & 0x0f;
551//                  putareg(data & 0xf0);
640552            }
641553            else if (data == 0x10)
642554            {
643               pChan = &scc->channel[0];
555               pChan = &channel[0];
644556               // clear ext. interrupts
645557               pChan->extIRQPending = 0;
646558               pChan->baudIRQPending = 0;
647               scc_updateirqs(device);
559               updateirqs();
648560            }
649561         }
650562         else
651563         {
652            scc->mode = 0;
653            scc_putreg(device, 0, data);
564            mode = 0;
565            putreg(0, data);
654566         }
655567         break;
656568
657569      case 2:
658570         /* Channel B (Printer Port) Data */
659         pChan = &scc->channel[1];
571         pChan = &channel[1];
660572
661573         if (pChan->txEnable)
662574         {
r13736r13737
671583            pChan->reg_val[0] |= 0x04;   // Tx empty
672584            pChan->txUnderrun = 1;
673585            pChan->txIRQPending = 1;
674            scc_updateirqs(device);
586            updateirqs();
675587         }
676588         break;
677589
678590      case 3:
679591         /* Channel A (Modem Port) Data */
680         pChan = &scc->channel[0];
592         pChan = &channel[0];
681593
682594         if (pChan->txEnable)
683595         {
r13736r13737
692604            pChan->reg_val[0] |= 0x04;   // Tx empty
693605            pChan->txUnderrun = 1;
694606            pChan->txIRQPending = 1;
695            scc_updateirqs(device);
607            updateirqs();
696608         }
697609         break;
698610   }
699611}
700612
701
702
703/*-------------------------------------------------
704    DEVICE_GET_INFO( scc8530 )
705-------------------------------------------------*/
706
707DEVICE_GET_INFO( scc8530 )
708{
709   switch (state)
710   {
711      /* --- the following bits of info are returned as 64-bit signed integers --- */
712      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(scc8530_t);            break;
713      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = sizeof(scc8530_interface);      break;
714
715      /* --- the following bits of info are returned as pointers to functions --- */
716      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(scc8530);   break;
717      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
718      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(scc8530);   break;
719
720      /* --- the following bits of info are returned as NULL-terminated strings --- */
721      case DEVINFO_STR_NAME:                     strcpy(info->s, "Zilog 8530 SCC");         break;
722      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Zilog 8530 SCC");         break;
723      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.5");                  break;
724      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
725      case DEVINFO_STR_CREDITS:                  /* Nothing */                        break;
726   }
727}
728
729DEFINE_LEGACY_DEVICE(SCC8530, scc8530);
730
731613/*
732614
733615AppleTalk check:
src/mess/machine/8530scc.h
r13736r13737
99#ifndef __8530SCC_H__
1010#define __8530SCC_H__
1111
12#define MCFG_SCC8530_ADD(_tag, _clock, _intrq_cb)   \
13   MCFG_DEVICE_ADD(_tag, SCC8530, _clock)   \
14   downcast<scc8530_t *>(device)->set_intrq_cb(_intrq_cb);
1215
13/***************************************************************************
14    MACROS
15***************************************************************************/
16class scc8530_t : public device_t
17{
18public:
19   enum IRQType_t {
20      IRQ_NONE,
21      IRQ_A_RX,
22      IRQ_A_RX_SPECIAL,
23      IRQ_B_RX,
24      IRQ_B_RX_SPECIAL,
25      IRQ_A_TX,
26      IRQ_B_TX,
27      IRQ_A_EXT,
28      IRQ_B_EXT,
29   };
1630
17DECLARE_LEGACY_DEVICE(SCC8530, scc8530);
31   typedef delegate<void (int state)> intrq_cb_t;
1832
19/***************************************************************************
20    TYPE DEFINITIONS
21***************************************************************************/
33   scc8530_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
34   void set_intrq_cb(intrq_cb_t cb);
2235
23typedef struct _scc8530_interface scc8530_interface;
24struct _scc8530_interface
25{
26   void (*irq)(device_t *device, int state);
27};
36   UINT8 get_reg_a(int reg);
37   UINT8 get_reg_b(int reg);
38   void set_reg_a(int reg, UINT8 data);
39   void set_reg_b(int reg, UINT8 data);
2840
41   void set_status(int status);
2942
43   DECLARE_READ8_MEMBER(reg_r);
44   DECLARE_WRITE8_MEMBER(reg_w);
3045
31/***************************************************************************
32    DEVICE CONFIGURATION MACROS
33***************************************************************************/
46protected:
47   virtual void device_start();
48   virtual void device_reset();
49   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
3450
35#define MCFG_SCC8530_ADD(_tag, _clock) \
36   MCFG_DEVICE_ADD(_tag, SCC8530, _clock)
51private:
52   struct Chan {
53      bool txIRQEnable;
54      bool rxIRQEnable;
55      bool extIRQEnable;
56      bool baudIRQEnable;
57      bool txIRQPending;
58      bool rxIRQPending;
59      bool extIRQPending;
60      bool baudIRQPending;
61      bool txEnable;
62      bool rxEnable;
63      bool txUnderrun;
64      bool txUnderrunEnable;
65      bool syncHunt;
66      bool DCDEnable;
67      bool CTSEnable;
68      UINT8 rxData;
69      UINT8 txData;
3770
38#define MCFG_SCC8530_IRQ(_irq) \
39   MCFG_DEVICE_CONFIG_DATAPTR(scc8530_interface, irq, _irq)
71      emu_timer *baudtimer;
4072
73      UINT8 reg_val[16];
74   };
4175
76   int mode;
77   int reg;
78   int status;
79   int IRQV;
80   int MasterIRQEnable;
81   int lastIRQStat;
82   IRQType_t IRQType;
83
84   Chan channel[2];
85
86   intrq_cb_t intrq_cb;
87
88   void updateirqs();
89   void initchannel(int ch);
90   void resetchannel(int ch);
91   void acknowledge();
92   UINT8 getareg();
93   UINT8 getbreg();
94   void putreg(int ch, UINT8 data);
95};
96
4297/***************************************************************************
43    FUNCTION PROTOTYPES
98    MACROS
4499***************************************************************************/
45100
46void scc8530_set_status(device_t *device, int status);
101extern const device_type SCC8530;
47102
48UINT8 scc8530_get_reg_a(device_t *device, int reg);
49UINT8 scc8530_get_reg_b(device_t *device, int reg);
50void scc8530_set_reg_a(device_t *device, int reg, UINT8 data);
51void scc8530_set_reg_b(device_t *device, int reg, UINT8 data);
52
53READ8_DEVICE_HANDLER(scc8530_r);
54WRITE8_DEVICE_HANDLER(scc8530_w);
55
56103#endif /* __8530SCC_H__ */
src/mess/machine/apple2gs.c
r13736r13737
942942{
943943   apple2gs_state *state = space->machine().driver_data<apple2gs_state>();
944944   UINT8 result;
945   device_t *scc;
945   scc8530_t *scc;
946946
947947   offset &= 0xFF;
948948
r13736r13737
10291029      case 0x39:   /* C039 - SCCAREG */
10301030      case 0x3A:   /* C03A - SCCBDATA */
10311031      case 0x3B:   /* C03B - SCCADATA */
1032         scc = space->machine().device("scc");
1033         result = scc8530_r(scc, offset & 0x03);
1032         scc = space->machine().device<scc8530_t>("scc");
1033         result = scc->reg_r(*space, offset & 0x03);
10341034         break;
10351035
10361036      case 0x3C:   /* C03C - SOUNDCTL */
r13736r13737
10851085static WRITE8_HANDLER( apple2gs_c0xx_w )
10861086{
10871087   apple2gs_state *state = space->machine().driver_data<apple2gs_state>();
1088   device_t *scc;
1088   scc8530_t *scc;
10891089
10901090   offset &= 0xFF;
10911091
r13736r13737
11701170      case 0x39:   /* C039 - SCCAREG */
11711171      case 0x3A:   /* C03A - SCCBDATA */
11721172      case 0x3B:   /* C03B - SCCADATA */
1173         scc = space->machine().device("scc");
1174         scc8530_w(scc, offset & 0x03, data);
1173         scc = space->machine().device<scc8530_t>("scc");
1174         scc->reg_w(*space, offset & 0x03, data);
11751175         break;
11761176
11771177      case 0x3C:   /* C03C - SOUNDCTL */
src/mess/machine/mac.c
r13736r13737
11011101 * Serial Communications Controller
11021102 * *************************************************************************/
11031103
1104void mac_scc_irq(device_t *device, int status)
1105{
1106   mac_state *mac = device->machine().driver_data<mac_state>();
1107
1108   mac->set_scc_interrupt(status);
1109}
1110
1111
1112
11131104void mac_state::scc_mouse_irq(int x, int y)
11141105{
1115   device_t *scc = machine().device("scc");
1106   scc8530_t *scc = machine().device<scc8530_t>("scc");
11161107   if (x && y)
11171108   {
11181109      if (m_last_was_x)
1119         scc8530_set_status(scc, 0x0a);
1110         scc->set_status(0x0a);
11201111      else
1121         scc8530_set_status(scc, 0x02);
1112         scc->set_status(0x02);
11221113
11231114      m_last_was_x ^= 1;
11241115   }
11251116   else
11261117   {
11271118      if (x)
1128         scc8530_set_status(scc, 0x0a);
1119         scc->set_status(0x0a);
11291120      else
1130         scc8530_set_status(scc, 0x02);
1121         scc->set_status(0x02);
11311122   }
11321123
11331124   this->set_scc_interrupt(1);
r13736r13737
11371128
11381129READ16_MEMBER ( mac_state::mac_scc_r )
11391130{
1140   device_t *scc = space.machine().device("scc");
1131   scc8530_t *scc = space.machine().device<scc8530_t>("scc");
11411132   UINT16 result;
11421133
1143   result = scc8530_r(scc, offset);
1134   result = scc->reg_r(space, offset);
11441135   return (result << 8) | result;
11451136}
11461137
r13736r13737
11481139
11491140WRITE16_MEMBER ( mac_state::mac_scc_w )
11501141{
1151   device_t *scc = space.machine().device("scc");
1152   scc8530_w(scc, offset, (UINT8) data);
1142   scc8530_t *scc = space.machine().device<scc8530_t>("scc");
1143   scc->reg_w(space, offset, data);
11531144}
11541145
11551146WRITE16_MEMBER ( mac_state::mac_scc_2_w )
11561147{
1157   device_t *scc = space.machine().device("scc");
1158   UINT8 wdata = data>>8;
1159   scc8530_w(scc, offset, wdata);
1148   scc8530_t *scc = space.machine().device<scc8530_t>("scc");
1149   scc->reg_w(space, offset, data >> 8);
11601150}
11611151
11621152/* ********************************** *
src/mess/includes/mac.h
r13736r13737
130130extern const via6522_interface mac_via6522_2_intf;
131131extern const via6522_interface mac_via6522_adb_intf;
132132
133void mac_scc_irq(device_t *device, int status);
134133void mac_scsi_irq(running_machine &machine, int state);
135134void mac_asc_irq(device_t *device, int state);
136135void mac_fdc_set_enable_lines(device_t *device, int enable_mask);
src/mess/includes/abc1600.h
r13736r13737
8484   required_device<z80dma_device> m_dma1;
8585   required_device<z80dma_device> m_dma2;
8686   required_device<z80dart_device> m_dart;
87   required_device<device_t> m_scc;
87   required_device<scc8530_t> m_scc;
8888   required_device<z8536_device> m_cio;
8989   required_device<device_t> m_fdc;
9090   required_device<e0516_device> m_rtc;
r13736r13737
194194   inline UINT16 get_crtca(UINT16 ma, UINT8 ra, UINT8 column);
195195   void crtc_update_row(device_t *device, bitmap_t *bitmap, const rectangle *cliprect, UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, INT8 cursor_x, void *param);
196196
197   void scc_irq(int status);
198
197199   // memory access controller
198200   int m_ifc2;
199201   UINT8 m_task;
src/mess/drivers/atarist.c
r13736r13737
13591359    AM_RANGE(0xff8e00, 0xff8e0f) AM_READWRITE(vme_r, vme_w)
13601360    AM_RANGE(0xff8e20, 0xff8e21) AM_READWRITE(cache_r, cache_w)
13611361//  AM_RANGE(0xfffa40, 0xfffa5f) AM_READWRITE(fpu_r, fpu_w)*/
1362   AM_RANGE(0xff8c80, 0xff8c87) AM_DEVREADWRITE8_LEGACY(Z8530_TAG, scc8530_r, scc8530_w, 0x00ff)
1362   AM_RANGE(0xff8c80, 0xff8c87) AM_DEVREADWRITE8(Z8530_TAG, scc8530_t, reg_r, reg_w, 0x00ff)
13631363   AM_RANGE(0xfffc20, 0xfffc3f) AM_DEVREADWRITE8(RP5C15_TAG, rp5c15_device, read, write, 0x00ff)
13641364ADDRESS_MAP_END
13651365
r13736r13737
25202520   MCFG_CPU_MODIFY(M68000_TAG)
25212521   MCFG_CPU_PROGRAM_MAP(megaste_map)
25222522   MCFG_RP5C15_ADD(RP5C15_TAG, XTAL_32_768kHz, rtc_intf)
2523   MCFG_SCC8530_ADD(Z8530_TAG, Y2/4)
2523   MCFG_SCC8530_ADD(Z8530_TAG, Y2/4, scc8530_t::intrq_cb_t())
25242524
25252525   /* internal ram */
25262526   MCFG_RAM_MODIFY(RAM_TAG)
src/mess/drivers/abc1600.c
r13736r13737
289289         break;
290290
291291      case SCC:
292         data = scc8530_r(m_scc, A1_A2);
292         data = m_scc->reg_r(*m_maincpu->memory().space(AS_PROGRAM), A1_A2);
293293         break;
294294
295295      case CIO:
r13736r13737
543543         break;
544544
545545      case SCC:
546         scc8530_w(m_scc, A1_A2, data);
546         m_scc->reg_w(*m_maincpu->memory().space(AS_PROGRAM), A1_A2, data);
547547         break;
548548
549549      case CIO:
r13736r13737
15361536//  SCC8530_INTERFACE( sc_intf )
15371537//-------------------------------------------------
15381538
1539static void scc_irq(device_t *device, int status)
1539void abc1600_state::scc_irq(int status)
15401540{
1541   abc1600_state *state = device->machine().driver_data<abc1600_state>();
1542
1543   state->m_maincpu->set_input_line(M68K_IRQ_5, status);
1541   m_maincpu->set_input_line(M68K_IRQ_5, status);
15441542}
15451543
15461544
r13736r13737
19161914   MCFG_Z80DMA_ADD(Z8410AB1_1_TAG, XTAL_64MHz/16, dma1_intf)
19171915   MCFG_Z80DMA_ADD(Z8410AB1_2_TAG, XTAL_64MHz/16, dma2_intf)
19181916   MCFG_Z80DART_ADD(Z8470AB1_TAG, XTAL_64MHz/16, dart_intf)
1919   MCFG_SCC8530_ADD(Z8530B1_TAG, XTAL_64MHz/16)
1920   MCFG_SCC8530_IRQ(scc_irq)
1917   MCFG_SCC8530_ADD(Z8530B1_TAG, XTAL_64MHz/16, scc8530_t::intrq_cb_t(FUNC(abc1600_state::scc_irq), static_cast<abc1600_state *>(owner)))
19211918   MCFG_Z8536_ADD(Z8536B1_TAG, XTAL_64MHz/16, cio_intf)
19221919   MCFG_NMC9306_ADD(NMC9306_TAG)
19231920   MCFG_E0516_ADD(E050_C16PC_TAG, XTAL_32_768kHz)
src/mess/drivers/apple2gs.c
r13736r13737
235235   MCFG_APPLE2_SLOT_ADD(6, "fdc", applefdc_r, applefdc_w, 0, 0, 0, 0)
236236
237237   /* SCC */
238   MCFG_SCC8530_ADD("scc", APPLE2GS_14M/2)
238   MCFG_SCC8530_ADD("scc", APPLE2GS_14M/2, scc8530_t::intrq_cb_t())
239239
240240   MCFG_LEGACY_FLOPPY_APPLE_2_DRIVES_ADD(apple2gs_floppy525_floppy_interface,15,16)
241241   MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADDITIONAL_ADD(apple2gs_floppy35_floppy_interface)
src/mess/drivers/mac.c
r13736r13737
920920   MCFG_IWM_ADD("fdc", mac_iwm_interface)
921921   MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface)
922922
923   MCFG_SCC8530_ADD("scc", C7M)
924   MCFG_SCC8530_IRQ(mac_scc_irq)
923   MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner)))
925924   MCFG_VIA6522_ADD("via6522_0", 1000000, mac_via6522_intf)
926925
927926   /* internal ram */
r13736r13737
10061005   MCFG_IWM_ADD("fdc", mac_iwm_interface)
10071006   MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface)
10081007
1009   MCFG_SCC8530_ADD("scc", C7M)
1010   MCFG_SCC8530_IRQ(mac_scc_irq)
1008   MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner)))
10111009   MCFG_VIA6522_ADD("via6522_0", 783360, mac_via6522_intf)
10121010
10131011   MCFG_HARDDISK_CONFIG_ADD( "harddisk1", mac_harddisk_config )
r13736r13737
10531051   MCFG_IWM_ADD("fdc", mac_iwm_interface)
10541052   MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface)
10551053
1056   MCFG_SCC8530_ADD("scc", C7M)
1057   MCFG_SCC8530_IRQ(mac_scc_irq)
1054   MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner)))
10581055
10591056   MCFG_VIA6522_ADD("via6522_0", C7M/10, mac_via6522_adb_intf)
10601057   MCFG_VIA6522_ADD("via6522_1", C7M/10, mac_via6522_2_intf)
r13736r13737
11061103   MCFG_IWM_ADD("fdc", mac_iwm_interface)
11071104   MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface)
11081105
1109   MCFG_SCC8530_ADD("scc", C7M)
1110   MCFG_SCC8530_IRQ(mac_scc_irq)
1106   MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner)))
11111107
11121108   MCFG_VIA6522_ADD("via6522_0", C7M/10, mac_via6522_adb_intf)
11131109
r13736r13737
13101306   MCFG_SWIM_ADD("fdc", mac_iwm_interface)
13111307   MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface)
13121308
1313   MCFG_SCC8530_ADD("scc", C7M)
1314   MCFG_SCC8530_IRQ(mac_scc_irq)
1309   MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner)))
13151310
13161311   MCFG_VIA6522_ADD("via6522_0", 783360, mac_via6522_adb_intf)
13171312   MCFG_VIA6522_ADD("via6522_1", 783360, mac_via6522_2_intf)
r13736r13737
13631358   MCFG_SWIM_ADD("fdc", mac_iwm_interface)
13641359   MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface)
13651360
1366   MCFG_SCC8530_ADD("scc", C7M)
1367   MCFG_SCC8530_IRQ(mac_scc_irq)
1361   MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner)))
13681362
13691363   MCFG_VIA6522_ADD("via6522_0", 783360, mac_via6522_adb_intf)
13701364   MCFG_VIA6522_ADD("via6522_1", 783360, mac_via6522_2_intf)
r13736r13737
14361430   MCFG_SWIM_ADD("fdc", mac_iwm_interface)
14371431   MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface)
14381432
1439   MCFG_SCC8530_ADD("scc", C7M)
1440   MCFG_SCC8530_IRQ(mac_scc_irq)
1433   MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner)))
14411434
14421435   MCFG_VIA6522_ADD("via6522_0", 783360, mac_via6522_adb_intf)
14431436   MCFG_VIA6522_ADD("via6522_1", 783360, mac_via6522_2_intf)
r13736r13737
16121605   MCFG_IWM_ADD("fdc", mac_iwm_interface)
16131606   MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface)
16141607
1615   MCFG_SCC8530_ADD("scc", C7M)
1616   MCFG_SCC8530_IRQ(mac_scc_irq)
1608   MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner)))
16171609
16181610   MCFG_VIA6522_ADD("via6522_0", 783360, mac_via6522_adb_intf)
16191611   MCFG_VIA6522_ADD("via6522_1", 783360, mac_via6522_2_intf)
r13736r13737
16621654   MCFG_IWM_ADD("fdc", mac_iwm_interface)
16631655   MCFG_LEGACY_FLOPPY_SONY_2_DRIVES_ADD(mac_floppy_interface)
16641656
1665   MCFG_SCC8530_ADD("scc", C7M)
1666   MCFG_SCC8530_IRQ(mac_scc_irq)
1657   MCFG_SCC8530_ADD("scc", C7M, scc8530_t::intrq_cb_t(FUNC(mac_state::set_scc_interrupt), static_cast<mac_state *>(owner)))
16671658
16681659   MCFG_VIA6522_ADD("via6522_0", C7M/10, mac_via6522_adb_intf)
16691660   MCFG_VIA6522_ADD("via6522_1", C7M/10, mac_via6522_2_intf)
src/mess/drivers/x68k.c
r13736r13737
538538static int x68k_read_mouse(running_machine &machine)
539539{
540540   x68k_state *state = machine.driver_data<x68k_state>();
541   device_t *scc = machine.device("scc");
541   scc8530_t *scc = machine.device<scc8530_t>("scc");
542542   char val = 0;
543543   char ipt = 0;
544544
545   if(!(scc8530_get_reg_b(scc,5) & 0x02))
545   if(!(scc->get_reg_b(5) & 0x02))
546546      return 0xff;
547547
548548   switch(state->m_mouse.inputtype)
r13736r13737
564564   state->m_mouse.inputtype++;
565565   if(state->m_mouse.inputtype > 2)
566566   {
567      int i_val = scc8530_get_reg_b(scc, 0);
567      int i_val = scc->get_reg_b(0);
568568      state->m_mouse.inputtype = 0;
569569      state->m_mouse.bufferempty = 1;
570570      i_val &= ~0x01;
571      scc8530_set_reg_b(scc, 0, i_val);
571      scc->set_reg_b(0, i_val);
572572      logerror("SCC: mouse buffer empty\n");
573573   }
574574
r13736r13737
583583*/
584584static READ16_HANDLER( x68k_scc_r )
585585{
586   device_t *scc = space->machine().device("scc");
586   scc8530_t *scc = space->machine().device<scc8530_t>("scc");
587587   offset %= 4;
588588   switch(offset)
589589   {
590590   case 0:
591      return scc8530_r(scc, 0);
591      return scc->reg_r(*space, 0);
592592   case 1:
593593      return x68k_read_mouse(space->machine());
594594   case 2:
595      return scc8530_r(scc, 1);
595      return scc->reg_r(*space, 1);
596596   case 3:
597      return scc8530_r(scc, 3);
597      return scc->reg_r(*space, 3);
598598   default:
599599      return 0xff;
600600   }
r13736r13737
603603static WRITE16_HANDLER( x68k_scc_w )
604604{
605605   x68k_state *state = space->machine().driver_data<x68k_state>();
606   device_t *scc = space->machine().device("scc");
606   scc8530_t *scc = space->machine().device<scc8530_t>("scc");
607607   offset %= 4;
608608
609609   switch(offset)
610610   {
611611   case 0:
612      scc8530_w(scc, 0,(UINT8)data);
613      if((scc8530_get_reg_b(scc, 5) & 0x02) != state->m_scc_prev)
612      scc->reg_w(*space, 0,(UINT8)data);
613      if((scc->get_reg_b(5) & 0x02) != state->m_scc_prev)
614614      {
615         if(scc8530_get_reg_b(scc, 5) & 0x02)  // Request to Send
615         if(scc->get_reg_b(5) & 0x02)  // Request to Send
616616         {
617            int val = scc8530_get_reg_b(scc, 0);
617            int val = scc->get_reg_b(0);
618618            state->m_mouse.bufferempty = 0;
619619            val |= 0x01;
620            scc8530_set_reg_b(scc, 0,val);
620            scc->set_reg_b(0,val);
621621         }
622622      }
623623      break;
624624   case 1:
625      scc8530_w(scc, 2,(UINT8)data);
625      scc->reg_w(*space, 2,(UINT8)data);
626626      break;
627627   case 2:
628      scc8530_w(scc, 1,(UINT8)data);
628      scc->reg_w(*space, 1,(UINT8)data);
629629      break;
630630   case 3:
631      scc8530_w(scc, 3,(UINT8)data);
631      scc->reg_w(*space, 3,(UINT8)data);
632632      break;
633633   }
634   state->m_scc_prev = scc8530_get_reg_b(scc, 5) & 0x02;
634   state->m_scc_prev = scc->get_reg_b(5) & 0x02;
635635}
636636
637637static TIMER_CALLBACK(x68k_scc_ack)
638638{
639639   x68k_state *state = machine.driver_data<x68k_state>();
640   device_t *scc = machine.device("scc");
640   scc8530_t *scc = machine.device<scc8530_t>("scc");
641641   if(state->m_mouse.bufferempty != 0)  // nothing to do if the mouse data buffer is empty
642642      return;
643643
r13736r13737
645645//      return;
646646
647647   // hard-code the IRQ vector for now, until the SCC code is more complete
648   if((scc8530_get_reg_a(scc, 9) & 0x08) || (scc8530_get_reg_b(scc, 9) & 0x08))  // SCC reg WR9 is the same for both channels
648   if((scc->get_reg_a(9) & 0x08) || (scc->get_reg_b(9) & 0x08))  // SCC reg WR9 is the same for both channels
649649   {
650      if((scc8530_get_reg_b(scc, 1) & 0x18) != 0)  // if bits 3 and 4 of WR1 are 0, then Rx IRQs are disabled on this channel
650      if((scc->get_reg_b(1) & 0x18) != 0)  // if bits 3 and 4 of WR1 are 0, then Rx IRQs are disabled on this channel
651651      {
652         if(scc8530_get_reg_b(scc, 5) & 0x02)  // RTS signal
652         if(scc->get_reg_b(5) & 0x02)  // RTS signal
653653         {
654654            state->m_mouse.irqactive = 1;
655655            state->m_current_vector[5] = 0x54;
r13736r13737
27732773
27742774   MCFG_HD63450_ADD( "hd63450", dmac_interface )
27752775
2776   MCFG_SCC8530_ADD( "scc", 5000000 )
2776   MCFG_SCC8530_ADD( "scc", 5000000, scc8530_t::intrq_cb_t() )
27772777
27782778   MCFG_RP5C15_ADD(RP5C15_TAG, XTAL_32_768kHz, rtc_intf)
27792779
src/mess/drivers/ip20.c
r13736r13737
2222#include "machine/8530scc.h"
2323#include "machine/sgi.h"
2424#include "machine/eeprom.h"
25#include "machine/8530scc.h"
2625#include "machine/wd33c93.h"
2726#include "imagedev/harddriv.h"
2827#include "imagedev/chd_cd.h"
r13736r13737
106105static READ32_HANDLER( hpc_r )
107106{
108107   ip20_state *state = space->machine().driver_data<ip20_state>();
109   device_t *scc;
108   scc8530_t *scc;
110109   running_machine &machine = space->machine();
111110
112111   offset <<= 2;
r13736r13737
165164   case 0x0d00:
166165      verboselog(machine, 2, "HPC DUART0 Channel B Control Read\n" );
167166//      return 0x00000004;
168      return 0x7c; //scc8530_r(machine, 0);
167      return 0x7c; //scc->reg_r(*space, 0);
169168   case 0x0d04:
170169      verboselog(machine, 2, "HPC DUART0 Channel B Data Read\n" );
171170//      return 0;
172      scc = space->machine().device("scc");
173      return scc8530_r(scc, 2);
171      scc = space->machine().device<scc8530_t>("scc");
172      return scc->reg_r(*space, 2);
174173   case 0x0d08:
175174      verboselog(machine, 2, "HPC DUART0 Channel A Control Read (%08x)\n", mem_mask    );
176175//      return 0x40;
177      return 0x7c; //scc8530_r(machine, 1);
176      return 0x7c; //scc->reg_r(*space, 1);
178177   case 0x0d0c:
179178      verboselog(machine, 2, "HPC DUART0 Channel A Data Read\n" );
180179//      return 0;
181      scc = space->machine().device("scc");
182      return scc8530_r(scc, 3);
180      scc = space->machine().device<scc8530_t>("scc");
181      return scc->reg_r(*space, 3);
183182   case 0x0d10:
184183//      verboselog(machine, 2, "HPC DUART1 Channel B Control Read\n" );
185184      return 0x00000004;
r13736r13737
224223static WRITE32_HANDLER( hpc_w )
225224{
226225   ip20_state *state = space->machine().driver_data<ip20_state>();
227   device_t *scc;
226   scc8530_t *scc;
228227   eeprom_device *eeprom;
229228   running_machine &machine = space->machine();
230229
r13736r13737
363362      break;
364363   case 0x0d00:
365364      verboselog(machine, 2, "HPC DUART0 Channel B Control Write: %08x (%08x)\n", data, mem_mask );
366      scc = space->machine().device("scc");
367      scc8530_w(scc, 0, data);
365      scc = space->machine().device<scc8530_t>("scc");
366      scc->reg_w(*space, 0, data);
368367      break;
369368   case 0x0d04:
370369      verboselog(machine, 2, "HPC DUART0 Channel B Data Write: %08x (%08x)\n", data, mem_mask );
371      scc = space->machine().device("scc");
372      scc8530_w(scc, 2, data);
370      scc = space->machine().device<scc8530_t>("scc");
371      scc->reg_w(*space, 2, data);
373372      break;
374373   case 0x0d08:
375374      verboselog(machine, 2, "HPC DUART0 Channel A Control Write: %08x (%08x)\n", data, mem_mask );
376      scc = space->machine().device("scc");
377      scc8530_w(scc, 1, data);
375      scc = space->machine().device<scc8530_t>("scc");
376      scc->reg_w(*space, 1, data);
378377      break;
379378   case 0x0d0c:
380379      verboselog(machine, 2, "HPC DUART0 Channel A Data Write: %08x (%08x)\n", data, mem_mask );
381      scc = space->machine().device("scc");
382      scc8530_w(scc, 3, data);
380      scc = space->machine().device<scc8530_t>("scc");
381      scc->reg_w(*space, 3, data);
383382      break;
384383   case 0x0d10:
385384      if( ( data & 0x000000ff ) >= 0x00000020 )
r13736r13737
625624   MCFG_SOUND_ADD( "cdda", CDDA, 0 )
626625   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
627626
628   MCFG_SCC8530_ADD("scc", 7000000)
627   MCFG_SCC8530_ADD("scc", 7000000, scc8530_t::intrq_cb_t())
629628
630629   MCFG_CDROM_ADD( "cdrom",ip20_cdrom )
631630

Previous 15994 Revisions Next


© 1998-2018 The MESS Team