Previous 15994 Revisions Next

r5575 Friday 4th September, 2009 at 05:13:58 UTC by R. Belmont
Changes from MAME SVN necessary for the new SNES code to compile.
[src/mame/machine]snessdd1.c

src/mame/machine/snessdd1.c
r5574r5575
1static UINT8 sdd1_read(running_machine* machine, UINT32 addr);
1static UINT8 sdd1_read(running_machine* machine, UINT16 addr);
22
33typedef struct //Input Manager
44{
r5574r5575
538538static void sdd1_init(running_machine* machine)
539539{
540540   snes_sdd1.sdd1emu = SDD1emu_ctor(machine);
541   snes_sdd1.buffer.data = auto_alloc_array_clear(machine, UINT8, 0x10000);
542541}
543542
544static UINT8 sdd1_mmio_read(const address_space *space, UINT16 addr)
543static UINT8 sdd1_mmio_read(running_machine* machine, UINT16 addr)
545544{
546   UINT8 val = 0xff;
547545   addr &= 0xffff;
548546
549547   switch(addr)
550548   {
551549      case 0x4804:
552         val = (snes_sdd1.mmc[0] >> 20) & 7;
550         return (snes_sdd1.mmc[0] >> 20) & 7;
553551      case 0x4805:
554         val = (snes_sdd1.mmc[1] >> 20) & 7;
552         return (snes_sdd1.mmc[1] >> 20) & 7;
555553      case 0x4806:
556         val = (snes_sdd1.mmc[2] >> 20) & 7;
554         return (snes_sdd1.mmc[2] >> 20) & 7;
557555      case 0x4807:
558         val = (snes_sdd1.mmc[3] >> 20) & 7;
556         return (snes_sdd1.mmc[3] >> 20) & 7;
559557   }
560558
561   printf("SDD1::mmio_read(%04x) = %02x\n", addr, val);
562   return val;
559   return 0xff;
563560}
564561
565static void sdd1_mmio_write(const address_space *space, UINT16 addr, UINT8 data)
562static void sdd1_mmio_write(running_machine* machine, UINT16 addr, UINT8 data)
566563{
567   printf("SDD1::mmio_write(%04x, %02x)\n", addr, data);
568564   addr &= 0xffff;
569565
570566   if((addr & 0x4380) == 0x4300)
r5574r5575
574570      {
575571         case 2:
576572            snes_sdd1.dma[channel].addr = (snes_sdd1.dma[channel].addr & 0xffff00) + (data <<  0);
577            printf( "dma[%d].addr = %06x\n", channel, snes_sdd1.dma[channel].addr );
578573            break;
579574         case 3:
580575            snes_sdd1.dma[channel].addr = (snes_sdd1.dma[channel].addr & 0xff00ff) + (data <<  8);
581            printf( "dma[%d].addr = %06x\n", channel, snes_sdd1.dma[channel].addr );
582576            break;
583577         case 4:
584578            snes_sdd1.dma[channel].addr = (snes_sdd1.dma[channel].addr & 0x00ffff) + (data << 16);
585            printf( "dma[%d].addr = %06x\n", channel, snes_sdd1.dma[channel].addr );
586579            break;
587580
588581         case 5:
589            snes_sdd1.dma[channel].size = (snes_sdd1.dma[channel].size &   0xff00) + (data <<  0);
590            printf( "dma[%d].size = %04x\n", channel, snes_sdd1.dma[channel].size );
582            snes_sdd1.dma[channel].addr = (snes_sdd1.dma[channel].addr &   0xff00) + (data <<  0);
591583            break;
592584         case 6:
593            snes_sdd1.dma[channel].size = (snes_sdd1.dma[channel].size &   0x00ff) + (data <<  8);
594            printf( "dma[%d].size = %04x\n", channel, snes_sdd1.dma[channel].size );
585            snes_sdd1.dma[channel].addr = (snes_sdd1.dma[channel].addr &   0x00ff) + (data <<  8);
595586            break;
596587      }
597      snes_w_io(space, addr & 0x7f, data);
588      snes_ram[addr] = data;
598589      return;
599590   }
600591
r5574r5575
622613   }
623614}
624615
625static UINT8 sdd1_read(running_machine* machine, UINT32 addr)
616static UINT8 sdd1_read(running_machine* machine, UINT16 addr)
626617{
627   printf( "sdd1.read(%06x)\n", addr );
628618   if(snes_sdd1.sdd1_enable & snes_sdd1.xfer_enable)
629619   {
630620      // at least one channel has S-DD1 decompression enabled...
631621      UINT32 i;
632      printf( "    sdd1_enable and xfer_enable are set, let's go\n" );
633622      for(i = 0; i < 8; i++)
634623      {
635624         if(snes_sdd1.sdd1_enable & snes_sdd1.xfer_enable & (1 << i))
636625         {
637            printf( "    channel %d is enabled\n", i );
638626            // S-DD1 always uses fixed transfer mode, so address will not change during transfer
639627            if(addr == snes_sdd1.dma[i].addr)
640628            {
641629               UINT8 data;
642               printf( "    addresses match\n" );
643630               if(!snes_sdd1.buffer.ready)
644631               {
645632                  UINT8 temp;
r5574r5575
652639                  // so temporarily disable decompression mode for decompress() call.
653640                  temp = snes_sdd1.sdd1_enable;
654641                  snes_sdd1.sdd1_enable = 0;
655                  printf( "    buffer is not ready, decompressing %05x bytes at addr %06x\n", snes_sdd1.buffer.size, addr );
656642                  SDD1emu_decompress(snes_sdd1.sdd1emu, addr, snes_sdd1.buffer.size, snes_sdd1.buffer.data);
657643                  snes_sdd1.sdd1_enable = temp;
658644
r5574r5575
661647
662648               // fetch a decompressed byte; once buffer is depleted, disable channel and invalidate buffer
663649               data = snes_sdd1.buffer.data[(UINT16)snes_sdd1.buffer.offset++];
664               printf( "    fetched byte: %02x\n", data );
665650               if(snes_sdd1.buffer.offset >= snes_sdd1.buffer.size)
666651               {
667                  printf( "    we're done\n" );
668652                  snes_sdd1.buffer.ready = 0;
669653                  snes_sdd1.xfer_enable &= ~(1 << i);
670654               }
r5574r5575
675659      } // channel loop
676660   } // S-DD1 decompressor enabled
677661
678   printf( "returning a generic memory read from %06x\n", snes_sdd1.mmc[(addr >> 20) & 3] + (addr & 0x0fffff) );
679662   return memory_read_byte(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), snes_sdd1.mmc[(addr >> 20) & 3] + (addr & 0x0fffff));
680663}
681664
682665static void sdd1_reset(running_machine *machine)
683666{
684   UINT8 i;
685
686   snes_sdd1.sdd1_enable = 0;
687   snes_sdd1.xfer_enable = 0;
688
689   snes_sdd1.mmc[0] = 0 << 20;
690   snes_sdd1.mmc[1] = 1 << 20;
691   snes_sdd1.mmc[2] = 2 << 20;
692   snes_sdd1.mmc[3] = 3 << 20;
693
694   for(i = 0; i < 8; i++)
695   {
696      snes_sdd1.dma[i].addr = 0;
697      snes_sdd1.dma[i].size = 0;
698   }
699
700   snes_sdd1.buffer.ready = 0;
701667}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team