Previous 15994 Revisions Next

r9356 Sunday 10th October, 2010 at 14:49:25 UTC by Angelo Salese
[Mega CD]: More improvements
[src/mame/drivers]megadriv.c

src/mame/drivers/megadriv.c
r9355r9356
43604360      segacd_redled = (data >> 8)&1;
43614361      segacd_greenled = (data >> 9)&1;
43624362
4363      //popmessage("%02x %02x",segacd_greenled,segacd_redled);
4363      popmessage("%02x %02x",segacd_greenled,segacd_redled);
43644364   }
43654365
43664366}
r9355r9356
44354435   }
44364436}
44374437
4438static void cdd_hock_irq(running_machine *machine)
4438static void cdd_hock_irq(running_machine *machine,UINT8 dir)
44394439{
44404440   int i,cdd_crc;
44414441
4442   if(segacd_cdd.ctrl & 4 && segacd_irq_mask & 0x10) // export status, check if bit 2 (HOst ClocK) and irq is enabled
4442   if((segacd_cdd.ctrl & 4 || dir) && segacd_irq_mask & 0x10) // export status, check if bit 2 (HOst ClocK) and irq is enabled
44434443   {
44444444      // TODO: this shouldn't be instant, CDD should first fill receive data.
44454445      segacd_cdd.ctrl &= 0x103; // clear HOCK flag
r9355r9356
44744474{
44754475   segacd_irq_mask = data & 0x7e;
44764476
4477   cdd_hock_irq(space->machine);
4477   cdd_hock_irq(space->machine,0);
44784478   // check here other pending IRQs
44794479}
44804480
r9355r9356
44874487{
44884488   segacd_cdd.ctrl = data;
44894489
4490   cdd_hock_irq(space->machine);
4490   cdd_hock_irq(space->machine,0);
44914491}
44924492
44934493/* 68k <- CDD communication comms are 4-bit wide */
r9355r9356
45144514   "Unknown 0xF"
45154515};
45164516
4517static const char *const segacd_cdd_get_toc_cmd[] =
4518{
4519   "Get Current Position",
4520   "Get Elapsed Time of Current Track",
4521   "Get Current Track",
4522   "Get Total Length",
4523   "Get First and Last Track Number",
4524   "Get Track Addresses",
4525   "Invalid 0x6",
4526   "Invalid 0x7",
4527   "Invalid 0x8",
4528   "Invalid 0x9",
4529   "Invalid 0xA",
4530   "Invalid 0xB",
4531   "Invalid 0xC",
4532   "Invalid 0xD",
4533   "Invalid 0xE",
4534   "Invalid 0xF",
4535};
4536
4537static void segacd_cdd_get_status(running_machine *machine)
4538{
4539   // ...
4540
4541   cdd_hock_irq(machine,1);
4542}
4543
4544static void segacd_cdd_stop_all(running_machine *machine)
4545{
4546   // ...
4547   segacd_cdd.ctrl |= 0x100; // set data bit
4548
4549   //cdd_hock_irq(machine,1); // doesn't work?
4550}
4551
4552
4553static void segacd_cdd_get_toc_info(running_machine *machine)
4554{
4555   segacd_cdd.status = ((segacd_cdd_tx[3] & 0xf) << 4) | (segacd_cdd.status & 0xf);
4556
4557   switch(segacd_cdd_tx[3] & 0xf)
4558   {
4559      default: printf("CDD: unhandled TOC command %s issued\n",segacd_cdd_get_toc_cmd[segacd_cdd_tx[3] & 0xf]);
4560   }
4561
4562   cdd_hock_irq(machine,1);
4563}
4564
45174565static WRITE8_HANDLER( segacd_cdd_tx_w )
45184566{
45194567   //printf("CDD Communication write %02x -> [%02x]\n",data,offset);
45204568   segacd_cdd_tx[offset] = data & 0xf;
45214569
4522   if(offset == 9) //execute the command when crc is sent (TODO: I wonder if we need to check if crc is valid ...)
4570   if(offset == 9) //execute the command when crc is sent (TODO: I wonder if we need to check if crc is valid. Plus obviously this shouldn't be instant)
45234571   {
45244572      switch(segacd_cdd_tx[0] & 0xf)
45254573      {
4574         case 0x0: segacd_cdd_get_status(space->machine); break;
4575         case 0x1: segacd_cdd_stop_all(space->machine); break;
4576         case 0x2: segacd_cdd_get_toc_info(space->machine); break;
45264577         default: printf("CDD: unhandled command %s issued\n",segacd_cdd_cmd[segacd_cdd_tx[0] & 0xf]);
45274578      }
45284579   }
r9355r9356
45354586   AM_RANGE(0x080000, 0x0bffff) AM_READWRITE(segacd_sub_dataram_part1_r, segacd_sub_dataram_part1_w) AM_BASE(&segacd_dataram)
45364587   AM_RANGE(0x0c0000, 0x0dffff) AM_READWRITE(segacd_sub_dataram_part2_r, segacd_sub_dataram_part2_w) AM_BASE(&segacd_dataram2)
45374588
4538//   AM_RANGE(0xfe0000, 0xfe3fff) // backup RAM, odd bytes only!
4589   AM_RANGE(0xfe0000, 0xfe3fff) AM_RAM // backup RAM, odd bytes only!
45394590
45404591   AM_RANGE(0xff0000, 0xff7fff) AM_RAM // PCM, RF5C164
45414592   AM_RANGE(0xff8000 ,0xff8001) AM_READWRITE(segacd_sub_led_ready_r, segacd_sub_led_ready_w)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team