Previous 15994 Revisions Next

r10542 Monday 21st February, 2011 at 21:42:49 UTC by Angelo Salese
[MEGACD] Various fixes [David Haywood]:
- Fixed byte priority when doing word writes to comms RAM (fixes Flashback)
- Added PCM DMA (Popful Mail, Flashback + more?)
[src/mame/machine]megadriv.c

src/mame/machine/megadriv.c
r10541r10542
44314431
44324432void CDC_Do_DMA(running_machine* machine, int rate)
44334433{
4434   address_space* space = cputag_get_address_space(machine, "segacd_68k", ADDRESS_SPACE_PROGRAM);
4435
44344436   UINT32 dstoffset, length;
44354437   UINT8 *dest;
44364438   UINT16 destination = CDC_REG0 & 0x0700;
r10541r10542
44544456
44554457
44564458   int dmacount = length;
4457   dstoffset = (CDC_DMA_ADDR & 0xFFFF) << 3;
4459
4460   bool PCM_DMA = false;
4461
4462   if (destination==DMA_PCM)
4463   {
4464      dstoffset = (CDC_DMA_ADDR & 0x03FF) << 2;
4465      PCM_DMA = true;
4466   }
4467   else
4468   {
4469      dstoffset = (CDC_DMA_ADDR & 0xFFFF) << 3;
4470   }
4471
44584472   int srcoffset = 0;
44594473
44604474   while (dmacount--)
r10541r10542
44814495      }
44824496      else if (destination==DMA_PCM)
44834497      {
4484         fatalerror("PCM RAM DMA unimplemented!\n");
4498         dest = 0;//fatalerror("PCM RAM DMA unimplemented!\n");
44854499      }
44864500      else
44874501      {
44884502         fatalerror("Unknown DMA Destination!!\n");
44894503      }
44904504
4491      dest[dstoffset+1] = data >>8;
4492      dest[dstoffset+0] = data&0xff;
4505      if (PCM_DMA)
4506      {
4507         space->write_byte(0xff2000+(((dstoffset*2)+1)&0x1fff),data >> 8);
4508         space->write_byte(0xff2000+(((dstoffset*2)+3)&0x1fff),data & 0xff);
4509      //   printf("PCM_DMA writing %04x %04x\n",0xff2000+(dstoffset*2), data);
4510      }
4511      else
4512      {
4513         if (dest)
4514         {
4515            dest[dstoffset+1] = data >>8;
4516            dest[dstoffset+0] = data&0xff;
4517         }
4518      }
44934519
44944520      srcoffset += 2;
44954521      dstoffset += 2;
44964522   }
44974523
4498   CDC_DMA_ADDR += length >> 2;
4524   if (PCM_DMA)
4525   {
4526      CDC_DMA_ADDR += length >> 1;
4527   }
4528   else
4529   {
4530      CDC_DMA_ADDR += length >> 2;
4531   }
4532
44994533   CDC_DMA_ADDRC += length*2;
45004534
45014535   if (SCD_DMA_ENABLED)
r10541r10542
50395073
50405074static WRITE16_HANDLER( segacd_comms_flags_subcpu_w )
50415075{
5042   if (ACCESSING_BITS_0_7 && ACCESSING_BITS_8_15)
5076   if (ACCESSING_BITS_8_15) // Dragon's Lair
50435077   {
5044      printf("sub cpu attempting to word write data to comms flags %04x!\n",data);
5078      segacd_comms_flags = (segacd_comms_flags & 0xff00) | ((data >> 8) & 0x00ff);
5079      space->machine->scheduler().synchronize();
50455080   }
50465081
5082   // flashback needs low bits to take priority in word writes
50475083   if (ACCESSING_BITS_0_7)
50485084   {
50495085      segacd_comms_flags = (segacd_comms_flags & 0xff00) | (data & 0x00ff);
50505086      space->machine->scheduler().synchronize();
50515087   }
5052
5053   if (ACCESSING_BITS_8_15) // Dragon's Lair
5054   {
5055      segacd_comms_flags = (segacd_comms_flags & 0xff00) | ((data >> 8) & 0x00ff);
5056      space->machine->scheduler().synchronize();
5057   }
50585088}
50595089
50605090static WRITE16_HANDLER( segacd_comms_flags_maincpu_w )
50615091{
5062   if (ACCESSING_BITS_0_7 && ACCESSING_BITS_8_15)
5092   if (ACCESSING_BITS_8_15)
50635093   {
5064      printf("main cpu attempting to word write data to comms flags %04x!\n",data);
5094      segacd_comms_flags = (segacd_comms_flags & 0x00ff) | (data & 0xff00);
5095      space->machine->scheduler().synchronize();
50655096   }
50665097
5098   // flashback needs low bits to take priority in word writes
50675099   if (ACCESSING_BITS_0_7)
50685100   {
50695101      segacd_comms_flags = (segacd_comms_flags & 0x00ff) | ((data << 8) & 0xff00);
50705102      space->machine->scheduler().synchronize();
50715103   }
5072
5073   if (ACCESSING_BITS_8_15)
5074   {
5075      segacd_comms_flags = (segacd_comms_flags & 0x00ff) | (data & 0xff00);
5076      space->machine->scheduler().synchronize();
5077   }
50785104}
50795105
50805106
r10541r10542
63126338      segacd_conversion_active = 1;
63136339
63146340      // todo: proper time calculation
6315      segacd_gfx_conversion_timer->adjust(attotime::from_nsec(5000000));
6341      segacd_gfx_conversion_timer->adjust(attotime::from_nsec(9000));
63166342
63176343
63186344

Previous 15994 Revisions Next


© 1998-2018 The MESS Team