Previous 15994 Revisions Next

r4953 Saturday 6th June, 2009 at 18:26:50 UTC by Curt Coder
[Z80STI] Implemented simple timers.
[src/mess/drivers]prof80.c
[src/mess/includes]prof80.h
[src/mess/machine]z80sti.c z80sti.h

src/mess/includes/prof80.h
r4952r4953
11#ifndef __PROF80__
22#define __PROF80__
33
4#define SCREEN_TAG      "screen"
4#define SCREEN_TAG            "screen"
55
6#define Z80_TAG         "z1"
7#define NEC765_TAG      "z38"
8#define UPD1990A_TAG   "z43"
9#define MC6845_TAG      "z30"
10#define PPI8255_TAG      "z6"
11#define Z80STI_TAG      "z9"
6#define Z80_TAG               "z1"
7#define NEC765_TAG            "z38"
8#define UPD1990A_TAG         "z43"
9#define MC6845_TAG            "z30"
10#define PPI8255_TAG            "z6"
11#define Z80STI_TAG            "z9"
1212
13#define GRIP_Z80_TAG         "grip_z1"
14
15#define UNIO_Z80STI_TAG         "z5"
16#define UNIO_Z80SIO_TAG         "z15"
17#define UNIO_Z80PIO_TAG         "z13"
18#define UNIO_CENTRONICS1_TAG   "n3"
19#define UNIO_CENTRONICS2_TAG   "n4"
20
1321#define GRIP_VIDEORAM_SIZE   0x10000
1422#define GRIP_VIDEORAM_MASK   0xffff
1523
src/mess/machine/z80sti.c
r4952r4953
11/***************************************************************************
22
3    Mostek Z80STI Serial Timer Interrupt Controller emulation
3    Mostek MK3801 Serial Timer Interrupt Controller (Z80-STI) emulation
44
5    Copyright (c) 2009, The MESS Team.
5    Copyright MESS Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
77
88***************************************************************************/
r4952r4953
1111
1212   TODO:
1313
14   - timers
15   - serial
14   - timers (other than delay mode)
15   - serial I/O
16   - reset behavior
1617
1718*/
1819
r4952r4953
2930
3031#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
3132
33/* registers */
3234enum
3335{
3436   Z80STI_REGISTER_IR = 0,
r4952r4953
4951   Z80STI_REGISTER_UDR
5052};
5153
54/* variable registers */
5255enum
5356{
5457   Z80STI_REGISTER_IR_SCR = 0,
r4952r4953
6164   Z80STI_REGISTER_IR_TCDC
6265};
6366
67/* timers */
6468enum
6569{
66   Z80STI_TIMER_A = 0,
67   Z80STI_TIMER_B,
68   Z80STI_TIMER_C,
69   Z80STI_TIMER_D,
70   Z80STI_MAX_TIMERS
70   TIMER_A = 0,
71   TIMER_B,
72   TIMER_C,
73   TIMER_D,
74   TIMER_COUNT
7175};
7276
77/* interrupt levels */
7378enum
7479{
7580   Z80STI_IR_P0 = 0,
r4952r4953
9095   Z80STI_IR_P7
9196};
9297
98/* timer C/D control register */
99#define Z80STI_TCDC_TARS   0x80
100#define Z80STI_TCDC_TBRS   0x08
101
102/* interrupt vector register */
103#define Z80STI_PVR_ISE      0x08
104#define Z80STI_PVR_VR4      0x10
105
106/* general purpose I/O interrupt levels */
93107static const int INT_LEVEL_GPIP[] =
94108{
95109   Z80STI_IR_P0, Z80STI_IR_P1, Z80STI_IR_P2, Z80STI_IR_P3,   Z80STI_IR_P4, Z80STI_IR_P5, Z80STI_IR_P6, Z80STI_IR_P7
96110};
97111
112/* timer interrupt levels */
98113static const int INT_LEVEL_TIMER[] =
99114{
100115   Z80STI_IR_TA, Z80STI_IR_TB, Z80STI_IR_TC, Z80STI_IR_TD
101116};
102117
118/* interrupt vectors */
103119static const UINT8 INT_VECTOR[] =
104120{
105   0x00, 0x01, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e
121   0x00, 0x01, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e,
122   0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e
106123};
107124
125/* timer prescaler divisors */
108126static const int PRESCALER[] = { 0, 4, 10, 16, 50, 64, 100, 200 };
109127
110128/***************************************************************************
r4952r4953
114132typedef struct _z80sti_t z80sti_t;
115133struct _z80sti_t
116134{
117   devcb_resolved_read8      in_gpio_func;
118   devcb_resolved_write8      out_gpio_func;
119   devcb_resolved_read_line   in_si_func;
120   devcb_resolved_write_line   out_so_func;
121   devcb_resolved_write_line   out_tao_func;
122   devcb_resolved_write_line   out_tbo_func;
123   devcb_resolved_write_line   out_tco_func;
124   devcb_resolved_write_line   out_tdo_func;
125   devcb_resolved_write_line   out_int_func;
135   /* device callbacks */
136   devcb_resolved_read8            in_gpio_func;
137   devcb_resolved_write8            out_gpio_func;
138   devcb_resolved_read_line         in_si_func;
139   devcb_resolved_write_line         out_so_func;
140   devcb_resolved_write_line         out_tao_func;
141   devcb_resolved_write_line         out_tbo_func;
142   devcb_resolved_write_line         out_tco_func;
143   devcb_resolved_write_line         out_tdo_func;
144   devcb_resolved_write_line         out_int_func;
126145
127146   /* I/O state */
128147   UINT8 gpip;                     /* general purpose I/O register */
r4952r4953
134153   UINT16 ipr;                     /* interrupt pending register */
135154   UINT16 isr;                     /* interrupt in-service register */
136155   UINT16 imr;                     /* interrupt mask register */
137   UINT8 pvr;                     /* */
156   UINT8 pvr;                     /* interrupt vector register */
138157   int int_state[16];               /* interrupt state */
139158
140159   /* timer state */
141160   UINT8 tabc;                     /* timer A/B control register */
142161   UINT8 tcdc;                     /* timer C/D control register */
143   UINT8 tdr[Z80STI_MAX_TIMERS];      /* timer data registers */
144   UINT8 tmc[Z80STI_MAX_TIMERS];      /* timer main counters */
145   int to[Z80STI_MAX_TIMERS];         /* timer out latch */
162   UINT8 tdr[TIMER_COUNT];            /* timer data registers */
163   UINT8 tmc[TIMER_COUNT];            /* timer main counters */
164   int to[TIMER_COUNT];            /* timer out latch */
146165
147166   /* serial state */
148167   UINT8 scr;                     /* synchronous character register */
r4952r4953
152171   UINT8 udr;                     /* USART data register */
153172
154173   /* timers */
155   emu_timer *timer[Z80STI_MAX_TIMERS];   /* counter timers */
156   emu_timer *rx_timer;               /* serial receive timer */
157   emu_timer *tx_timer;               /* serial transmit timer */
174   emu_timer *timer[TIMER_COUNT];      /* counter timers */
175   emu_timer *rx_timer;            /* serial receive timer */
176   emu_timer *tx_timer;            /* serial transmit timer */
158177};
159178
160179/***************************************************************************
r4952r4953
210229
211230static void take_interrupt(z80sti_t *z80sti, int level)
212231{
232   /* set interrupt pending register bit */
213233   z80sti->ipr |= 1 << level;
214234
215235   /* trigger interrupt */
r4952r4953
272292      switch (z80sti->pvr & 0x07)
273293      {
274294      case Z80STI_REGISTER_IR_SCR:   return z80sti->scr;
275      case Z80STI_REGISTER_IR_TDDR:   return z80sti->tmc[Z80STI_TIMER_D];
276      case Z80STI_REGISTER_IR_TCDR:   return z80sti->tmc[Z80STI_TIMER_C];
295      case Z80STI_REGISTER_IR_TDDR:   return z80sti->tmc[TIMER_D];
296      case Z80STI_REGISTER_IR_TCDR:   return z80sti->tmc[TIMER_C];
277297      case Z80STI_REGISTER_IR_AER:   return z80sti->aer;
278298      case Z80STI_REGISTER_IR_IERB:   return z80sti->ier & 0xff;
279299      case Z80STI_REGISTER_IR_IERA:   return z80sti->ier >> 8;
r4952r4953
291311   case Z80STI_REGISTER_IMRA:   return z80sti->imr >> 8;
292312   case Z80STI_REGISTER_PVR:   return z80sti->pvr;
293313   case Z80STI_REGISTER_TABC:   return z80sti->tabc;
294   case Z80STI_REGISTER_TBDR:   return z80sti->tmc[Z80STI_TIMER_B];
295   case Z80STI_REGISTER_TADR:   return z80sti->tmc[Z80STI_TIMER_A];
314   case Z80STI_REGISTER_TBDR:   return z80sti->tmc[TIMER_B];
315   case Z80STI_REGISTER_TADR:   return z80sti->tmc[TIMER_A];
296316   case Z80STI_REGISTER_UCR:   return z80sti->ucr;
297317   case Z80STI_REGISTER_RSR:   return z80sti->rsr;
298318   case Z80STI_REGISTER_TSR:   return z80sti->tsr;
r4952r4953
315335   case Z80STI_REGISTER_IR:
316336      switch (z80sti->pvr & 0x07)
317337      {
318      /*
319338      case Z80STI_REGISTER_IR_SCR:
320339         LOG(("Z80STI '%s' Sync Character Register: %x\n", device->tag, data));
321340         z80sti->scr = data;
322341         break;
323      */
342
324343      case Z80STI_REGISTER_IR_TDDR:
325344         LOG(("Z80STI '%s' Timer D Data Register: %x\n", device->tag, data));
326         z80sti->tdr[Z80STI_TIMER_D] = data;
345         z80sti->tdr[TIMER_D] = data;
327346         break;
328347
329348      case Z80STI_REGISTER_IR_TCDR:
330349         LOG(("Z80STI '%s' Timer C Data Register: %x\n", device->tag, data));
331         z80sti->tdr[Z80STI_TIMER_C] = data;
350         z80sti->tdr[TIMER_C] = data;
332351         break;
333352
334353      case Z80STI_REGISTER_IR_AER:
r4952r4953
337356         break;
338357
339358      case Z80STI_REGISTER_IR_IERB:
340         LOG(("Z80STI '%s' Interrupt Enable B Register: %x\n", device->tag, data));
359         LOG(("Z80STI '%s' Interrupt Enable Register B: %x\n", device->tag, data));
341360         z80sti->ier = (z80sti->ier & 0xff00) | data;
342361         check_interrupts(z80sti);
343362         break;
344363
345364      case Z80STI_REGISTER_IR_IERA:
346         LOG(("Z80STI '%s' Interrupt Enable A Register: %x\n", device->tag, data));
365         LOG(("Z80STI '%s' Interrupt Enable Register A: %x\n", device->tag, data));
347366         z80sti->ier = (data << 8) | (z80sti->ier & 0xff);
348367         check_interrupts(z80sti);
349368         break;
r4952r4953
354373         break;
355374
356375      case Z80STI_REGISTER_IR_TCDC:
376         {
377         int tcc = PRESCALER[(data >> 4) & 0x07];
378         int tdc = PRESCALER[data & 0x07];
379
357380         z80sti->tcdc = data;
381
382         LOG(("Z80STI '%s' Timer C Prescaler: %u\n", device->tag, tcc));
383         LOG(("Z80STI '%s' Timer D Prescaler: %u\n", device->tag, tdc));
384
385         if (tcc)
386            timer_adjust_periodic(z80sti->timer[TIMER_C], ATTOTIME_IN_HZ(device->clock / tcc), 0, ATTOTIME_IN_HZ(device->clock / tcc));
387         else
388            timer_enable(z80sti->timer[TIMER_C], 0);
389
390         if (tdc)
391            timer_adjust_periodic(z80sti->timer[TIMER_D], ATTOTIME_IN_HZ(device->clock / tdc), 0, ATTOTIME_IN_HZ(device->clock / tdc));
392         else
393            timer_enable(z80sti->timer[TIMER_D], 0);
394
395         if (BIT(data, 7))
396         {
397            LOG(("Z80STI '%s' Timer A Reset\n", device->tag));
398            z80sti->to[TIMER_A] = 0;
399
400            devcb_call_write_line(&z80sti->out_tao_func, z80sti->to[TIMER_A]);
401         }
402
403         if (BIT(data, 3))
404         {
405            LOG(("Z80STI '%s' Timer B Reset\n", device->tag));
406            z80sti->to[TIMER_B] = 0;
407
408            devcb_call_write_line(&z80sti->out_tbo_func, z80sti->to[TIMER_B]);
409         }
410         }
358411         break;
359
360      default:
361         LOG(("Z80STI '%s' Unimplemented IR Register %x\n", device->tag, z80sti->pvr & 0x07));
362412      }
363413      break;
364414
r4952r4953
369419      break;
370420
371421   case Z80STI_REGISTER_IPRB:
372      LOG(("Z80STI '%s' Interrupt Pending B Register: %x\n", device->tag, data));
422      LOG(("Z80STI '%s' Interrupt Pending Register B: %x\n", device->tag, data));
373423      z80sti->ipr = (z80sti->ipr & 0xff00) | data;
374424      check_interrupts(z80sti);
375425      break;
376426
377427   case Z80STI_REGISTER_IPRA:
378      LOG(("Z80STI '%s' Interrupt Pending A Register: %x\n", device->tag, data));
428      LOG(("Z80STI '%s' Interrupt Pending Register A: %x\n", device->tag, data));
379429      z80sti->ipr = (data << 8) | (z80sti->ipr & 0xff);
380430      check_interrupts(z80sti);
381431      break;
382432
383433   case Z80STI_REGISTER_ISRB:
384      LOG(("Z80STI '%s' Interrupt In-Service B Register: %x\n", device->tag, data));
434      LOG(("Z80STI '%s' Interrupt In-Service Register B: %x\n", device->tag, data));
385435      z80sti->isr = (z80sti->isr & 0xff00) | data;
386436      break;
387437
388438   case Z80STI_REGISTER_ISRA:
389      LOG(("Z80STI '%s' Interrupt In-Service A Register: %x\n", device->tag, data));
439      LOG(("Z80STI '%s' Interrupt In-Service Register A: %x\n", device->tag, data));
390440      z80sti->isr = (data << 8) | (z80sti->isr & 0xff);
391441      break;
392442
393443   case Z80STI_REGISTER_IMRB:
394      LOG(("Z80STI '%s' Interrupt Mask B Register: %x\n", device->tag, data));
444      LOG(("Z80STI '%s' Interrupt Mask Register B: %x\n", device->tag, data));
395445      z80sti->imr = (data << 8) | (z80sti->imr & 0xff);
396446      check_interrupts(z80sti);
397447      break;
398448
399449   case Z80STI_REGISTER_IMRA:
400      LOG(("Z80STI '%s' Interrupt Mask A Register: %x\n", device->tag, data));
450      LOG(("Z80STI '%s' Interrupt Mask Register A: %x\n", device->tag, data));
401451      z80sti->imr = (data << 8) | (z80sti->imr & 0xff);
402452      check_interrupts(z80sti);
403453      break;
404454
405455   case Z80STI_REGISTER_PVR:
456      LOG(("Z80STI '%s' Interrupt Vector: %02x\n", device->tag, data & 0xe0));
457      LOG(("Z80STI '%s' IR Address: %01x\n", device->tag, data & 0x07));
406458      z80sti->pvr = data;
407459      break;
408460
409461   case Z80STI_REGISTER_TABC:
462      {
463      int tac = PRESCALER[(data >> 4) & 0x07];
464      int tbc = PRESCALER[data & 0x07];
465
410466      z80sti->tabc = data;
467
468      LOG(("Z80STI '%s' Timer A Prescaler: %u\n", device->tag, tac));
469      LOG(("Z80STI '%s' Timer B Prescaler: %u\n", device->tag, tbc));
470
471      if (tac)
472         timer_adjust_periodic(z80sti->timer[TIMER_A], ATTOTIME_IN_HZ(device->clock / tac), 0, ATTOTIME_IN_HZ(device->clock / tac));
473      else
474         timer_enable(z80sti->timer[TIMER_A], 0);
475
476      if (tbc)
477         timer_adjust_periodic(z80sti->timer[TIMER_B], ATTOTIME_IN_HZ(device->clock / tbc), 0, ATTOTIME_IN_HZ(device->clock / tbc));
478      else
479         timer_enable(z80sti->timer[TIMER_B], 0);
480      }
411481      break;
412482
413483   case Z80STI_REGISTER_TBDR:
414484      LOG(("Z80STI '%s' Timer B Data Register: %x\n", device->tag, data));
415      z80sti->tdr[Z80STI_TIMER_B] = data;
485      z80sti->tdr[TIMER_B] = data;
416486      break;
417487
418488   case Z80STI_REGISTER_TADR:
419489      LOG(("Z80STI '%s' Timer A Data Register: %x\n", device->tag, data));
420      z80sti->tdr[Z80STI_TIMER_A] = data;
490      z80sti->tdr[TIMER_A] = data;
421491      break;
422492/*
423493   case Z80STI_REGISTER_UCR:
r4952r4953
437507      break;
438508*/
439509   default:
440      LOG(("Z80STI '%s' Unimplemented Register %x\n", device->tag, offset & 0x0f));
510      LOG(("Z80STI '%s' Unsupported Register %x\n", device->tag, offset & 0x0f));
441511   }
442512}
443513
r4952r4953
473543    timer_count - timer count down
474544-------------------------------------------------*/
475545
476static void timer_count(z80sti_t *z80sti, int index)
546static void timer_count(const device_config *device, int index)
477547{
548   z80sti_t *z80sti = get_safe_token(device);
549
478550   if (z80sti->tmc[index] == 0x01)
479551   {
552      //LOG(("Z80STI '%s' Timer %c Expired\n", device->tag, 'A' + index));
553
480554      /* toggle timer output signal */
481555      z80sti->to[index] = !z80sti->to[index];
482556
483557      switch (index)
484558      {
485      case Z80STI_TIMER_A: devcb_call_write_line(&z80sti->out_tao_func, z80sti->to[index]); break;
486      case Z80STI_TIMER_B: devcb_call_write_line(&z80sti->out_tbo_func, z80sti->to[index]); break;
487      case Z80STI_TIMER_C: devcb_call_write_line(&z80sti->out_tco_func, z80sti->to[index]); break;
488      case Z80STI_TIMER_D: devcb_call_write_line(&z80sti->out_tdo_func, z80sti->to[index]); break;
559      case TIMER_A: devcb_call_write_line(&z80sti->out_tao_func, z80sti->to[index]); break;
560      case TIMER_B: devcb_call_write_line(&z80sti->out_tbo_func, z80sti->to[index]); break;
561      case TIMER_C: devcb_call_write_line(&z80sti->out_tco_func, z80sti->to[index]); break;
562      case TIMER_D: devcb_call_write_line(&z80sti->out_tdo_func, z80sti->to[index]); break;
489563      }
490564
491      if (z80sti->ier & INT_LEVEL_TIMER[index])
565      if (z80sti->ier & (1 << INT_LEVEL_TIMER[index]))
492566      {
567         LOG(("Z80STI '%s' Interrupt Pending for Timer %c\n", device->tag, 'A' + index));
568
493569         /* signal timer elapsed interrupt */
494570         take_interrupt(z80sti, INT_LEVEL_TIMER[index]);
495571      }
496572
497      /* load main counter */
573      /* load timer main counter */
498574      z80sti->tmc[index] = z80sti->tdr[index];
499575   }
500576   else
r4952r4953
508584    TIMER_CALLBACK( timer_# )
509585-------------------------------------------------*/
510586
511static TIMER_CALLBACK( timer_a ) { z80sti_t *z80sti = get_safe_token(ptr); timer_count(z80sti, Z80STI_TIMER_A); }
512static TIMER_CALLBACK( timer_b ) { z80sti_t *z80sti = get_safe_token(ptr); timer_count(z80sti, Z80STI_TIMER_B); }
513static TIMER_CALLBACK( timer_c ) { z80sti_t *z80sti = get_safe_token(ptr); timer_count(z80sti, Z80STI_TIMER_C); }
514static TIMER_CALLBACK( timer_d ) { z80sti_t *z80sti = get_safe_token(ptr); timer_count(z80sti, Z80STI_TIMER_D); }
587static TIMER_CALLBACK( timer_a ) { timer_count(ptr, TIMER_A); }
588static TIMER_CALLBACK( timer_b ) { timer_count(ptr, TIMER_B); }
589static TIMER_CALLBACK( timer_c ) { timer_count(ptr, TIMER_C); }
590static TIMER_CALLBACK( timer_d ) { timer_count(ptr, TIMER_D); }
515591
516592/*-------------------------------------------------
517    gpip_input - GPIP input write
593    gpip_input - GPIP input line write
518594-------------------------------------------------*/
519595
520596static void gpip_input(const device_config *device, int bit, int state)
r4952r4953
528604   {
529605      LOG(("Z80STI '%s' Edge Transition Detected on Bit: %u\n", device->tag, bit));
530606
531      if (z80sti->ier & INT_LEVEL_GPIP[bit])
607      if (z80sti->ier & (1 << INT_LEVEL_GPIP[bit]))
532608      {
533609         LOG(("Z80STI '%s' Interrupt Pending for P%u\n", device->tag, bit));
534610
r4952r4953
540616}
541617
542618/*-------------------------------------------------
543    z80sti_i#_w - input # write
619    z80sti_i#_w - GPIP input line # write
544620-------------------------------------------------*/
545621
546622WRITE_LINE_DEVICE_HANDLER( z80sti_i0_w ) { gpip_input(device, 0, state); }
r4952r4953
673749   devcb_resolve_write_line(&z80sti->out_int_func, &intf->out_int_func, device);
674750
675751   /* create the counter timers */
676   z80sti->timer[Z80STI_TIMER_A] = timer_alloc(device->machine, timer_a, (void *)device);
677   z80sti->timer[Z80STI_TIMER_B] = timer_alloc(device->machine, timer_b, (void *)device);
678   z80sti->timer[Z80STI_TIMER_C] = timer_alloc(device->machine, timer_c, (void *)device);
679   z80sti->timer[Z80STI_TIMER_D] = timer_alloc(device->machine, timer_d, (void *)device);
752   z80sti->timer[TIMER_A] = timer_alloc(device->machine, timer_a, (void *)device);
753   z80sti->timer[TIMER_B] = timer_alloc(device->machine, timer_b, (void *)device);
754   z80sti->timer[TIMER_C] = timer_alloc(device->machine, timer_c, (void *)device);
755   z80sti->timer[TIMER_D] = timer_alloc(device->machine, timer_d, (void *)device);
680756
681757   /* create serial receive clock timer */
682758   if (intf->rx_clock > 0)
r4952r4953
745821
746822      /* --- the following bits of info are returned as NULL-terminated strings --- */
747823      case DEVINFO_STR_NAME:                     strcpy(info->s, "Mostek MK3801");            break;
748      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Z80 STI");                  break;
824      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Z80-STI");                  break;
749825      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                     break;
750826      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                  break;
751827      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");      break;
src/mess/machine/z80sti.h
r4952r4953
11/**********************************************************************
22
3    Mostek MK3801 Serial Timer Interrupt Controller emulation
3    Mostek MK3801 Serial Timer Interrupt Controller (Z80-STI) emulation
44
55    Copyright MESS Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
r4952r4953
8282   /* this gets called for each change of the TDO pin (pin 4) */
8383   devcb_write_line      out_tdo_func;
8484
85   /* this gets called on each change of the interrupt line (pin 17) */
85   /* this gets called on each change of the _INT pin (pin 17) */
8686   devcb_write_line      out_int_func;
8787};
8888
r4952r4953
103103/* transmit clock */
104104WRITE_LINE_DEVICE_HANDLER( z80sti_tc_w );
105105
106/* input write */
106/* GPIP input lines */
107107WRITE_LINE_DEVICE_HANDLER( z80sti_i0_w );
108108WRITE_LINE_DEVICE_HANDLER( z80sti_i1_w );
109109WRITE_LINE_DEVICE_HANDLER( z80sti_i2_w );
src/mess/drivers/prof80.c
r4952r4953
11/*
22
33   PROF-80 (Prozessor RAM-Floppy Kontroller)
4   GRIP-1/2/3/5 (Grafik-Interface-Prozessor)
4   GRIP-1/2/3/4/5 (Grafik-Interface-Prozessor)
5   UNIO-1 (?)
56
67   http://www.prof80.de/
78   http://oldcomputers.dyndns.org/public/pub/rechner/conitec/info.html
r4952r4953
1213
1314   TODO:
1415
16   - PPI8255 Mode 2 is broken
17   - MC6845 DE callback is broken
1518   - Z80 STI (Mostek MK3801) push-model
16   - PROF-GRIP communications
19   - RAM banking
20   - floppy access
1721   - UNIO card (Z80-STI, Z80-SIO, 2x centronics)
1822   - GRIP-COLOR (192kB color RAM)
19   - GRIP 1/2/3/5 selection
23   - GRIP 1/2/3/4/5 selection
2024   
2125*/
2226
r4952r4953
260264   prof80_bankswitch(space->machine);
261265}
262266
267static READ8_HANDLER( gripc_r )
268{
269   prof80_state *state = space->machine->driver_data;
270
271   return state->ecb_status;
272}
273
274static READ8_HANDLER( gripd_r )
275{
276   prof80_state *state = space->machine->driver_data;
277
278   /* trigger GRIP 8255 port C bit 6 (_ACKA) */
279   ppi8255_set_port_c(state->ppi8255, 0x54);
280   ppi8255_set_port_c(state->ppi8255, 0x14);
281   ppi8255_set_port_c(state->ppi8255, 0x54);
282
283   return state->ecb_data;
284}
285
286static WRITE8_HANDLER( gripd_w )
287{
288   prof80_state *state = space->machine->driver_data;
289
290   state->ecb_data = data;
291
292   /* trigger GRIP 8255 port C bit 4 (_STBA) */
293   ppi8255_set_port_c(state->ppi8255, 0x54);
294   ppi8255_set_port_c(state->ppi8255, 0x44);
295   ppi8255_set_port_c(state->ppi8255, 0x54);
296}
297
263298/* GRIP */
264299
265300static WRITE8_HANDLER( page_w )
r4952r4953
327362   centronics_strobe_w(state->centronics, 1);
328363}
329364
330static READ8_HANDLER( gripc_r )
331{
332   prof80_state *state = space->machine->driver_data;
365/* UNIO */
333366
334   return state->ecb_status;
335}
336
337static READ8_HANDLER( gripd_r )
367static WRITE8_HANDLER( unio_ctrl_w )
338368{
339   prof80_state *state = space->machine->driver_data;
369//   prof80_state *state = space->machine->driver_data;
340370
341   /* trigger GRIP 8255 port C */
342   ppi8255_set_port_c(state->ppi8255, 0x44);
371//   int flag = BIT(data, 0);
372   int flad = (data >> 1) & 0x07;
343373
344   return state->ecb_data;
374   switch (flad)
375   {
376   case 0: /* CG1 */
377   case 1: /* CG2 */
378   case 2: /* _STB1 */
379   case 3: /* _STB2 */
380   case 4: /* _INIT */
381   case 5: /* JSO0 */
382   case 6: /* JSO1 */
383   case 7: /* JSO2 */
384      break;
385   }
345386}
346387
347static WRITE8_HANDLER( gripd_w )
348{
349   prof80_state *state = space->machine->driver_data;
350
351   state->ecb_data = data;
352
353   /* trigger GRIP 8255 port C */
354   ppi8255_set_port_c(state->ppi8255, 0x14);
355}
356
357388/* Memory Maps */
358389
359390static ADDRESS_MAP_START( prof80_mem, ADDRESS_SPACE_PROGRAM, 8 )
r4952r4953
376407ADDRESS_MAP_END
377408
378409static ADDRESS_MAP_START( prof80_io, ADDRESS_SPACE_IO, 8 )
379//   AM_RANGE(0x80, 0x8f) AM_MIRROR(0xff00) AM_DEVREADWRITE(Z80STI_TAG, z80sti_r, z80sti_w)
380//   AM_RANGE(0x94, 0x95) AM_MIRROR(0xff00) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_d_r, z80sio_d_w)
381//   AM_RANGE(0x96, 0x97) AM_MIRROR(0xff00) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_c_r, z80sio_c_w)
382//   AM_RANGE(0x9e, 0x9e) AM_MIRROR(0xff00) AM_WRITE(unio_w) (4=_STB1, 6=_STB2, 8=INIT)
383//   AM_RANGE(0x9c, 0x9c) AM_MIRROR(0xff00) AM_DEVWRITE("centronics1", centronics_data_w)
384//   AM_RANGE(0x9d, 0x9d) AM_MIRROR(0xff00) AM_DEVWRITE("centronics2", centronics_data_w)
410//   AM_RANGE(0x80, 0x8f) AM_MIRROR(0xff00) AM_DEVREADWRITE(UNIO_Z80STI_TAG, z80sti_r, z80sti_w)
411//   AM_RANGE(0x94, 0x95) AM_MIRROR(0xff00) AM_DEVREADWRITE(UNIO_Z80SIO_TAG, z80sio_d_r, z80sio_d_w)
412//   AM_RANGE(0x96, 0x97) AM_MIRROR(0xff00) AM_DEVREADWRITE(UNIO_Z80SIO_TAG, z80sio_c_r, z80sio_c_w)
413   AM_RANGE(0x9e, 0x9e) AM_MIRROR(0xff00) AM_WRITE(unio_ctrl_w)
414//   AM_RANGE(0x9c, 0x9c) AM_MIRROR(0xff00) AM_DEVWRITE(UNIO_CENTRONICS1_TAG, centronics_data_w)
415//   AM_RANGE(0x9d, 0x9d) AM_MIRROR(0xff00) AM_DEVWRITE(UNIO_CENTRONICS1_TAG, centronics_data_w)
385416   AM_RANGE(0xc0, 0xc0) AM_MIRROR(0xff00) AM_READ(gripc_r)
386417   AM_RANGE(0xc1, 0xc1) AM_MIRROR(0xff00) AM_READWRITE(gripd_r, gripd_w)
387418   AM_RANGE(0xd8, 0xd8) AM_MIRROR(0xff00) AM_WRITE(flr_w)
r4952r4953
449480{
450481   prof80_state *state = device->machine->driver_data;
451482
483//   logerror("DE changed to %u\n", display_enabled);
484   
452485   z80sti_i1_w(state->z80sti, display_enabled);
453486}
454487
r4952r4953
582615
583616        bit      signal      description
584617
585        PC0     STI I4
586        PC1     KBF
587        PC2     _KBSTB
588        PC3     STI I7
589        PC4               1 when PROF-80 reads port 0xc0
590        PC5     PA6
591        PC6               1 when PROF-80 writes port 0xc0
592        PC7     PA7
618      PC0     INTRB      interrupt B output (keyboard)
619        PC1     KBF         input buffer B full output (keyboard)
620        PC2     _KBSTB      strobe B input (keyboard)
621        PC3     INTRA      interrupt A output (PROF-80)
622        PC4      _STBA      strobe A input (PROF-80)
623        PC5     IBFA      input buffer A full output (PROF-80)
624        PC6      _ACKA      acknowledge A input (PROF-80)
625        PC7     _OBFA      output buffer full output (PROF-80)
593626   
594627   */
595628
596   return 0x04;
629   return 0x54;
597630}
598631
599632static WRITE8_DEVICE_HANDLER( grip_ppi8255_c_w )
r4952r4953
602635
603636        bit      signal      description
604637
605        PC0     STI I4
606        PC1     KBF
607        PC2     _KBSTB
608        PC3     STI I7
609        PC4               1 when PROF-80 reads port 0xc0
610        PC5     PA6
611        PC6               1 when PROF-80 writes port 0xc0
612        PC7     PA7
638      PC0     INTRB      interrupt B output (keyboard)
639        PC1     KBF         input buffer B full output (keyboard)
640        PC2     _KBSTB      strobe B input (keyboard)
641        PC3     INTRA      interrupt A output (PROF-80)
642        PC4      _STBA      strobe A input (PROF-80)
643        PC5     IBFA      input buffer A full output (PROF-80)
644        PC6      _ACKA      acknowledge A input (PROF-80)
645        PC7     _OBFA      output buffer full output (PROF-80)
613646   
614647   */
615648
616649   prof80_state *state = device->machine->driver_data;
617650
618   state->ecb_status = (BIT(data, 7) << 7) | (BIT(data, 5) << 6);
651   /* keyboard interrupt */
652   z80sti_i4_w(state->z80sti, BIT(data, 0));
653
654   /* PROF-80 interrupt */
655   z80sti_i7_w(state->z80sti, BIT(data, 3));
656
657   /* PROF-80 handshaking */
658   state->ecb_status = (!BIT(data, 7) << 7) | (!BIT(data, 5) << 6);
659   logerror("IBF %u OBF %u status %02x\n", BIT(data, 5), BIT(data, 7), state->ecb_status);
619660}
620661
621662static const ppi8255_interface grip_ppi8255_interface =
r4952r4953
630671
631672/* Z80-STI Interface */
632673
674static READ8_DEVICE_HANDLER( grip_z80sti_gpio_r )
675{
676   /*
677
678        bit      signal      description
679
680        I0      CTS         RS-232 clear to send input
681        I1      DE         MC6845 display enable input
682        I2      CURSOR      MC6845 cursor input
683        I3      BUSY      Centronics busy input
684        I4      PC0         PPI8255 PC0 input
685        I5      SKBD      Serial keyboard input
686        I6      EXIN      External interrupt input
687        I7      PC3         PPI8255 PC3 input
688   
689   */
690
691//   prof80_state *state = device->machine->driver_data;
692
693//   return state->pc3 << 7 | state->exin << 6 | state->skbd << 5 | state->pc0 << 4 | busy << 3 | state->cursor << 2 | state->de << 1 | state->cts;
694
695   return 0;
696}
697
698static WRITE_LINE_DEVICE_HANDLER( grip_z80sti_tbo_w )
699{
700   // connected to speaker
701}
702
633703static WRITE_LINE_DEVICE_HANDLER( grip_z80sti_irq_w )
634704{
635   cputag_set_input_line(device->machine, "grip", INPUT_LINE_IRQ0, state);
705   cputag_set_input_line(device->machine, GRIP_Z80_TAG, INPUT_LINE_IRQ0, state);
636706}
637707
638708static Z80STI_INTERFACE( grip_z80sti_interface )
639709{
640   0,
641   0,
642   DEVCB_NULL,
643   DEVCB_NULL,
644   DEVCB_NULL,
645   DEVCB_NULL,
646   DEVCB_NULL,
647   DEVCB_NULL,
648   DEVCB_NULL,
649   DEVCB_NULL,
650   DEVCB_LINE(grip_z80sti_irq_w)
710   0,                           /* serial receive clock */
711   0,                           /* serial transmit clock */
712   DEVCB_DEVICE_HANDLER(Z80STI_TAG, grip_z80sti_gpio_r),   /* GPIO read */
713   DEVCB_NULL,                     /* GPIO write */
714   DEVCB_NULL,                     /* serial input */
715   DEVCB_NULL,                     /* serial output */
716   DEVCB_NULL,                     /* timer A output */
717   DEVCB_LINE(grip_z80sti_tbo_w),      /* timer B output */
718   DEVCB_LINE(z80sti_tc_w),         /* timer C output */
719   DEVCB_LINE(z80sti_rc_w),         /* timer D output */
720   DEVCB_LINE(grip_z80sti_irq_w)      /* interrupt */
651721};
652722
653723/* Z80 Daisy Chain */
r4952r4953
707777
708778static MACHINE_RESET( prof80 )
709779{
780   prof80_state *state = machine->driver_data;
781
710782   int i;
711783
712784   for (i = 0; i < 8; i++)
r4952r4953
714786   // write all zeroes 0 flr_W
715787      //UINT8 data = (i << 4) | (i << 1);
716788   }
789
790   state->ecb_status = 0x40;
717791}
718792
719793/* Machine Drivers */
r4952r4953
726800    MDRV_CPU_PROGRAM_MAP(prof80_mem)
727801    MDRV_CPU_IO_MAP(prof80_io)
728802
729    MDRV_CPU_ADD("grip", Z80, XTAL_16MHz/4)
803    MDRV_CPU_ADD(GRIP_Z80_TAG, Z80, XTAL_16MHz/4)
730804   MDRV_CPU_CONFIG(grip_daisy_chain)
731805    MDRV_CPU_PROGRAM_MAP(grip_mem)
732806    MDRV_CPU_IO_MAP(grip_io)
r4952r4953
779853   ROM_COPY( Z80_TAG, 0xf0000, 0x70000, 0x10000 ) // block 7
780854   ROM_COPY( Z80_TAG, 0xf0000, 0x60000, 0x10000 ) // block 6
781855
782   ROM_REGION( 0x10000, "grip", 0 )
856   ROM_REGION( 0x10000, GRIP_Z80_TAG, 0 )
783857   ROM_LOAD( "grip21.z2", 0x0000, 0x4000, CRC(7f6a37dd) SHA1(2e89f0b0c378257ff7e41c50d57d90865c6e214b) )
784858   ROM_LOAD( "grip26.z2", 0x0000, 0x4000, CRC(a1c424f0) SHA1(83942bc75b9475f044f936b8d9d7540551d87db9) )
785859   ROM_LOAD( "grip31.z2", 0x0000, 0x4000, CRC(e0e4e8ab) SHA1(73d3d14c9b06fed0c187fb0fffe5ec035d8dd256) )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team