Previous 15994 Revisions Next

r5574 Friday 4th September, 2009 at 04:57:29 UTC by MooglyGuy
Copying [Harmony]'s changes from MAME SVN:
- S-DD1 updates
- SuperFX updates
- SNES machine updates
[src/emu/cpu/superfx]superfx.c
[src/mame/machine]snes.c snessdd1.c
[src/mess]mess.mak
[src/mess/drivers]snes.c
[src/mess/machine]snescart.c

src/mame/machine/snessdd1.c
r5573r5574
1static UINT8 sdd1_read(running_machine* machine, UINT16 addr);
1static UINT8 sdd1_read(running_machine* machine, UINT32 addr);
22
33typedef struct //Input Manager
44{
r5573r5574
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);
541542}
542543
543static UINT8 sdd1_mmio_read(running_machine* machine, UINT16 addr)
544static UINT8 sdd1_mmio_read(const address_space *space, UINT16 addr)
544545{
546   UINT8 val = 0xff;
545547   addr &= 0xffff;
546548
547549   switch(addr)
548550   {
549551      case 0x4804:
550         return (snes_sdd1.mmc[0] >> 20) & 7;
552         val = (snes_sdd1.mmc[0] >> 20) & 7;
551553      case 0x4805:
552         return (snes_sdd1.mmc[1] >> 20) & 7;
554         val = (snes_sdd1.mmc[1] >> 20) & 7;
553555      case 0x4806:
554         return (snes_sdd1.mmc[2] >> 20) & 7;
556         val = (snes_sdd1.mmc[2] >> 20) & 7;
555557      case 0x4807:
556         return (snes_sdd1.mmc[3] >> 20) & 7;
558         val = (snes_sdd1.mmc[3] >> 20) & 7;
557559   }
558560
559   return 0xff;
561   printf("SDD1::mmio_read(%04x) = %02x\n", addr, val);
562   return val;
560563}
561564
562static void sdd1_mmio_write(running_machine* machine, UINT16 addr, UINT8 data)
565static void sdd1_mmio_write(const address_space *space, UINT16 addr, UINT8 data)
563566{
567   printf("SDD1::mmio_write(%04x, %02x)\n", addr, data);
564568   addr &= 0xffff;
565569
566570   if((addr & 0x4380) == 0x4300)
r5573r5574
570574      {
571575         case 2:
572576            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 );
573578            break;
574579         case 3:
575580            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 );
576582            break;
577583         case 4:
578584            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 );
579586            break;
580587
581588         case 5:
582            snes_sdd1.dma[channel].addr = (snes_sdd1.dma[channel].addr &   0xff00) + (data <<  0);
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 );
583591            break;
584592         case 6:
585            snes_sdd1.dma[channel].addr = (snes_sdd1.dma[channel].addr &   0x00ff) + (data <<  8);
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 );
586595            break;
587596      }
588      snes_ram[addr] = data;
597      snes_w_io(space, addr & 0x7f, data);
589598      return;
590599   }
591600
r5573r5574
613622   }
614623}
615624
616static UINT8 sdd1_read(running_machine* machine, UINT16 addr)
625static UINT8 sdd1_read(running_machine* machine, UINT32 addr)
617626{
627   printf( "sdd1.read(%06x)\n", addr );
618628   if(snes_sdd1.sdd1_enable & snes_sdd1.xfer_enable)
619629   {
620630      // at least one channel has S-DD1 decompression enabled...
621631      UINT32 i;
632      printf( "    sdd1_enable and xfer_enable are set, let's go\n" );
622633      for(i = 0; i < 8; i++)
623634      {
624635         if(snes_sdd1.sdd1_enable & snes_sdd1.xfer_enable & (1 << i))
625636         {
637            printf( "    channel %d is enabled\n", i );
626638            // S-DD1 always uses fixed transfer mode, so address will not change during transfer
627639            if(addr == snes_sdd1.dma[i].addr)
628640            {
629641               UINT8 data;
642               printf( "    addresses match\n" );
630643               if(!snes_sdd1.buffer.ready)
631644               {
632645                  UINT8 temp;
r5573r5574
639652                  // so temporarily disable decompression mode for decompress() call.
640653                  temp = snes_sdd1.sdd1_enable;
641654                  snes_sdd1.sdd1_enable = 0;
655                  printf( "    buffer is not ready, decompressing %05x bytes at addr %06x\n", snes_sdd1.buffer.size, addr );
642656                  SDD1emu_decompress(snes_sdd1.sdd1emu, addr, snes_sdd1.buffer.size, snes_sdd1.buffer.data);
643657                  snes_sdd1.sdd1_enable = temp;
644658
r5573r5574
647661
648662               // fetch a decompressed byte; once buffer is depleted, disable channel and invalidate buffer
649663               data = snes_sdd1.buffer.data[(UINT16)snes_sdd1.buffer.offset++];
664               printf( "    fetched byte: %02x\n", data );
650665               if(snes_sdd1.buffer.offset >= snes_sdd1.buffer.size)
651666               {
667                  printf( "    we're done\n" );
652668                  snes_sdd1.buffer.ready = 0;
653669                  snes_sdd1.xfer_enable &= ~(1 << i);
654670               }
r5573r5574
659675      } // channel loop
660676   } // S-DD1 decompressor enabled
661677
678   printf( "returning a generic memory read from %06x\n", snes_sdd1.mmc[(addr >> 20) & 3] + (addr & 0x0fffff) );
662679   return memory_read_byte(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), snes_sdd1.mmc[(addr >> 20) & 3] + (addr & 0x0fffff));
663680}
664681
665682static void sdd1_reset(running_machine *machine)
666683{
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;
667701}
src/mame/machine/snes.c
r5573r5574
13541354         break;
13551355   }
13561356
1357   logerror("Unsupported MMIO write: offset %08x = %02x\n", offset, data);
1358
13591357   snes_ram[offset] = data;
13601358}
13611359
r5573r5574
15201518   UINT8 value;
15211519   UINT16 address = offset & 0xffff;
15221520
1523   if (snes_cart.mode & 5)                     /* Mode 20 & 22 */
1521   if (snes_has_addon_chip == HAS_SUPERFX)
15241522   {
1523      //printf( "snes_r_bank3: %08x\n", offset );
1524      return snes_ram[0x400000 + offset];
1525   }
1526   else if (snes_cart.mode & 5)                     /* Mode 20 & 22 */
1527   {
15251528      if ((address < 0x8000) && (snes_cart.mode == SNES_MODE_20)) //FIXME: check this
15261529         value =  snes_ram[0x200000 + ((offset & ~0x8000) | 0x8000)];                     /* Reserved */
15271530      else
r5573r5574
16691672      snes_w_io(space, address, data);
16701673   else if (address < 0x8000)
16711674   {
1672      if (snes_has_addon_chip == HAS_OBC1)
1675      if (snes_has_addon_chip == HAS_SUPERFX)
1676         snes_ram[0x700000 + (address & 0x1fff)] = data;
1677      else if (snes_has_addon_chip == HAS_OBC1)
16731678         obc1_write(space, offset, data);
16741679      else if ((snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
16751680         DSP2_write(data);
r5573r5574
24782483
24792484WRITE8_HANDLER( superfx_w_bank3 )
24802485{
2486   //printf( "superfx_w_bank3: %08x = %02x\n", 0x600000 + offset, data );
24812487   snes_ram[0x600000 + offset] = data;
24822488}
src/emu/cpu/superfx/superfx.c
r5573r5574
530530
531531   addr &= 0xffff;
532532
533   //printf( "superfx_mmio_write: %08x = %02x\n", addr, data );
534
533535   if(addr >= 0x3100 && addr <= 0x32ff)
534536   {
535537      return superfx_cache_mmio_write(cpustate, addr - 0x3100, data);
r5573r5574
573575         break;
574576
575577      case 0x3033:
576         cpustate->bramr = data;
578         cpustate->bramr = data & 1;
577579         break;
578580
579581      case 0x3034:
580         cpustate->pbr = data;
582         cpustate->pbr = data & 0x7f;
581583         superfx_cache_flush(cpustate);
582584         break;
583585
r5573r5574
591593         break;
592594
593595      case 0x3039:
594         cpustate->clsr = data;
596         cpustate->clsr = data & 1;
595597         superfx_update_speed(cpustate);
596598         break;
597599
r5573r5574
11691171            { // DIV2
11701172               cpustate->sfr &= ~SUPERFX_SFR_CY;
11711173               cpustate->sfr |= (*(cpustate->sreg) & 1) ? SUPERFX_SFR_CY : 0;
1172               superfx_gpr_write(cpustate, cpustate->dreg_idx, ((INT16)(*(cpustate->sreg)) >> 1) + ((*(cpustate->sreg) + 1) >> 16));
1174               superfx_gpr_write(cpustate, cpustate->dreg_idx, ((INT16)(*(cpustate->sreg)) >> 1) + ((UINT32)(*(cpustate->sreg) + 1) >> 16));
11731175               superfx_dreg_sfr_sz_update(cpustate);
11741176               superfx_regs_reset(cpustate);
11751177            }
r5573r5574
11941196            }
11951197            else
11961198            { // LJMP
1197               cpustate->pbr = cpustate->r[op & 0xf];
1199               cpustate->pbr = cpustate->r[op & 0xf] & 0x7f;
11981200               superfx_gpr_write(cpustate, 15, *(cpustate->sreg));
11991201               cpustate->cbr = cpustate->r[15] & 0xfff0;
12001202               superfx_cache_flush(cpustate);
r5573r5574
13191321                  break;
13201322               case SUPERFX_SFR_ALT2: // RAMB
13211323                  superfx_rambuffer_sync(cpustate);
1322                  cpustate->rambr = *(cpustate->sreg);
1324                  cpustate->rambr = ((*(cpustate->sreg)) & 1) ? 1 : 0;
13231325                  superfx_regs_reset(cpustate);
13241326                  break;
13251327               case SUPERFX_SFR_ALT3: // ROMB
13261328                  superfx_rombuffer_sync(cpustate);
1327                  cpustate->rombr = *(cpustate->sreg);
1329                  cpustate->rombr = *(cpustate->sreg) & 0x7f;
13281330                  superfx_regs_reset(cpustate);
13291331                  break;
13301332            }
src/mess/machine/snescart.c
r5573r5574
552552      /* LoROM carts load data in banks 0x00 to 0x7f at address 0x8000 (actually up to 0x7d, because 0x7e and
553553       * 0x7f are overwritten by WRAM). Each block is also mirrored in banks 0x80 to 0xff (up to 0xff for real)
554554       */
555         while (read_blocks < 128 && read_blocks < total_blocks)
555         if((temp_buffer[0x007fd6] >= 0x13 && temp_buffer[0x007fd6] <= 0x15) || temp_buffer[0x007fd6] == 0xa)
556556         {
557            /* Loading data */
558            image_fread(image, &snes_ram[0x8000 + read_blocks * 0x10000], 0x8000);
559            /* Mirroring */
560            memcpy(&snes_ram[0x808000 + (read_blocks * 0x10000)], &snes_ram[0x8000 + (read_blocks * 0x10000)], 0x8000);
561            read_blocks++;
557            while (read_blocks < 64 && read_blocks < total_blocks)
558            {
559               /* Loading data primary: banks 0-3f from 8000-ffff*/
560               image_fread(image, &snes_ram[0x8000 + read_blocks * 0x10000], 0x8000);
561               /* Mirroring at banks 80-bf from 8000-ffff */
562               memcpy(&snes_ram[0x808000 + (read_blocks * 0x10000)], &snes_ram[0x8000 + (read_blocks * 0x10000)], 0x8000);
563               read_blocks++;
564            }
565
566            image_fseek(image, offset, SEEK_SET);
567            /* Loading data secondary, filling full 64k banks from 0x400000 to 600000 */
568            image_fread(image, &snes_ram[0x400000], total_blocks * 0x8000);
569            /* mirror at c00000-e00000 */
570            memcpy( &snes_ram[0xc00000], &snes_ram[0x400000], total_blocks * 0x8000);
562571         }
563         /* Filling banks up to 0x7f and their mirrors */
564         while (read_blocks % 128)
572         else
565573         {
566            int j = 0, repeat_blocks;
567            while ((read_blocks % (128 >> j)) && j < 7)
568               j++;
569            repeat_blocks = read_blocks % (128 >> (j - 1));
574            while (read_blocks < 128 && read_blocks < total_blocks)
575            {
576               /* Loading data */
577               image_fread(image, &snes_ram[0x8000 + read_blocks * 0x10000], 0x8000);
578               /* Mirroring */
579               memcpy(&snes_ram[0x808000 + (read_blocks * 0x10000)], &snes_ram[0x8000 + (read_blocks * 0x10000)], 0x8000);
580               read_blocks++;
581            }
582            /* Filling banks up to 0x7f and their mirrors */
583            while (read_blocks % 128)
584            {
585               int j = 0, repeat_blocks;
586               while ((read_blocks % (128 >> j)) && j < 7)
587                  j++;
588               repeat_blocks = read_blocks % (128 >> (j - 1));
570589
571            memcpy( &snes_ram[read_blocks * 0x10000], &snes_ram[(read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
572            memcpy( &snes_ram[0x800000 + read_blocks * 0x10000], &snes_ram[(read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
573            read_blocks += repeat_blocks;
590               memcpy( &snes_ram[read_blocks * 0x10000], &snes_ram[(read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
591               memcpy( &snes_ram[0x800000 + read_blocks * 0x10000], &snes_ram[(read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
592               read_blocks += repeat_blocks;
593            }
574594         }
575595         break;
576596   }
r5573r5574
757777      logerror( "\tNMI Address:   %2X%2Xh\n", snes_r_bank1(space, 0x00fffb), snes_r_bank1(space, 0x00fffa) );
758778      logerror( "\tStart Address: %2X%2Xh\n\n", snes_r_bank1(space, 0x00fffd), snes_r_bank1(space, 0x00fffc) );
759779
780      logerror( "\tMode: %d\n", snes_cart.mode);
781
760782      if (!supported_type)
761783         logerror("WARNING: This cart type \"%s\" is not supported yet!\n", types[snes_has_addon_chip]);
762784   }
src/mess/mess.mak
r5573r5574
15231523                     $(MESS_LAYOUT)/z80netb.lh \
15241524                     $(MESS_LAYOUT)/z80netf.lh
15251525
1526$(MAME_MACHINE)/snes.o:    $(MAMESRC)/machine/snesdsp1.c \
1527            $(MAMESRC)/machine/snesdsp2.c \
1528            $(MAMESRC)/machine/snesobc1.c \
1529            $(MAMESRC)/machine/snesrtc.c \
1530            $(MAMESRC)/machine/snessdd1.c
1531
15261532#-------------------------------------------------
15271533# MESS-specific tools
15281534#-------------------------------------------------
src/mess/drivers/snes.c
r5573r5574
5555static ADDRESS_MAP_START( superfx_map, ADDRESS_SPACE_PROGRAM, 8)
5656   AM_RANGE(0x000000, 0x3fffff) AM_READWRITE(superfx_r_bank1, superfx_w_bank1)
5757   AM_RANGE(0x400000, 0x5fffff) AM_READWRITE(superfx_r_bank2, superfx_w_bank2)
58   AM_RANGE(0x600000, 0x7fffff) AM_READWRITE(superfx_r_bank3, superfx_w_bank3)
58   AM_RANGE(0x600000, 0x7dffff) AM_READWRITE(superfx_r_bank3, superfx_w_bank3)
5959ADDRESS_MAP_END
6060
6161static READ8_HANDLER( spc_ram_100_r )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team