Previous 15994 Revisions Next

r9354 Sunday 10th October, 2010 at 12:21:09 UTC by Angelo Salese
[Mega CD]: Added export status hooks
[src/mame/drivers]megadriv.c

src/mame/drivers/megadriv.c
r9353r9354
364364
365365/* Sega CD stuff */
366366static int sega_cd_connected = 0x00;
367static UINT16 segacd_cdd_ctrl,segacd_irq_mask;
368static UINT8 segacd_cdd_recv[10];
367static UINT16 segacd_irq_mask;
368static UINT8 segacd_cdd_rx[10];
369static struct
370{
371   UINT8 status;
372   UINT8 minute;
373   UINT8 seconds;
374   UINT8 frame;
375   UINT8 ext;
376   UINT8 ctrl;
377}segacd_cdd;
369378
370379#ifdef UNUSED_FUNCTION
371380/* taken from segaic16.c */
r9353r9354
43064315
43074316   for(i=0;i<10;i++)
43084317   {
4309      segacd_cdd_recv[i] = 0;
4318      segacd_cdd_rx[i] = 0;
43104319   }
43114320
4312   segacd_cdd_recv[9] = 0xf; // default checksum
4321   segacd_cdd_rx[9] = 0xf; // default checksum
43134322}
43144323
43154324
r9353r9354
44254434   }
44264435}
44274436
4437static void cdd_hock_irq(running_machine *machine)
4438{
4439   int i,cdd_crc;
4440
4441   if(segacd_cdd.ctrl & 4 && segacd_irq_mask & 0x10) // export status, check if bit 2 (HOst ClocK) and irq is enabled
4442   {
4443      // TODO: this shouldn't be instant, CDD should first fill receive data.
4444      segacd_cdd.ctrl &= 0x103; // clear HOCK flag
4445
4446      segacd_cdd_rx[0] = (segacd_cdd.status & 0xf0) >> 4;
4447      segacd_cdd_rx[1] = (segacd_cdd.status & 0x0f) >> 0;
4448      segacd_cdd_rx[2] = (segacd_cdd.minute & 0xf0) >> 4;
4449      segacd_cdd_rx[3] = (segacd_cdd.minute & 0x0f) >> 0;
4450      segacd_cdd_rx[4] = (segacd_cdd.seconds & 0xf0) >> 4;
4451      segacd_cdd_rx[5] = (segacd_cdd.seconds & 0x0f) >> 0;
4452      segacd_cdd_rx[6] = (segacd_cdd.frame & 0xf0) >> 4;
4453      segacd_cdd_rx[7] = (segacd_cdd.frame & 0x0f) >> 0;
4454      segacd_cdd_rx[8] = (segacd_cdd.ext & 0x0f) >> 0;
4455
4456      /* Do checksum calculation of the above registers */
4457      cdd_crc = 0;
4458      for(i=0;i<9;i++)
4459         cdd_crc += segacd_cdd_rx[i];
4460
4461      segacd_cdd_rx[9] = ((cdd_crc & 0xf) ^ 0xf);
4462
4463      cputag_set_input_line(machine, "segacd_68k", 4, HOLD_LINE);
4464   }
4465}
4466
44284467static READ16_HANDLER( segacd_irq_mask_r )
44294468{
44304469   return segacd_irq_mask;
r9353r9354
44344473{
44354474   segacd_irq_mask = data & 0x7e;
44364475
4437   // check here pending IRQs
4476   cdd_hock_irq(space->machine);
4477   // check here other pending IRQs
44384478}
44394479
44404480static READ16_HANDLER( segacd_cdd_ctrl_r )
44414481{
4442   return segacd_cdd_ctrl;
4482   return segacd_cdd.ctrl;
44434483}
44444484
44454485static WRITE16_HANDLER( segacd_cdd_ctrl_w )
44464486{
4447   segacd_cdd_ctrl = data;
4487   segacd_cdd.ctrl = data;
44484488
4449   if(segacd_cdd_ctrl & 4 && segacd_irq_mask & 0x10) // HOst ClocK
4450   {
4451      // TODO: this shouldn't be instant, CDD should first fill receive data.
4452      segacd_cdd_ctrl &= 0x103; // clear HOCK flag
4453      // export status
4454      cputag_set_input_line(space->machine, "segacd_68k", 4, HOLD_LINE);
4455   }
4489   cdd_hock_irq(space->machine);
44564490}
44574491
44584492/* 68k <- CDD communication comms are 4-bit wide */
44594493static READ8_HANDLER( segacd_cdd_rx_r )
44604494{
4461   return segacd_cdd_recv[offset] & 0xf;
4495   return segacd_cdd_rx[offset] & 0xf;
44624496}
44634497
44644498
r9353r9354
44764510
44774511//   AM_RANGE(0xfe0000, 0xfe3fff) // backup RAM, odd bytes only!
44784512
4479//   AM_RANGE(0xff0000, 0xff7fff) // PCM, RF5C164
4513   AM_RANGE(0xff0000, 0xff7fff) AM_RAM // PCM, RF5C164
44804514   AM_RANGE(0xff8000 ,0xff8001) AM_READWRITE(segacd_sub_led_ready_r, segacd_sub_led_ready_w)
44814515   AM_RANGE(0xff8002 ,0xff8003) AM_READWRITE(segacd_sub_memory_mode_r, segacd_sub_memory_mode_w)
44824516
r9353r9354
44904524   AM_RANGE(0xff8020 ,0xff802f) AM_READWRITE(segacd_comms_sub_part2_r, segacd_comms_sub_part2_w)
44914525//   AM_RANGE(0xff8030, 0xff8031) // Timer W/INT3
44924526   AM_RANGE(0xff8032, 0xff8033) AM_READWRITE(segacd_irq_mask_r,segacd_irq_mask_w)
4493//   AM_RANGE(0xff8034, 0xff8035) // CD Fader
4527   AM_RANGE(0xff8034, 0xff8035) AM_NOP // CD Fader
44944528   AM_RANGE(0xff8036, 0xff8037) AM_READWRITE(segacd_cdd_ctrl_r,segacd_cdd_ctrl_w)
44954529   AM_RANGE(0xff8038, 0xff8041) AM_READ8(segacd_cdd_rx_r,0xffff)
44964530   AM_RANGE(0xff8042, 0xff804b) AM_WRITE8(segacd_cdd_tx_w,0xffff)
r9353r9354
45084542//   AM_RANGE(0xff8068, 0xff8069) // Subcode address
45094543
45104544//   AM_RANGE(0xff8100, 0xff817f) // Subcode buffer area
4511//   AM_RANGE(0xff8180, 0xff81ff) // Image of subcode buffer area
4545//   AM_RANGE(0xff8180, 0xff81ff) // mirror of subcode buffer area
45124546
45134547ADDRESS_MAP_END
45144548

Previous 15994 Revisions Next


© 1998-2018 The MESS Team