Previous 15994 Revisions Next

r6153 Wednesday 21st October, 2009 at 08:24:25 UTC by Fabio Priuli
[NES] Improved UNIF support and added emulation of a few UNIF-only boards
[src/mess/includes]nes.h
[src/mess/machine]nes.c nes_ines.c nes_mmc.c nes_unif.c

src/mess/includes/nes.h
r6152r6153
4343   /* load-time cart variables which remain constant */
4444   UINT8 trainer;
4545   UINT8 battery;
46   UINT8 prg_chunks;
47   UINT8 chr_chunks;
46   UINT16 prg_chunks;   // a recently dumped multigame cart has 256 chunks of both PRG & CHR!
47   UINT16 chr_chunks;
4848
4949   UINT8 format;   // 1 = iNES, 2 = UNIF
5050
src/mess/machine/nes.c
r6152r6153
146146         logerror("Mapper %d is not yet supported, defaulting to no mapper.\n",nes.mapper);
147147         mmc_write_low = mmc_write_mid = mmc_write = NULL;
148148         mmc_read_low = NULL;
149//         ppu_latch = NULL;
149         ppu_latch = NULL;
150150      }
151151   }
152152   else if (nes.format == 2)
r6152r6153
339339
340340
341341
342static void nes_read_input_device( running_machine *machine, int cfg, nes_input *vals, int pad_port,
343   int supports_zapper, int paddle_port )
342static void nes_read_input_device( running_machine *machine, int cfg, nes_input *vals, int pad_port, int supports_zapper, int paddle_port )
344343{
345344   static const char *const padnames[] = { "PAD1", "PAD2", "PAD3", "PAD4" };
346345
r6152r6153
457456   int local_options = 0;
458457   char m;
459458   int i;
460   const char *filetype = image_filetype(image);
461459
462   if (!mame_stricmp(filetype, "nes"))
460   /* Check first 4 bytes of the image to decide if it is UNIF or iNES */
461      /* Unfortunately, many .unf files have been released as .nes, so we cannot rely on extensions only */
462   memset(magic, '\0', sizeof(magic));
463   image_fread(image, magic, 4);
464
465   if ((magic[0] == 'N') && (magic[1] == 'E') && (magic[2] == 'S'))   /* If header starts with 'NES' it is iNES */
463466   {
464      nes.format = 1;   // TODO: use this to select between mapper_reset / unif_reset
465      /* Verify the file is in iNES format */
466      memset(magic, '\0', sizeof(magic));
467      image_fread(image, magic, 4);
467      nes.format = 1;   // we use this to select between mapper_reset / unif_reset
468468
469      if ((magic[0] != 'N') || (magic[1] != 'E') || (magic[2] != 'S'))
470      {
471         logerror("%s is NOT a file in iNES format.\n", image_filename(image));
472         return INIT_FAIL;
473      }
474
475469      mapinfo = image_extrainfo(image);
476470
477471      if (mapinfo)
r6152r6153
638632         image_battery_load(image, battery_data, BATTERY_SIZE);
639633
640634   }
641   else if (!mame_stricmp(filetype, "unf"))
635   else if ((magic[0] == 'U') && (magic[1] == 'N') && (magic[2] == 'I') && (magic[3] == 'F')) /* If header starts with 'UNIF' it is UNIF */
642636   {
643637      UINT32 unif_ver = 0;
644638      char magic2[4];
645639      UINT8 buffer[4];
646640      UINT32 chunk_length = 0, read_length = 0x20;
647641      UINT32 prg_start = 0, chr_start = 0;
648      UINT32 prg_left = 0, chr_left = 0;   // used to verify integrity of our unif image
642      int prg_left = 0, chr_left = 0;   // used to verify integrity of our unif image
649643      char unif_mapr[32];   // here we should store MAPR chunks
650644      UINT32 size = image_length(image);
651645      const unif *unif_board;
646      int mapr_chunk_found = 0;
652647
653      nes.format = 2;   // TODO: use this to select between mapper_reset / unif_reset
654      /* Verify the file is in iNES format */
655      memset(magic, '\0', sizeof(magic));
656      image_fread(image, magic, 4);
648      nes.format = 2;   // we use this to select between mapper_reset / unif_reset
657649
658      if ((magic[0] != 'U') || (magic[1] != 'N') || (magic[2] != 'I') || (magic[3] != 'F'))
659      {
660         logerror("%s is NOT a file in UNIF format.\n", image_filename(image));
661         return INIT_FAIL;
662      }
663
664650      image_fread(image, &buffer, 4);
665651      unif_ver = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
666652      logerror("UNIF file found, version %d\n", unif_ver);
r6152r6153
678664         memset(magic2, '\0', sizeof(magic2));
679665         image_fread(image, &magic2, 4);
680666
667#if 0
668// unfortunately, the MAPR chunk is not always the first chunk (see Super 24-in-1)
681669         /* Preliminary checks: the first chunk MUST be MAPR! */
682670         if (read_length == 0x20 && ((magic2[0] != 'M') || (magic2[1] != 'A') || (magic2[2] != 'P') || (magic2[3] != 'R')))
683671            fatalerror("First chunk of data in UNIF should be [MAPR]. Check if your image has been corrupted\n");
r6152r6153
685673         /* Preliminary checks: multiple MAPR chunks are FORBIDDEN! */
686674         if (read_length > 0x20 && ((magic2[0] == 'M') && (magic2[1] == 'A') && (magic2[2] == 'P') && (magic2[3] == 'R')))
687675            fatalerror("UNIF should not have multiple [MAPR] chunks. Check if your image has been corrupted\n");
676#endif
688677
689         /* What kind of chunk do we have here? */
690         if ((magic2[0] == 'M') && (magic2[1] == 'A') && (magic2[2] == 'P') && (magic2[3] == 'R'))
678         /* we first run through the whole image to find a [MAPR] chunk */
679         /* when found, we set mapr_chunk_found=1 and we go back to load other chunks! */
680         if (!mapr_chunk_found)
691681         {
692            logerror("[MAPR] chunk found: ");
693            image_fread(image, &buffer, 4);
694            chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
682            if ((magic2[0] == 'M') && (magic2[1] == 'A') && (magic2[2] == 'P') && (magic2[3] == 'R'))
683            {
684               mapr_chunk_found = 1;
685               logerror("[MAPR] chunk found: ");
686               image_fread(image, &buffer, 4);
687               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
695688
696            if (chunk_length <= 0x20)
697               image_fread(image, &unif_mapr, chunk_length);
689               if (chunk_length <= 0x20)
690                  image_fread(image, &unif_mapr, chunk_length);
698691
699            read_length += (chunk_length + 8);
692               unif_board = nes_unif_lookup(unif_mapr);
693               logerror("%s\n", unif_mapr);
700694
701            unif_board = nes_unif_lookup(unif_mapr);
702            logerror("%s\n", unif_mapr);
695               if (unif_board == NULL)
696               {
697                  fatalerror("Unsupported UNIF board %s.\n", unif_mapr);
698//                            logerror("Unsupported UNIF board %s.\n", unif_mapr);
699               }
703700
704            if (unif_board == NULL)
705            {
706               fatalerror("Unsupported UNIF board.\n");
707//                  logerror("Unsupported UNIF board.\n");
708            }
701               nes.mapper = 0;   // this allows us to set up memory handlers without duplicating code (for the moment)
702               nes.board = unif_board->board;
703               nes.prg_chunks = unif_board->prgrom;
704               nes.chr_chunks = unif_board->chrrom;
705               nes.battery = unif_board->wram;   // we should implement WRAM banks...
706//                  nes.hard_mirroring = unif_board->nt;
707//                      nes.four_screen_vram = ;
709708
710            nes.mapper = 0;   // this allows us to set up memory handlers without duplicating code (for the moment)
711            nes.board = unif_board->board;
712            nes.prg_chunks = unif_board->prgrom;
713            nes.chr_chunks = unif_board->chrrom;
714            nes.battery = unif_board->wram;   // we should implement WRAM banks...
715            nes.hard_mirroring = unif_board->nt;
716//              nes.four_screen_vram = ;
709               /* Free the regions that were allocated by the ROM loader */
710               memory_region_free(image->machine, "maincpu");
711               memory_region_free(image->machine, "gfx1");
717712
718            /* Free the regions that were allocated by the ROM loader */
719            memory_region_free(image->machine, "maincpu");
720            memory_region_free(image->machine, "gfx1");
713               /* Allocate them again with the proper size */
714               memory_region_alloc(image->machine, "maincpu", 0x10000 + (nes.prg_chunks + 1) * 0x4000, 0);
715               if (nes.chr_chunks)
716                  memory_region_alloc(image->machine, "gfx1", nes.chr_chunks * 0x2000, 0);
721717
722            /* Allocate them again with the proper size */
723            memory_region_alloc(image->machine, "maincpu", 0x10000 + (nes.prg_chunks + 1) * 0x4000, 0);
724            if (nes.chr_chunks)
725               memory_region_alloc(image->machine, "gfx1", nes.chr_chunks * 0x2000, 0);
718               nes.rom = memory_region(image->machine, "maincpu");
719               nes.vrom = memory_region(image->machine, "gfx1");
720               nes.vram = memory_region(image->machine, "gfx2");
721               nes.wram = memory_region(image->machine, "user1");
726722
727            nes.rom = memory_region(image->machine, "maincpu");
728            nes.vrom = memory_region(image->machine, "gfx1");
729            nes.vram = memory_region(image->machine, "gfx2");
730            nes.wram = memory_region(image->machine, "user1");
723               /* for validation purposes */
724               prg_left = unif_board->prgrom * 0x4000;
725               chr_left = unif_board->chrrom * 0x2000;
731726
732            /* for validation purposes */
733            prg_left = unif_board->prgrom * 0x4000;
734            chr_left = unif_board->chrrom * 0x2000;
735         }
736         else if ((magic2[0] == 'R') && (magic2[1] == 'E') && (magic2[2] == 'A') && (magic2[3] == 'D'))
737         {
738            logerror("[READ] chunk found. No support yet.\n");
739            image_fread(image, &buffer, 4);
740            chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
727               /* now that we found the MAPR chunk, we can go back to load other chunks */
728               image_fseek(image, 0x20, SEEK_SET);
729               read_length = 0x20;
730            }
731            else
732            {
733               logerror("Skip this chunk. We need a [MAPR] chunk before anything else.\n");
734               image_fread(image, &buffer, 4);
735               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
741736
742            read_length += (chunk_length + 8);
737               read_length += (chunk_length + 8);
738            }
743739         }
744         else if ((magic2[0] == 'N') && (magic2[1] == 'A') && (magic2[2] == 'M') && (magic2[3] == 'E'))
740         else
745741         {
746            logerror("[NAME] chunk found. No support yet.\n");
747            image_fread(image, &buffer, 4);
748            chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
742            /* What kind of chunk do we have here? */
743            if ((magic2[0] == 'M') && (magic2[1] == 'A') && (magic2[2] == 'P') && (magic2[3] == 'R'))
744            {
745               /* The [MAPR] chunk has already been read, so we skip it */
746               /* TO DO: it would be nice to check if more than one MAPR chunk is present */
747               logerror("[MAPR] chunk found (in the 2nd run). Already loaded.\n");
748               image_fread(image, &buffer, 4);
749               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
749750
750            read_length += (chunk_length + 8);
751         }
752         else if ((magic2[0] == 'T') && (magic2[1] == 'V') && (magic2[2] == 'C') && (magic2[3] == 'I'))
753         {
754            logerror("[TVCI] chunk found. No support yet.\n");
755            image_fread(image, &buffer, 4);
756            chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
751               read_length += (chunk_length + 8);
752            }
753            else if ((magic2[0] == 'R') && (magic2[1] == 'E') && (magic2[2] == 'A') && (magic2[3] == 'D'))
754            {
755               logerror("[READ] chunk found. No support yet.\n");
756               image_fread(image, &buffer, 4);
757               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
757758
758            read_length += (chunk_length + 8);
759         }
760         else if ((magic2[0] == 'D') && (magic2[1] == 'I') && (magic2[2] == 'N') && (magic2[3] == 'F'))
761         {
762            logerror("[DINF] chunk found. No support yet.\n");
763            image_fread(image, &buffer, 4);
764            chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
759               read_length += (chunk_length + 8);
760            }
761            else if ((magic2[0] == 'N') && (magic2[1] == 'A') && (magic2[2] == 'M') && (magic2[3] == 'E'))
762            {
763               logerror("[NAME] chunk found. No support yet.\n");
764               image_fread(image, &buffer, 4);
765               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
765766
766            read_length += (chunk_length + 8);
767         }
768         else if ((magic2[0] == 'C') && (magic2[1] == 'T') && (magic2[2] == 'R') && (magic2[3] == 'L'))
769         {
770            logerror("[CTRL] chunk found. No support yet.\n");
771            image_fread(image, &buffer, 4);
772            chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
767               read_length += (chunk_length + 8);
768            }
769            else if ((magic2[0] == 'W') && (magic2[1] == 'R') && (magic2[2] == 'T') && (magic2[3] == 'R'))
770            {
771               logerror("[WRTR] chunk found. No support yet.\n");
772               image_fread(image, &buffer, 4);
773               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
773774
774            read_length += (chunk_length + 8);
775         }
776         else if ((magic2[0] == 'B') && (magic2[1] == 'A') && (magic2[2] == 'T') && (magic2[3] == 'R'))
777         {
778            logerror("[BATR] chunk found. No support yet.\n");
779            image_fread(image, &buffer, 4);
780            chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
775               read_length += (chunk_length + 8);
776            }
777            else if ((magic2[0] == 'T') && (magic2[1] == 'V') && (magic2[2] == 'C') && (magic2[3] == 'I'))
778            {
779               logerror("[TVCI] chunk found. No support yet.\n");
780               image_fread(image, &buffer, 4);
781               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
781782
782            read_length += (chunk_length + 8);
783         }
784         else if ((magic2[0] == 'V') && (magic2[1] == 'R') && (magic2[2] == 'O') && (magic2[3] == 'R'))
785         {
786            logerror("[VROR] chunk found. No support yet.\n");
787            image_fread(image, &buffer, 4);
788            chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
783               read_length += (chunk_length + 8);
784            }
785            else if ((magic2[0] == 'D') && (magic2[1] == 'I') && (magic2[2] == 'N') && (magic2[3] == 'F'))
786            {
787               logerror("[DINF] chunk found. No support yet.\n");
788               image_fread(image, &buffer, 4);
789               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
789790
790            read_length += (chunk_length + 8);
791         }
792         else if ((magic2[0] == 'M') && (magic2[1] == 'I') && (magic2[2] == 'R') && (magic2[3] == 'R'))
793         {
794            logerror("[MIRR] chunk found. No support yet.\n");
795            image_fread(image, &buffer, 4);
796            chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
791               read_length += (chunk_length + 8);
792            }
793            else if ((magic2[0] == 'C') && (magic2[1] == 'T') && (magic2[2] == 'R') && (magic2[3] == 'L'))
794            {
795               logerror("[CTRL] chunk found. No support yet.\n");
796               image_fread(image, &buffer, 4);
797               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
797798
798            read_length += (chunk_length + 8);
799         }
800         else if ((magic2[0] == 'P') && (magic2[1] == 'C') && (magic2[2] == 'K'))
801         {
802            logerror("[PCK%c] chunk found. No support yet.\n", magic2[3]);
803            image_fread(image, &buffer, 4);
804            chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
799               read_length += (chunk_length + 8);
800            }
801            else if ((magic2[0] == 'B') && (magic2[1] == 'A') && (magic2[2] == 'T') && (magic2[3] == 'R'))
802            {
803               logerror("[BATR] chunk found. No support yet.\n");
804               image_fread(image, &buffer, 4);
805               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
805806
806            read_length += (chunk_length + 8);
807         }
808         else if ((magic2[0] == 'C') && (magic2[1] == 'C') && (magic2[2] == 'K'))
809         {
810            logerror("[CCK%c] chunk found. No support yet.\n", magic2[3]);
807               read_length += (chunk_length + 8);
808            }
809            else if ((magic2[0] == 'V') && (magic2[1] == 'R') && (magic2[2] == 'O') && (magic2[3] == 'R'))
810            {
811               logerror("[VROR] chunk found. No support yet.\n");
811812               image_fread(image, &buffer, 4);
812            chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
813               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
813814
814            read_length += (chunk_length + 8);
815         }
816         else if ((magic2[0] == 'P') && (magic2[1] == 'R') && (magic2[2] == 'G'))
817         {
818            logerror("[PRG%c] chunk found. ", magic2[3]);
819            image_fread(image, &buffer, 4);
820            chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
815               read_length += (chunk_length + 8);
816            }
817            else if ((magic2[0] == 'M') && (magic2[1] == 'I') && (magic2[2] == 'R') && (magic2[3] == 'R'))
818            {
819               logerror("[MIRR] chunk found. No support yet.\n");
820               image_fread(image, &buffer, 4);
821               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
821822
822            logerror("It consists of %d 16K-blocks.\n", chunk_length / 0x4000);
823            /* Validation */
824            prg_left -= chunk_length;
825            if (prg_left < 0)
826               fatalerror("PRG chunks larger than expected by board %s!\n", unif_mapr);
823               read_length += (chunk_length + 8);
824            }
825            else if ((magic2[0] == 'P') && (magic2[1] == 'C') && (magic2[2] == 'K'))
826            {
827               logerror("[PCK%c] chunk found. No support yet.\n", magic2[3]);
828               image_fread(image, &buffer, 4);
829               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
827830
828            /* Read in the program chunks */
829            if (nes.prg_chunks == 1)
831               read_length += (chunk_length + 8);
832            }
833            else if ((magic2[0] == 'C') && (magic2[1] == 'C') && (magic2[2] == 'K'))
830834            {
831               image_fread(image, &nes.rom[0x14000], chunk_length);
832               /* Mirror the only bank into $8000 */
833               memcpy(&nes.rom[0x10000], &nes.rom[0x14000], chunk_length);
835               logerror("[CCK%c] chunk found. No support yet.\n", magic2[3]);
836                  image_fread(image, &buffer, 4);
837               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
838
839               read_length += (chunk_length + 8);
834840            }
835            else
836               image_fread(image, &nes.rom[0x10000 + prg_start], chunk_length);
841            else if ((magic2[0] == 'P') && (magic2[1] == 'R') && (magic2[2] == 'G'))
842            {
843               logerror("[PRG%c] chunk found. ", magic2[3]);
844               image_fread(image, &buffer, 4);
845               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
837846
838            prg_start += chunk_length;
839            read_length += (chunk_length + 8);
840         }
841         else if ((magic2[0] == 'C') && (magic2[1] == 'H') && (magic2[2] == 'R'))
842         {
843            logerror("[CHR%c] chunk found. ", magic2[3]);
844            image_fread(image, &buffer, 4);
845            chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
847               logerror("It consists of %d 16K-blocks.\n", chunk_length / 0x4000);
848               /* Validation */
849               prg_left -= chunk_length;
850               if (prg_left < 0)
851                  fatalerror("PRG chunks larger than expected by board %s!\n", unif_mapr);
846852
847            logerror("It consists of %d 8K-blocks.\n", chunk_length / 0x2000);
848            /* validation */
849            chr_left -= chunk_length;
850            if (chr_left < 0)
851               fatalerror("CHR chunks larger than expected by board %s!\n", unif_mapr);
853               /* Read in the program chunks */
854               if (nes.prg_chunks == 1)
855               {
856                  image_fread(image, &nes.rom[0x14000], chunk_length);
857                  /* Mirror the only bank into $8000 */
858                  memcpy(&nes.rom[0x10000], &nes.rom[0x14000], chunk_length);
859               }
860               else
861                  image_fread(image, &nes.rom[0x10000 + prg_start], chunk_length);
852862
853            image_fread(image, nes.vrom + chr_start, chunk_length);
863               prg_start += chunk_length;
864               read_length += (chunk_length + 8);
865            }
866            else if ((magic2[0] == 'C') && (magic2[1] == 'H') && (magic2[2] == 'R'))
867            {
868               logerror("[CHR%c] chunk found. ", magic2[3]);
869               image_fread(image, &buffer, 4);
870               chunk_length = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
854871
855            chr_start += chunk_length;
856            read_length += (chunk_length + 8);
872               logerror("It consists of %d 8K-blocks.\n", chunk_length / 0x2000);
873               /* validation */
874               chr_left -= chunk_length;
875               if (chr_left < 0)
876                  fatalerror("CHR chunks larger than expected by board %s!\n", unif_mapr);
877
878               /* Read in the vrom chunks */
879               image_fread(image, nes.vrom + chr_start, chunk_length);
880
881               chr_start += chunk_length;
882               read_length += (chunk_length + 8);
883            }
884            else
885            {
886               printf("Unsupported UNIF chunk. Please report the problem at MESS Board.\n");
887               read_length = size;
888            }
857889         }
858         else
859         {
860            printf("Unsupported UNIF chunk. Please report the problem at MESS Board.\n");
861            read_length = size;
862         }
863890      } while (size > read_length);
864891
892   if (!mapr_chunk_found )
893      fatalerror("UNIF should have a [MAPR] chunk to work. Check if your image has been corrupted\n");
894
865895   logerror("UNIF support is only very preliminary.\n");
866896   }
897   else
898   {
899      logerror("%s is NOT a file in either iNES or UNIF format.\n", image_filename(image));
900      return INIT_FAIL;
901   }
867902
868903   return INIT_PASS;
869904}
870905
871906
872907
873void nes_partialhash(char *dest, const unsigned char *data,
874   unsigned long length, unsigned int functions)
908void nes_partialhash( char *dest, const unsigned char *data, unsigned long length, unsigned int functions )
875909{
876910   if (length <= 16)
877911      return;
r6152r6153
879913}
880914
881915
882DEVICE_START(nes_disk)
916DEVICE_START( nes_disk )
883917{
884918   /* clear some of the cart variables we don't use */
885919   nes.trainer = 0;
r6152r6153
897931}
898932
899933
900DEVICE_IMAGE_LOAD(nes_disk)
934DEVICE_IMAGE_LOAD( nes_disk )
901935{
902936   unsigned char magic[4];
903937
r6152r6153
927961   return INIT_PASS;
928962}
929963
930DEVICE_IMAGE_UNLOAD(nes_disk)
964DEVICE_IMAGE_UNLOAD( nes_disk )
931965{
932966   /* TODO: should write out changes here as well */
933967   nes_fds.data = NULL;
src/mess/machine/nes_unif.c
r6152r6153
1111
1212****************************************************************************************/
1313
14/*************************************************************
15
16    Board BMC-64IN1NOREPEAT
17
18    Games: 64-in-1 Y2K
19
20    In MESS: Supported
21
22*************************************************************/
23
24static void bmc_64in1nr_set_prg( running_machine *machine )
25{
26   UINT8 helper1 = (bmc_64in1nr_reg[1] & 0x1f);
27   UINT8 helper2 = (helper1 << 1) | ((bmc_64in1nr_reg[1] & 0x40) >> 6);
28
29   if (bmc_64in1nr_reg[0] & 0x80)
30   {
31      if (bmc_64in1nr_reg[1] & 0x80)
32         prg32(machine, helper1);
33      else
34      {
35         prg16_89ab(machine, helper2);
36         prg16_cdef(machine, helper2);
37      }
38   }
39   else
40      prg16_cdef(machine, helper2);
41}
42
43static WRITE8_HANDLER( bmc_64in1nr_l_w )
44{
45   LOG_MMC(("bmc_64in1nr_l_w offset: %04x, data: %02x\n", offset, data));
46   offset += 0x100;
47
48   switch (offset)
49   {
50   case 0x1000:
51   case 0x1001:
52   case 0x1002:
53   case 0x1003:
54      bmc_64in1nr_reg[offset & 0x03] = data;
55      bmc_64in1nr_set_prg(space->machine);
56      chr8(space->machine, ((bmc_64in1nr_reg[0] >> 1) & 0x03) | (bmc_64in1nr_reg[2] << 2), CHRROM);
57      break;
58   }
59   if (offset == 0x1000)   /* reg[0] also sets mirroring */
60      set_nt_mirroring((data & 0x20) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
61}
62
63static WRITE8_HANDLER( bmc_64in1nr_w )
64{
65   LOG_MMC(("bmc_64in1nr_w offset: %04x, data: %02x\n", offset, data));
66
67   bmc_64in1nr_reg[3] = data;   // reg[3] is currently unused?!?
68}
69
70/*************************************************************
71
72    Board BMC-190IN1
73
74    Games: 190-in-1
75
76    In MESS: Supported
77
78*************************************************************/
79
80static WRITE8_HANDLER( bmc_190in1_w )
81{
82   LOG_MMC(("bmc_190in1_w offset: %04x, data: %02x\n", offset, data));
83
84   set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
85   data >>= 2;
86   prg16_89ab(space->machine, data);
87   prg16_cdef(space->machine, data);
88   chr8(space->machine, data, CHRROM);
89}
90
91/*************************************************************
92
93    Board BMC-A65AS
94
95    Games: 3-in-1 (N068)
96
97    In MESS: Supported
98
99*************************************************************/
100
101static WRITE8_HANDLER( bmc_a65as_w )
102{
103   UINT8 helper = (data & 0x30) >> 1;
104   LOG_MMC(("bmc_a65as_w offset: %04x, data: %02x\n", offset, data));
105
106   if (data & 0x80)
107      set_nt_mirroring((data & 0x20) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
108   else
109      set_nt_mirroring((data & 0x08) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
110
111   if (data & 0x40)
112      prg32(space->machine, data >> 1);
113   else
114   {
115      prg16_89ab(space->machine, helper | (data & 0x07));
116      prg16_cdef(space->machine, helper | 0x07);
117   }
118}
119
120/*************************************************************
121
122    Board BMC-GS2004
123
124    Games: Tetris Family 6-in-1
125
126    In MESS: Preliminary Support. It also misses WRAM handling
127       (we need reads from 0x6000-0x7fff)
128
129*************************************************************/
130
131static WRITE8_HANDLER( bmc_gs2004_w )
132{
133   LOG_MMC(("bmc_gs2004_w offset: %04x, data: %02x\n", offset, data));
134
135   prg32(space->machine, data);
136}
137
138/*************************************************************
139
140    Board BMC-GS2013
141
142    Games: Tetris Family 12-in-1
143
144    In MESS: Preliminary Support. It also misses WRAM handling
145       (we need reads from 0x6000-0x7fff)
146
147*************************************************************/
148
149static WRITE8_HANDLER( bmc_gs2013_w )
150{
151   LOG_MMC(("bmc_gs2013_w offset: %04x, data: %02x\n", offset, data));
152
153   if (data & 0x08)
154      prg32(space->machine, data & 0x09);
155   else
156      prg32(space->machine, data & 0x07);
157}
158
159/*************************************************************
160
161    Board BMC-SUPER24IN1SC03
162
163    Games: Super 24-in-1
164
165    In MESS: Supported
166
167*************************************************************/
168
169static void bmc_s24in1sc03_set_prg( running_machine *machine )
170{
171   static const UINT8 masks[8] = {0x3f, 0x1f, 0x0f, 0x01, 0x03, 0x00, 0x00, 0x00};
172   UINT8 prg_flip = (mmc_cmd1 & 0x40) ? 2 : 0;
173   int prg_base = bmc_s24in1sc03_reg[1] << 1;
174   int prg_mask = masks[bmc_s24in1sc03_reg[0] & 0x07];
175
176   prg8_89(machine, prg_base | (prg_bank[0 ^ prg_flip] & prg_mask));
177   prg8_ab(machine, prg_base | (prg_bank[1] & prg_mask));
178   prg8_cd(machine, prg_base | (prg_bank[2 ^ prg_flip] & prg_mask));
179   prg8_ef(machine, prg_base | (prg_bank[3] & prg_mask));
180}
181
182static void bmc_s24in1sc03_set_chr( running_machine *machine )
183{
184   UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5;
185   UINT8 chr = (bmc_s24in1sc03_reg[0] & 0x20) ? CHRRAM : CHRROM;
186   int chr_base = (bmc_s24in1sc03_reg[2] << 3) & 0xf00;
187
188   chr1_x(machine, chr_page ^ 0, chr_base | (vrom_bank[0] & ~0x01), chr);
189   chr1_x(machine, chr_page ^ 1, chr_base | (vrom_bank[0] |  0x01), chr);
190   chr1_x(machine, chr_page ^ 2, chr_base | (vrom_bank[1] & ~0x01), chr);
191   chr1_x(machine, chr_page ^ 3, chr_base | (vrom_bank[1] |  0x01), chr);
192   chr1_x(machine, chr_page ^ 4, chr_base | vrom_bank[2], chr);
193   chr1_x(machine, chr_page ^ 5, chr_base | vrom_bank[3], chr);
194   chr1_x(machine, chr_page ^ 6, chr_base | vrom_bank[4], chr);
195   chr1_x(machine, chr_page ^ 7, chr_base | vrom_bank[5], chr);
196}
197
198static WRITE8_HANDLER( bmc_s24in1sc03_l_w )
199{
200   LOG_MMC(("bmc_s24in1sc03_l_w offset: %04x, data: %02x\n", offset, data));
201   offset += 0x100;
202
203   if (offset == 0x1ff0)
204   {
205      bmc_s24in1sc03_reg[0] = data;
206      bmc_s24in1sc03_set_prg(space->machine);
207      bmc_s24in1sc03_set_chr(space->machine);
208   }
209
210   if (offset == 0x1ff1)
211   {
212      bmc_s24in1sc03_reg[1] = data;
213      bmc_s24in1sc03_set_prg(space->machine);
214   }
215
216   if (offset == 0x1ff2)
217   {
218      bmc_s24in1sc03_reg[2] = data;
219      bmc_s24in1sc03_set_chr(space->machine);
220   }
221}
222
223static WRITE8_HANDLER( bmc_s24in1sc03_w )
224{
225   UINT8 cmd, bmc_s24in1sc03_helper;
226   LOG_MMC(("bmc_s24in1sc03_w offset: %04x, data: %02x\n", offset, data));
227
228   switch (offset & 0x6001)
229   {
230      case 0x0000:
231         bmc_s24in1sc03_helper = mmc_cmd1 ^ data;
232         mmc_cmd1 = data;
233
234         /* Has PRG Mode changed? */
235         if (bmc_s24in1sc03_helper & 0x40)
236            bmc_s24in1sc03_set_prg(space->machine);
237
238         /* Has CHR Mode changed? */
239         if (bmc_s24in1sc03_helper & 0x80)
240            bmc_s24in1sc03_set_chr(space->machine);
241         break;
242
243      case 0x0001:
244         cmd = mmc_cmd1 & 0x07;
245         switch (cmd)
246         {
247            case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
248            case 2: case 3: case 4: case 5:
249               vrom_bank[cmd] = data;
250               bmc_s24in1sc03_set_chr(space->machine);
251               break;
252            case 6:
253            case 7:
254               prg_bank[cmd - 6] = data;
255               bmc_s24in1sc03_set_prg(space->machine);
256               break;
257         }
258         break;
259
260      default:
261         mapper4_w(space, offset, data);
262         break;
263   }
264}
265
266/*************************************************************
267
268    Board BMC-T-262
269
270    Games: 4-in-1 (D-010), 8-in-1 (A-020)
271
272    In MESS: Supported
273
274*************************************************************/
275
276static WRITE8_HANDLER( bmc_t262_w )
277{
278   UINT8 mmc_helper;
279   LOG_MMC(("bmc_t262_w offset: %04x, data: %02x\n", offset, data));
280
281   if (mmc_cmd2 || offset == 0)
282   {
283      mmc_cmd1 = (mmc_cmd1 & 0x38) | (data & 0x07);
284      prg16_89ab(space->machine, mmc_cmd1);
285   }
286   else
287   {
288      mmc_cmd2 = 1;
289      set_nt_mirroring((offset & 0x02) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
290      mmc_helper = ((offset >> 3) & 0x20) | ((offset >> 2) & 0x18);
291      mmc_cmd1 = mmc_helper | (mmc_cmd1 & 0x07);
292      prg16_89ab(space->machine, mmc_cmd1);
293      prg16_cdef(space->machine, mmc_helper | 0x07);
294   }
295}
296
297/*************************************************************
298
299    Board BMC-WS
300
301    Games: Super 40-in-1
302
303    In MESS: Supported
304
305*************************************************************/
306
307static WRITE8_HANDLER( bmc_ws_m_w )
308{
309   UINT8 mmc_helper;
310   LOG_MMC(("bmc_ws_m_w offset: %04x, data: %02x\n", offset, data));
311
312   if (offset < 0x1000)
313   {
314      switch (offset & 0x01)
315      {
316      case 0:
317         if (!mmc_cmd1)
318         {
319            mmc_cmd1 = data & 0x20;
320            set_nt_mirroring((data & 0x10) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
321            mmc_helper = (~data & 0x08) >> 3;
322            prg16_89ab(space->machine, data & ~mmc_helper);
323            prg16_cdef(space->machine, data |  mmc_helper);
324         }
325         break;
326      case 1:
327         if (!mmc_cmd1)
328         {
329            chr8(space->machine, data, CHRROM);
330         }
331         break;
332      }
333   }
334}
335
336/*************************************************************
337
338    Board DREAMTECH01
339
340    Games: Korean Igo
341
342    In MESS: Supported
343
344*************************************************************/
345
346static WRITE8_HANDLER( dreamtech_l_w )
347{
348   LOG_MMC(("dreamtech_l_w offset: %04x, data: %02x\n", offset, data));
349   offset += 0x100;
350
351   if (offset == 0x1020)   /* 0x5020 */
352      prg16_89ab(space->machine, data);
353}
354
355/*************************************************************
356
357    Board UNL-8237
358
359    Games: Pochahontas 2
360
361    MMC3 clone
362
363    In MESS: Not working
364
365*************************************************************/
366
367static void unl_8237_set_prg( running_machine *machine )
368{
369   UINT8 prg_flip = (mmc_cmd1 & 0x40) ? 2 : 0;
370
371   if (!(unl_8237_reg[0] & 0x80))
372   {
373      prg8_89(machine, prg_bank[0 ^ prg_flip]);
374      prg8_ab(machine, prg_bank[1]);
375      prg8_cd(machine, prg_bank[2 ^ prg_flip]);
376      prg8_ef(machine, prg_bank[3]);
377   }
378}
379
380static void unl_8237_set_chr( running_machine *machine )
381{
382   UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5;
383   UINT8 bank[8];
384   int i;
385
386   for(i = 0; i < 6; i++)
387      bank[i] = vrom_bank[i] | ((unl_8237_reg[1] << 6) & 0x100);
388
389   chr1_x(machine, chr_page ^ 0, (bank[0] & ~0x01), CHRROM);
390   chr1_x(machine, chr_page ^ 1, (bank[0] |  0x01), CHRROM);
391   chr1_x(machine, chr_page ^ 2, (bank[1] & ~0x01), CHRROM);
392   chr1_x(machine, chr_page ^ 3, (bank[1] |  0x01), CHRROM);
393   chr1_x(machine, chr_page ^ 4, bank[2], CHRROM);
394   chr1_x(machine, chr_page ^ 5, bank[3], CHRROM);
395   chr1_x(machine, chr_page ^ 6, bank[4], CHRROM);
396   chr1_x(machine, chr_page ^ 7, bank[5], CHRROM);
397}
398
399static WRITE8_HANDLER( unl_8237_l_w )
400{
401   LOG_MMC(("unl_8237_l_w offset: %04x, data: %02x\n", offset, data));
402   offset += 0x100;
403
404   if (offset == 0x1000)
405   {
406      unl_8237_reg[0] = data;
407      if (unl_8237_reg[0] & 0x80)
408      {
409         if (unl_8237_reg[0] & 0x20)
410            prg32(space->machine, (unl_8237_reg[0] & 0x0f) >> 1);
411         else
412         {
413            prg16_89ab(space->machine, unl_8237_reg[0] & 0x1f);
414            prg16_cdef(space->machine, unl_8237_reg[0] & 0x1f);
415         }
416      }
417      else
418         unl_8237_set_prg(space->machine);
419   }
420
421   if (offset == 0x1001)
422   {
423      unl_8237_reg[1] = data;
424      unl_8237_set_chr(space->machine);
425   }
426}
427
428static WRITE8_HANDLER( unl_8237_w )
429{
430   UINT8 unl_8237_helper, cmd;
431   static const UINT8 conv_table[8] = {0,2,6,1,7,3,4,5};
432   LOG_MMC(("unl_8237_w offset: %04x, data: %02x\n", offset, data));
433
434   switch (offset & 0x7000)
435   {
436      case 0x2000:
437      case 0x3000:
438         unl_8237_reg[2] = 1;
439         data = (data & 0xc0) | conv_table[data & 0x07];
440         unl_8237_helper = mmc_cmd1 ^ data;
441         mmc_cmd1 = data;
442
443         /* Has PRG Mode changed? */
444         if (unl_8237_helper & 0x40)
445            unl_8237_set_prg(space->machine);
446
447         /* Has CHR Mode changed? */
448         if (unl_8237_helper & 0x80)
449            unl_8237_set_chr(space->machine);
450         break;
451
452      case 0x4000:
453      case 0x5000:
454         if (unl_8237_reg[2])
455         {
456            unl_8237_reg[2] = 0;
457            cmd = mmc_cmd1 & 0x07;
458            switch (cmd)
459            {
460               case 0: case 1:
461               case 2: case 3: case 4: case 5:
462                  vrom_bank[cmd] = data;
463                  unl_8237_set_chr(space->machine);
464                  break;
465               case 6:
466               case 7:
467                  prg_bank[cmd - 6] = data;
468                  unl_8237_set_prg(space->machine);
469                  break;
470            }
471         }
472         break;
473
474      case 0x0000:
475      case 0x1000:
476         set_nt_mirroring((data | (data >> 7)) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
477         break;
478
479      case 0x6000:
480         break;
481
482      case 0x7000:
483         mapper4_w(space, 0x6001, data);
484         mapper4_w(space, 0x4000, data);
485         mapper4_w(space, 0x4001, data);
486         break;
487   }
488}
489
490/*************************************************************
491
492    Board UNL-AX5705
493
494    Games: Super Mario Bros. Pocker Mali (Crayon Shin-chan pirate hack)
495
496    In MESS: Supported
497
498*************************************************************/
499
500static void unl_ax5705_set_prg( running_machine *machine )
501{
502   prg8_89(machine, prg_bank[0]);
503   prg8_ab(machine, prg_bank[1]);
504}
505
506static WRITE8_HANDLER( unl_ax5705_w )
507{
508   UINT8 bank;
509   LOG_MMC(("unl_ax5705_w offset: %04x, data: %02x\n", offset, data));
510
511   switch (offset & 0x700f)
512   {
513   case 0x0000:
514      prg_bank[0] = (data & 0x05) | ((data & 0x08) >> 2) | ((data & 0x02) << 2);
515      unl_ax5705_set_prg(space->machine);
516      break;
517   case 0x0008:
518      set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
519      break;
520   case 0x2000:
521      prg_bank[1] = (data & 0x05) | ((data & 0x08) >> 2) | ((data & 0x02) << 2);
522      unl_ax5705_set_prg(space->machine);
523      break;
524   /* CHR banks 0, 1, 4, 5 */
525   case 0x2008:
526   case 0x200a:
527   case 0x4008:
528   case 0x400a:
529      bank = ((offset & 0x4000) ? 4 : 0) + ((offset & 0x0002) ? 1 : 0);
530      vrom_bank[bank] = (vrom_bank[bank] & 0xf0) | (data & 0x0f);
531      chr1_x(space->machine, bank, vrom_bank[bank], CHRROM);
532      break;
533   case 0x2009:
534   case 0x200b:
535   case 0x4009:
536   case 0x400b:
537      bank = ((offset & 0x4000) ? 4 : 0) + ((offset & 0x0002) ? 1 : 0);
538      vrom_bank[bank] = (vrom_bank[bank] & 0x0f) | ((data & 0x04) << 3) | ((data & 0x02) << 5) | ((data & 0x09) << 4);
539      chr1_x(space->machine, bank, vrom_bank[bank], CHRROM);
540      break;
541   /* CHR banks 2, 3, 6, 7 */
542   case 0x4000:
543   case 0x4002:
544   case 0x6000:
545   case 0x6002:
546      bank = 2 + ((offset & 0x2000) ? 4 : 0) + ((offset & 0x0002) ? 1 : 0);
547      vrom_bank[bank] = (vrom_bank[bank] & 0xf0) | (data & 0x0f);
548      chr1_x(space->machine, bank, vrom_bank[bank], CHRROM);
549      break;
550   case 0x4001:
551   case 0x4003:
552   case 0x6001:
553   case 0x6003:
554      bank = 2 + ((offset & 0x2000) ? 4 : 0) + ((offset & 0x0002) ? 1 : 0);
555      vrom_bank[bank] = (vrom_bank[bank] & 0x0f) | ((data & 0x04) << 3) | ((data & 0x02) << 5) | ((data & 0x09) << 4);
556      chr1_x(space->machine, bank, vrom_bank[bank], CHRROM);
557      break;
558   }
559}
560
561/*************************************************************
562
563    Board UNL-CC-21
564
565    Games: Mi Hun Che
566
567    In MESS: Supported
568
569*************************************************************/
570
571static WRITE8_HANDLER( unl_cc21_w )
572{
573   LOG_MMC(("unl_cc21_w offset: %04x, data: %02x\n", offset, data));
574
575   set_nt_mirroring((offset & 0x02) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW);
576   chr8(space->machine, (offset & 0x01), CHRROM);
577}
578
579/*************************************************************
580
581    Board UNL-KOF97
582
583    Games: King of Fighters 97 (Rex Soft)
584
585    MMC3 clone
586
587    In MESS: Not working
588
589*************************************************************/
590
591static UINT8 unl_kof97_unscramble( UINT8 data )
592{
593   return ((data >> 1) & 0x01) | ((data >> 4) & 0x02) | ((data << 2) & 0x04) | ((data >> 0) & 0xd8) | ((data << 3) & 0x20);
594}
595
596static WRITE8_HANDLER( unl_kof97_w )
597{
598   LOG_MMC(("unl_kof97_w offset: %04x, data: %02x\n", offset, data));
599
600   /* Addresses 0x9000, 0xa000, 0xd000 & 0xf000 behaves differently than MMC3 */
601   if (offset == 0x1000)
602   {
603      data = unl_kof97_unscramble(data);
604      mapper4_w(space, 0x0001, data);
605   }
606   else if (offset == 0x2000)
607   {
608      data = unl_kof97_unscramble(data);
609      mapper4_w(space, 0x0000, data);
610   }
611   else if (offset == 0x5000)
612   {
613      data = unl_kof97_unscramble(data);
614      mapper4_w(space, 0x4001, data);
615   }
616   else if (offset == 0x7000)
617   {
618      data = unl_kof97_unscramble(data);
619      mapper4_w(space, 0x6001, data);
620   }
621   else      /* Other addresses behaves like MMC3, up to unscrambling data */
622   {
623      switch (offset & 0x6001)
624      {
625      case 0x0000:
626      case 0x0001:
627      case 0x4000:
628      case 0x4001:
629      case 0x6000:
630      case 0x6001:
631      case 0x2000:   /* are these ever called?!? */
632      case 0x2001:
633         data = unl_kof97_unscramble(data);
634         mapper4_w(space, offset, data);
635         break;
636      }
637   }
638}
639
640/*************************************************************
641
642    Board UNL-T-230
643
644    Games: Dragon Ball Z IV (Unl)
645
646    In MESS: Supported
647
648*************************************************************/
649
650static WRITE8_HANDLER( unl_t230_w )
651{
652   LOG_MMC(("unl_t230_w offset: %04x, data: %02x\n", offset, data));
653
654   switch (offset & 0x7007)
655   {
656      case 0x0000:
657         break;
658      case 0x2000:
659         data = (data << 1) & 0x1f;
660         prg8_89(space->machine, data);
661         prg8_ab(space->machine, data | 0x01);
662         break;
663
664      default:
665         konami_vrc2b_w(space, offset, data);
666         break;
667   }
668}
669
670
671/*************************************************************
672
673    Constants
674
675*************************************************************/
676
14677/* CHRRAM sizes */
15678enum
16679{
r6152r6153
44707STD_BNROM, STD_CNROM, STD_CPROM,
45708STD_DEROM, STD_DE1ROM, STD_DRROM,
46709STD_EKROM, STD_ELROM, STD_ETROM, STD_EWROM,
47STD_FJROM, STD_FKROM, STD_GNROM, STD_HKROM,
710STD_FJROM, STD_FKROM, STD_GNROM, STD_HKROM,
48711STD_JLROM, STD_JSROM, STD_MHROM, STD_NTBROM,
49712STD_PEEOROM, STD_PNROM,
50713STD_SAROM, STD_SBROM, STD_SCROM, STD_SEROM,
51714STD_SFROM, STD_SGROM, STD_SHROM, STD_SJROM,
52STD_SKROM, STD_SLROM, STD_SNROM, STD_SOROM,
715STD_SKROM, STD_SLROM, STD_SNROM, STD_SOROM,
53716STD_SUROM, STD_SXROM,
54717STD_TEROM, STD_TBROM, STD_TFROM, STD_TGROM,
55718STD_TKROM, STD_TLROM, STD_TNROM, STD_TR1ROM,
r6152r6153
62725/* AGCI */
63726AGCI_47516, AGCI_50282,
64727/* AVE */
65AVE_MB91, AVE_NINA01, AVE_NINA02, AVE_NINA03,
728AVE_MB91, AVE_NINA01, AVE_NINA02, AVE_NINA03,
66729AVE_NINA06, AVE_NINA07, AVE_74161,
67730/* Bandai */
68731BANDAI_74161, BANDAI_FCG1, BANDAI_FCG2, BANDAI_JUMP2,
r6152r6153
74737CAMERICA_9093, CAMERICA_9096, CAMERICA_9097,
75738/* Color Dreams */
76739COLORDREAMS,
740/* Dreamtech */
741DREAMTECH,
77742/* Irem */
78743IREM_74161, IREM_G101, IREM_G101A, IREM_G101B,
79744IREM_HOLYDIV,
r6152r6153
91756JALECO_JF41,
92757/* Konami */
93758KONAMI_74139,
94KONAMI_VRC1, KONAMI_VRC2, KONAMI_VRC3,
759KONAMI_VRC1, KONAMI_VRC2, KONAMI_VRC3,
95760KONAMI_VRC4, KONAMI_VRC6, KONAMI_VRC7,
96761/* Namcot */
97762NAMCOT_163,
r6152r6153
101766/* Rex Soft */
102767REXSOFT_SL1632,
103768/* Sachen */
104SACHEN_8259A, SACHEN_8259B, SACHEN_8259C,
769SACHEN_8259A, SACHEN_8259B, SACHEN_8259C,
105770SACHEN_8259D, SACHEN_SA0036, SACHEN_SA0037,
106SACHEN_SA0161M, SACHEN_SA72007, SACHEN_SA72008,
771SACHEN_SA0161M, SACHEN_SA72007, SACHEN_SA72008,
107772SACHEN_TCA01, SACHEN_TCU01, SACHEN_TCU02, SACHEN_74LS374,
108773/* Sunsoft */
109774SUNSOFT_1, SUNSOFT_2B, SUNSOFT_3, SUNSOFT_4,
r6152r6153
117782/* TXC */
118783TXC_22211A,
119784/* Multigame Carts */
120BMC_HIK8IN1,
785BMC_64IN1NR, BMC_190IN1, BMC_A65AS, BMC_GS2004, BMC_GS2013,
786BMC_HIK8IN1, BMC_NOVELDIAMOND, BMC_S24IN1SC03, BMC_T262,
787BMC_WS,
121788/* Unlicensed */
122UNL_N625092, UNL_SMB2J
789UNL_8237, UNL_CC21, UNL_AX5705, UNL_KOF97,
790UNL_N625092, UNL_SC127, UNL_SMB2J, UNL_T230
123791};
124792
125793
r6152r6153
157825   { "BANDAI-NROM-128",            NULL, NULL, NULL, NULL, NULL, NULL, NULL,                            2,    1,   0,    0, CHRRAM_0,  NT_X,  STD_NROM},
158826   { "BANDAI-NROM-256",            NULL, NULL, NULL, NULL, NULL, NULL, NULL,                            2,    1,   0,    0, CHRRAM_0,  NT_X,  STD_NROM},
159827   { "BANDAI-PT-554",              NULL, NULL, NULL, mapper3_w, NULL, NULL, NULL,        2,    4,   0,    0, CHRRAM_0,  NT_X,  BANDAI_PT554},
160//    { "BMC-13in1JY110",             }
161//   { "BMC-190IN1",                 [unif only!!]                8,   8,   0,   0,  CHRRAM_0, NT_VERT,  BMC_190IN1},
162//   { "BMC-42IN1RESETSWITCH",       [mapper 60 - unsupported]},
163//   { "BMC-64IN1NOREPEAT",          [unif only!!]               64,  64,   0,   0,  CHRRAM_0, NT_VERT,  BMC_64IN1NR},
164//   { "BMC-70IN1",                  [mapper 236 - unsupported]},
165//   { "BMC-70IN1B",                 [mapper 236 - unsupported]},
166//   { "BMC-8157",                   [unif only!!]               32,   0,   0,   0,  CHRRAM_8, NT_VERT,  BMC_8157},
167//   { "BMC-A65AS",                  [unif only!!]               32,   0,   0,   0,  CHRRAM_8, NT_VERT,  BMC_A65AS},
168//   { "BMC-BS-5",                   [unif only!!]                8,   8,   0,   0,  CHRRAM_0, NT_VERT,  BENSHENG_BS5},
169//   { "BMC-D1038",                  [mapper 60 - unsupported]},
170//   { "BMC-FK23C",                  [unif only!!]               64, 128,   0,   0,  CHRRAM_0, NT_X,  BMC_FK23C},
171//   { "BMC-FK23CA",                 },
172//   { "BMC-GHOSTBUSTERS63IN1",      [unif only!!]              128,   0,   0,   0,  CHRRAM_8, NT_HORZ,  BMC_G63IN1},
173//    { "BMC-GK-192",             }
174//   { "BMC-GS-2004",                [unif only!!]               32,   0,   0,   0,  CHRRAM_8, NT_X,  RCM_GS2004},
175//   { "BMC-GS-2013",                [unif only!!]               32,   0,   0,   0,  CHRRAM_8, NT_X,  RCM_GS2013},
176//   { "BMC-NOVELDIAMOND9999999IN1", [mapper 54 - unsupported]},
177//   { "BMC-SUPER24IN1SC03",         [unif only!!]              256, 256,   8,   0,  CHRRAM_8, NT_X,  BMC_S24IN1},
828//    { "BMC-13in1JY110",             [mentioned in FCEUMM source - we need more info]}
829   { "BMC-190IN1",                 NULL, NULL, NULL, bmc_190in1_w, NULL, NULL, NULL,        8,   8,   0,   0,  CHRRAM_0, NT_VERT,  BMC_190IN1},
830//  { "BMC-42IN1RESETSWITCH",       [mapper 60 - unsupported]},
831   { "BMC-64IN1NOREPEAT",          bmc_64in1nr_l_w, NULL, NULL, bmc_64in1nr_w, NULL, NULL, NULL,        64,  64,   0,   0,  CHRRAM_0, NT_VERT,  BMC_64IN1NR},      //UNIF only!
832//  { "BMC-70IN1",                  [mapper 236 - unsupported]},
833//  { "BMC-70IN1B",                 [mapper 236 - unsupported]},
834//  { "BMC-8157",                   [unif only!!]               32,   0,   0,   0,  CHRRAM_8, NT_VERT,  BMC_8157},
835   { "BMC-A65AS",                  NULL, NULL, NULL, bmc_a65as_w, NULL, NULL, NULL,        32,   0,   0,   0,  CHRRAM_8, NT_VERT,  BMC_A65AS},      //UNIF only!
836//  { "BMC-BS-5",                   [unif only!!]                8,   8,   0,   0,  CHRRAM_0, NT_VERT,  BENSHENG_BS5},
837//  { "BMC-D1038",                  [mapper 60 - unsupported]},
838//  { "BMC-FK23C",                  [unif only!!]               64, 128,   0,   0,  CHRRAM_0, NT_X,  BMC_FK23C},
839//  { "BMC-FK23CA",                 (same as above, but different reg init)},
840//  { "BMC-GHOSTBUSTERS63IN1",      [unif only!!]              128,   0,   0,   0,  CHRRAM_8, NT_HORZ,  BMC_G63IN1},
841//    { "BMC-GK-192",                 [mentioned in FCEUMM source - we need more info]}
842   { "BMC-GS-2004",                NULL, NULL, NULL, bmc_gs2004_w, NULL, NULL, NULL,        32,   0,   0,   0,  CHRRAM_8, NT_X,  BMC_GS2004},      //UNIF only!
843   { "BMC-GS-2013",                NULL, NULL, NULL, bmc_gs2013_w, NULL, NULL, NULL,        32,   0,   0,   0,  CHRRAM_8, NT_X,  BMC_GS2013},      //UNIF only!
844   { "BMC-NOVELDIAMOND9999999IN1", NULL, NULL, NULL, mapper54_w, NULL, NULL, NULL,           8,   8,   0,   0,  CHRRAM_0, NT_X,  BMC_NOVELDIAMOND},
845   { "BMC-SUPER24IN1SC03",         bmc_s24in1sc03_l_w, NULL, NULL, bmc_s24in1sc03_w, NULL, NULL, mapper4_irq,     256, 256,   8,   0,  CHRRAM_8, NT_X,  BMC_S24IN1SC03},
178846   { "BMC-SUPERHIK8IN1",           NULL, NULL, mapper45_m_w, mapper4_w, NULL, NULL, mapper4_irq, 256,  256,   8,    0, CHRRAM_0,  NT_X,  BMC_HIK8IN1},
179//   { "BMC-SUPERVISION16IN1",       [mapper 53 - unsupported]},
180//   { "BMC-T-262",                  [unif only!!]               64,   0,   0,   0,  CHRRAM_8, NT_VERT,  BMC_T262},
181//   { "BMC-WS",                     [unif only!!]                8,   8,   0,   0,  CHRRAM_0, NT_VERT,  BMC_S40IN1},
182//   { "BTL-MARIO1-MALEE2",          [mapper 55 - unsupported]},
847//  { "BMC-SUPERVISION16IN1",       [mapper 53 - unsupported]},
848   { "BMC-T-262",                  NULL, NULL, NULL, bmc_t262_w, NULL, NULL, NULL,        64,   0,   0,   0,  CHRRAM_8, NT_VERT,  BMC_T262},      //UNIF only!
849   { "BMC-WS",                     NULL, NULL, bmc_ws_m_w, NULL, NULL, NULL, NULL,         8,   8,   0,   0,  CHRRAM_0, NT_VERT,  BMC_WS},      //UNIF only!
850//  { "BTL-MARIO1-MALEE2",          [mapper 55 - unsupported]},
183851   { "CAMERICA-ALGN",              NULL, NULL, NULL, mapper71_w, NULL, NULL, NULL,               16,    0,   0,    0, CHRRAM_8,  NT_X,  CAMERICA_ALGN},
184852   { "CAMERICA-ALGQ",              NULL, NULL, mapper232_w, mapper232_w, NULL, NULL, NULL,       16,    0,   0,    0, CHRRAM_8,  NT_X,  CAMERICA_ALGQ},
185853   { "CAMERICA-BF9093",            NULL, NULL, NULL, mapper71_w, NULL, NULL, NULL,               16,    0,   0,    0, CHRRAM_8,  NT_X,  CAMERICA_9093},
r6152r6153
187855   { "CAMERICA-BF9097",            NULL, NULL, NULL, mapper71_w, NULL, NULL, NULL,                8,    0,   0,    0, CHRRAM_8,  NT_Y,  CAMERICA_9097},
188856   { "CAMERICA-GAMEGENIE",         NULL, NULL, NULL, NULL, NULL, NULL, NULL,                            2,    1,   0,    0, CHRRAM_0,  NT_X,  STD_NROM},
189857   { "COLORDREAMS-74*377",         NULL, NULL, NULL, mapper11_w, NULL, NULL, NULL,                8,   16,   0,    0, CHRRAM_0,  NT_X,  COLORDREAMS},
190//   { "DREAMTECH01",                [unif only!!]          16,   0,   0,   0,  CHRRAM_8, NT_X,  DREAMTECH},
858   { "DREAMTECH01",                dreamtech_l_w, NULL, NULL, NULL, NULL, NULL, NULL,            16,    0,   0,   0,  CHRRAM_8, NT_X,  DREAMTECH},      //UNIF only!
191859   { "HVC-AMROM",                  NULL, NULL, NULL, mapper7_w, NULL, NULL, NULL,                 8,    0,   0,    0, CHRRAM_8,  NT_Y,  STD_AMROM},
192860   { "HVC-AN1ROM",                 NULL, NULL, NULL, mapper7_w, NULL, NULL, NULL,                 4,    0,   0,    0, CHRRAM_8,  NT_Y,  STD_AN1ROM},
193861   { "HVC-ANROM",                  NULL, NULL, NULL, mapper7_w, NULL, NULL, NULL,                 8,    0,   0,    0, CHRRAM_8,  NT_Y,  STD_ANROM},
r6152r6153
314982   { "KONAMI-74*139/74",           NULL, NULL, mapper87_m_w, NULL, NULL, NULL, NULL,                   2,    4,   0,    0, CHRRAM_0,  NT_X,  KONAMI_74139},
315983   { "KONAMI-CNROM",               NULL, NULL, NULL, mapper3_w, NULL, NULL, NULL,        2,    4,   0,    0, CHRRAM_0,  NT_X,  STD_CNROM},
316984   { "KONAMI-NROM-128",            NULL, NULL, NULL, NULL, NULL, NULL, NULL,                            2,    1,   0,    0, CHRRAM_0,  NT_X,  STD_NROM},
317//    { "KONAMI-QTAI",             }
985//    { "KONAMI-QTAI",                [mentioned in FCEUMM source - we need more info]}
318986   { "KONAMI-SLROM",               NULL, NULL, NULL, mapper1_w, NULL, NULL, NULL,               16,   16,   0,    0, CHRRAM_0,  NT_HORZ,  STD_SLROM},
319987   { "KONAMI-TLROM",               NULL, NULL, NULL, mapper4_w, NULL, NULL, mapper4_irq,       32,   32,   0,    0, CHRRAM_0,  NT_X,  STD_TLROM},
320988   { "KONAMI-UNROM",               NULL, NULL, NULL, mapper2_w, NULL, NULL, NULL,               8,    0,    0,   0, CHRRAM_8,  NT_X,  STD_UNROM},
321989   { "KONAMI-VRC-1",               NULL, NULL, NULL, mapper75_w, NULL, NULL, NULL,                     8,   16,   0,    0, CHRRAM_0,  NT_VERT,  KONAMI_VRC1},
322990   { "KONAMI-VRC-2",               NULL, NULL, NULL, konami_vrc2a_w, NULL, NULL, NULL,                 8,   32,   0,    0, CHRRAM_0,  NT_VERT,  KONAMI_VRC2},
323   // variant 2b (mapper 23) exists! how to distinguish?!? NULL, NULL, NULL, konami_vrc2b_w, NULL, NULL, konami_irq
991   // variant 2b (mapper 23) exists! how to distinguish?!? NULL, NULL, NULL, konami_vrc2b_w, NULL, NULL, konami_irq
324992   { "KONAMI-VRC-3",               NULL, NULL, NULL, mapper73_w, NULL, NULL, konami_irq,               8,    0,   8,    0, CHRRAM_8,  NT_X,  KONAMI_VRC3},
325993   { "KONAMI-VRC-4",               NULL, NULL, NULL, konami_vrc4_w, NULL, NULL, konami_irq,           16,   32,   0,    0, CHRRAM_0,  NT_VERT,  KONAMI_VRC4},
326994   // exist also variants with 2 & 8 NVWRAM!
327995   { "KONAMI-VRC-6",               NULL, NULL, NULL, konami_vrc6a_w, NULL, NULL, konami_irq,          16,   32,   0,    0, CHRRAM_0,  NT_VERT,  KONAMI_VRC6},
328   // variant 6b (mapper 26) exists! how to distinguish?!? NULL, NULL, NULL, konami_vrc6b_w, NULL, NULL, konami_irq
996   // variant 6b (mapper 26) exists! how to distinguish?!? NULL, NULL, NULL, konami_vrc6b_w, NULL, NULL, konami_irq
329997   // exist also variants with 8 NVWRAM!
330998   { "KONAMI-VRC-7",               NULL, NULL, NULL, konami_vrc7_w, NULL, NULL, konami_irq,           32,   32,   0,    0, CHRRAM_0,  NT_VERT,  KONAMI_VRC7},
331999   // exist also variants with 8 NVWRAM!
3321000   { "MLT-ACTION52",               NULL, NULL, NULL, mapper228_w, NULL, NULL, NULL,                  128,   64,   0,    0, CHRRAM_0,  NT_VERT,  ACTENT_ACT52},
3331001   { "MLT-CALTRON6IN1",            NULL, NULL, mapper41_m_w, mapper41_w, NULL, NULL, NULL,            16,   16,   0,    0, CHRRAM_0,  NT_VERT,  CALTRON_6IN1},
334//   { "MLT-MAXI15",                 [mapper 234 - unsupported]},
1002//  { "MLT-MAXI15",                 [mapper 234 - unsupported]},
3351003   { "NAMCOT-163",                 mapper19_l_w, mapper19_l_r, NULL, mapper19_w, NULL, NULL, namcot_irq,32, 32,   0,    0, CHRRAM_0,  NT_X,  NAMCOT_163},
3361004   // exist also variants with 8 NVWRAM
3371005   { "NAMCOT-3301",                NULL, NULL, NULL, NULL, NULL, NULL, NULL,                            2,    1,   0,    0, CHRRAM_0,  NT_X,  STD_NROM},
r6152r6153
3691037   { "NES-EKROM",                  mapper5_l_w, mapper5_l_r, NULL, mapper5_w, NULL, NULL, mapper5_irq,   32,  64,    8,   0, CHRRAM_0,  NT_X, STD_EKROM},
3701038   { "NES-ELROM",                  mapper5_l_w, mapper5_l_r, NULL, mapper5_w, NULL, NULL, mapper5_irq,   32,  64,    0,   0, CHRRAM_0,  NT_X, STD_ELROM},
3711039   { "NES-ETROM",                  mapper5_l_w, mapper5_l_r, NULL, mapper5_w, NULL, NULL, mapper5_irq,   32,  64,    8,   8, CHRRAM_0,  NT_X, STD_ETROM},
372//   { "NES-EVENT",                  [mapper 105 - unsupported]},
1040//  { "NES-EVENT",                  [mapper 105 - unsupported]},
3731041   { "NES-EWROM",                  mapper5_l_w, mapper5_l_r, NULL, mapper5_w, NULL, NULL, mapper5_irq,   32,  64,   32,   0, CHRRAM_0,  NT_X, STD_EWROM},
3741042   { "NES-FJROM",                  NULL, NULL, NULL, mapper10_w, mapper9_latch, NULL, NULL,             8,   16,    8,    0, CHRRAM_0,  NT_VERT,  STD_FJROM},
3751043   { "NES-FKROM",                  NULL, NULL, NULL, mapper10_w, mapper9_latch, NULL, NULL,            16,   16,    8,    0, CHRRAM_0,  NT_VERT,  STD_FKROM},
r6152r6153
4701138   { "TENGEN-800042",              NULL, NULL, NULL, mapper68_w, NULL, NULL, NULL,                     8,  32,    0,    0, CHRRAM_0,  NT_VERT,  TENGEN_800042},
4711139   { "UNL-22211",                  mapper132_l_w, mapper132_l_r, NULL, mapper132_w, NULL, NULL, NULL,  4,   4,    0,    0, CHRRAM_0,  NT_X,  TXC_22211A},
4721140   // mapper 172 & 173 are variant of this one... no UNIF?
473//   { "UNL-3D-BLOCK",                 }
474//   { "UNL-603-5052",               [mapper 238 - unsupported]},
475//    { "UNL-8157",                  }
476//   { "UNL-8237",                   [unif only!!]              32, 64,   0,   0,  CHRRAM_0, NT_X,  UNL_8237},
477//   { "UNL-A9746",                  [mapper 219 - unsupported]},
478//   { "UNL-AX5705",                 [unif only!!]               8, 32,   0,   0,  CHRRAM_0, NT_X,  UNL_AX5705},
479//   { "UNL-CC-21",                  [unif only!!]               2,  2,   0,   0,  CHRRAM_0, NT_Y,  UNL_CC21},
480//    { "UNL-C-N22M",                  }
481//    { "UNL-DANCE",                  }
482//   { "UNL-EDU2000",                [unif only!!]              64,  0,  32,   0,  CHRRAM_8, NT_Y,  UNL_EDU2K},
483//   { "UNL-H2288",                  [mapper 123 - unsupported]},
484//   { "UNL-KOF97",                  [unif only!!]              32, 32,   0,   0,  CHRRAM_0, NT_X,  UNL_KOF97},
485//   { "UNL-KS7032",                 [mapper 142 - unsupported]},
486//    { "UNL-KS7017",                  }
1141//  { "UNL-3D-BLOCK",               [mentioned in FCEUMM source - we need more info]}
1142//  { "UNL-603-5052",               [mapper 238 - unsupported]},
1143//    { "UNL-8157",                   [mentioned in FCEUMM source - we need more info]}
1144   { "UNL-8237",                   unl_8237_l_w, NULL, NULL, unl_8237_w, NULL, NULL, mapper4_irq,     32, 64,   0,   0,  CHRRAM_0, NT_X,  UNL_8237},
1145//  { "UNL-A9746",                  [mapper 219 - unsupported]},
1146   { "UNL-AX5705",                 NULL, NULL, NULL, unl_ax5705_w, NULL, NULL, NULL,                   8, 32,   0,   0,  CHRRAM_0, NT_X,  UNL_AX5705},
1147   { "UNL-CC-21",                  NULL, NULL, NULL, unl_cc21_w, NULL, NULL, NULL,                     2,  2,   0,   0,  CHRRAM_0, NT_Y,  UNL_CC21},
1148//    { "UNL-C-N22M",                 [mentioned in FCEUMM source - we need more info]}
1149//    { "UNL-DANCE",                  [mentioned in FCEUMM source - we need more info]}
1150//  { "UNL-DRIPGAME",               [by Quietust - we need more info]}
1151//  { "UNL-EDU2000",                [unif only!!]              64,  0,  32,   0,  CHRRAM_8, NT_Y,  UNL_EDU2K},
1152//  { "UNL-H2288",                  [mapper 123 - unsupported]},
1153   { "UNL-KOF97",                  NULL, NULL, NULL, unl_kof97_w, NULL, NULL, mapper4_irq,       32, 32,   0,   0,  CHRRAM_0, NT_X,  UNL_KOF97},
1154//  { "UNL-KS7032",                 [mapper 142 - unsupported]},
1155//    { "UNL-KS7017",                 [mentioned in FCEUMM source - we need more info]}
4871156   { "UNL-N625092",                NULL, NULL, NULL, mapper221_w, NULL, NULL, NULL,                   64,    1,   0,    0, CHRRAM_0,  NT_VERT,  UNL_N625092},
488//   { "UNL-PEC-586",                },
1157//  { "UNL-PEC-586",                [mentioned in FCEUMM source - we need more info]},
4891158   { "UNL-SA-002",                 mapper136_l_w, mapper136_l_r, NULL, NULL, NULL, NULL, NULL,         2,    2,   0,    0, CHRRAM_0,  NT_X,  SACHEN_TCU02},
490//   { "UNL-SA-009",                 },
1159//  { "UNL-SA-009",                 [mentioned in FCEUMM source - we need more info]},
4911160   { "UNL-SA-0036",                NULL, NULL, NULL, mapper149_w, NULL, NULL, NULL,                    2,    2,   0,    0, CHRRAM_0,  NT_X,  SACHEN_SA0036},
4921161   { "UNL-SA-0037",                NULL, NULL, NULL, mapper148_w, NULL, NULL, NULL,                    4,    8,   0,    0, CHRRAM_0,  NT_X,  SACHEN_SA0037},
4931162   { "UNL-SA-016-1M",              mapper79_l_w, NULL, NULL, NULL, NULL, NULL, NULL,                   4,    8,   0,    0, CHRRAM_0,  NT_X,  SACHEN_SA0161M},   // actually this is Mapper 146, but works like 79!
r6152r6153
4961165   { "UNL-SA-NROM",                NULL, mapper143_l_r, NULL, NULL, NULL, NULL, NULL,                  2,    1,   0,    0, CHRRAM_0,  NT_X,  SACHEN_TCA01},
4971166   { "UNL-SACHEN-74LS374N",        mapper150_l_w, mapper150_l_r, mapper150_m_w, NULL, NULL, NULL, NULL,4,   16,   0,    0, CHRRAM_0,  NT_X,  SACHEN_74LS374},
4981167   // mapper 243 variant exists! how to distinguish?!?  mapper243_l_w, NULL, NULL, NULL, NULL, NULL, NULL (also uses NT_VERT!)
499//   { "UNL-SACHEN-74LS374NA",       [is it mapper 243?]},
1168//  { "UNL-SACHEN-74LS374NA",       [is it mapper 243?]},
5001169   { "UNL-SACHEN-8259A",           mapper141_l_w, NULL, mapper141_m_w, NULL, NULL, NULL, NULL,        16,   32,   0,    0, CHRRAM_0,  NT_X,  SACHEN_8259A},
5011170   { "UNL-SACHEN-8259B",           mapper138_l_w, NULL, mapper138_m_w, NULL, NULL, NULL, NULL,        16,   32,   0,    0, CHRRAM_0,  NT_X,  SACHEN_8259B},
5021171   { "UNL-SACHEN-8259C",           mapper139_l_w, NULL, mapper139_m_w, NULL, NULL, NULL, NULL,        16,   32,   0,    0, CHRRAM_0,  NT_X,  SACHEN_8259C},
5031172   { "UNL-SACHEN-8259D",           mapper137_l_w, NULL, mapper137_m_w, NULL, NULL, NULL, NULL,        16,   32,   0,    0, CHRRAM_0,  NT_X,  SACHEN_8259D},
504//   { "UNL-SHERO",                  [unif only!!]               32,  64,   0,   0,  CHRRAM_8, NT_4SCR_2K,  SACHEN_SHERO},
505//    { "UNL-SC-127",                  }
1173//  { "UNL-SHERO",                  [unif only!!]               32,  64,   0,   0,  CHRRAM_8, NT_4SCR_2K,  SACHEN_SHERO},
1174   { "UNL-SC-127",                 NULL, NULL, NULL, mapper35_w, NULL, NULL, mapper35_irq,            32,   64,   8,    0, CHRRAM_0,  NT_X,  UNL_SC127},
5061175   { "UNL-SL1632",                 NULL, NULL, NULL, mapper14_w, NULL, NULL, mapper4_irq,             16,   64,   0,    0, CHRRAM_0,  NT_VERT,  REXSOFT_SL1632},
5071176   { "UNL-SMB2J",                  NULL, NULL, NULL, mapper43_w, NULL, NULL, NULL,                     8,    1,   8,    8, CHRRAM_0,  NT_X,  UNL_SMB2J},
508//   { "UNL-T-230",                  [unif only!!]              16,   0,   0,   0, CHRRAM_8, NT_VERT,  UNL_T230},
1177   { "UNL-T-230",                  NULL, NULL, NULL, unl_t230_w, NULL, NULL, konami_irq,              16,    0,   0,    0, CHRRAM_8, NT_VERT,  UNL_T230},
5091178   { "UNL-TC-U01-1.5M",            mapper147_l_w, NULL, mapper147_m_w, mapper147_w, NULL, NULL, NULL,  8,   16,   0,    0, CHRRAM_0,  NT_X,  SACHEN_TCU01},
510   // mapper 136 variant exists! how to distinguish?!? 
511//   { "UNL-TEK90",                  [mappers 90, 209, 211 - unsupported]},
512//   { "UNL-TF1201",                 [unif only!!]               16,  32,   0,   0,  CHRRAM_0, NT_VERT,  UNL_TF1201},
1179   // mapper 136 variant exists! how to distinguish?!?
1180//  { "UNL-TEK90",                  [mappers 90, 209, 211 - unsupported]},
1181//  { "UNL-TF1201",                 [unif only!!]               16,  32,   0,   0,  CHRRAM_0, NT_VERT,  UNL_TF1201},
5131182   { "VIRGIN-SNROM",               NULL, NULL, NULL, mapper1_w, NULL, NULL, NULL,               16,    0,   8,    0, CHRRAM_8,  NT_HORZ,  STD_SNROM}
5141183};
5151184
src/mess/machine/nes_mmc.c
r6152r6153
9292    * 153 - Famicom Jump II uses a different board (or the same in a very different way)
9393    * 242 - DQ8 has no mirroring (missing graphics is due to other reasons though)
9494
95    Known issues on specific UNIF boards:
96    * BMC-GS2004 is not working
97    * BMC-GS2013 is not working
98    * UNL-8237 is not working
99    * UNL-KOF97 is not working
100
95101    Details to investigate:
96102    * 034 writes to 0x8000-0xffff should not be used for NINA-001 and BNROM, only unlicensed BxROM...
97103    * 144 we ignore writes to 0x8000 while NEStopia does not. is it a problem?
r6152r6153
234240static UINT8 mapper121_reg[3];
235241static UINT8 mapper187_reg[4];
236242static UINT8 map208_reg[5];
243static UINT8 bmc_64in1nr_reg[4];
244static UINT8 unl_8237_reg[3];
245static UINT8 bmc_s24in1sc03_reg[3];
237246
238247
239248static UINT8 extra_bank[16];   // some MMC3 clone have 2 series of PRG/CHR banks...
r6152r6153
742751
743752static int mapper_initialize( running_machine *machine, int mmc_num )
744753{
745   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
746754   int err = 0, i;
747755
748756   switch (mmc_num)
749757   {
750758      case 0:
751759         err = 1; /* No mapper found */
752         prg32(space->machine, 0);
760         prg32(machine, 0);
753761         break;
754762      case 1:
755763      case 155:
r6152r6153
758766         MMC1_regs[0] = 0x0f;
759767         MMC1_regs[1] = MMC1_regs[2] = MMC1_regs[3] = 0;
760768         set_nt_mirroring(PPU_MIRROR_HORZ);
761         MMC1_set_chr(space->machine);
762         MMC1_set_prg(space->machine);
769         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
770         MMC1_set_chr(machine);
771         MMC1_set_prg(machine);
763772         break;
764773      case 2:
765774         /* These games don't switch VROM, but some ROMs incorrectly have CHR chunks */
766775         nes.chr_chunks = 0;
767         prg16_89ab(space->machine, 0);
768         prg16_cdef(space->machine, nes.prg_chunks - 1);
776         prg16_89ab(machine, 0);
777         prg16_cdef(machine, nes.prg_chunks - 1);
769778         break;
770779      case 13:
771         chr4_0(space->machine, 0, CHRRAM);
772         prg32(space->machine, 0);
780         chr4_0(machine, 0, CHRRAM);
781         prg32(machine, 0);
773782         break;
774783      case 3:
775784      case 185:
776         prg32(space->machine, 0);
785         prg32(machine, 0);
777786         break;
778787      case 4:
779788      case 206:
r6152r6153
782791         /* that much is documented for Nintendo Gauntlet boards */
783792         if(nes.four_screen_vram)
784793         {
785            extended_ntram=auto_alloc_array(space->machine, UINT8, 0x2000);
794            extended_ntram=auto_alloc_array(machine, UINT8, 0x2000);
786795            set_nt_page(0, CART_NTRAM, 0, 1);
787796            set_nt_page(1, CART_NTRAM, 1, 1);
788797            set_nt_page(2, CART_NTRAM, 2, 1);
r6152r6153
806815         mmc_prg_base = mmc_chr_base = 0;
807816         mmc_prg_mask = mmc_chr_mask = 0xff;   // these could be init'ed as xxx_chunks-1 and they would work the same
808817         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
809         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
810         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
818         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
819         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
811820         break;
812821      case 5:
813822         /* Can switch 8k prg banks, but they are saved as 16k in size */
r6152r6153
815824         MMC5_vrom_bank_mode = 0;
816825         MMC5_vram_protect = 0;
817826         nes.mid_ram_enable = 0;
818         prg16_89ab(space->machine, nes.prg_chunks - 2);
819         prg16_cdef(space->machine, nes.prg_chunks - 1);
827         prg16_89ab(machine, nes.prg_chunks - 2);
828         prg16_cdef(machine, nes.prg_chunks - 1);
820829         break;
821830      case 6:
822831         mmc_cmd1 = 0;
823832         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
824         prg16_89ab(space->machine, 0);
825         prg16_cdef(space->machine, 7);
833         prg16_89ab(machine, 0);
834         prg16_cdef(machine, 7);
826835         break;
827836      case 7:
828837         /* Bankswitches 32k at a time */
829838         set_nt_mirroring(PPU_MIRROR_LOW);
830         prg16_89ab(space->machine, 0);
831         prg16_cdef(space->machine, nes.prg_chunks - 1);
839         prg16_89ab(machine, 0);
840         prg16_cdef(machine, nes.prg_chunks - 1);
832841         break;
833842      case 8:
834843      case 96:
835         prg32(space->machine, 0);
844         prg32(machine, 0);
836845         break;
837846      case 9:
838847         MMC2_regs[0] = MMC2_regs[2] = 0;
839848         MMC2_regs[1] = MMC2_regs[3] = 0;
840849         mmc_cmd1 = mmc_cmd2 = 0xfe;
841         prg8_89(space->machine, 0);
850         prg8_89(machine, 0);
842851         //ugly hack to deal with iNES header usage of chunk count.
843         prg8_ab(space->machine, (nes.prg_chunks << 1) - 3);
844         prg8_cd(space->machine, (nes.prg_chunks << 1) - 2);
845         prg8_ef(space->machine, (nes.prg_chunks << 1) - 1);
852         prg8_ab(machine, (nes.prg_chunks << 1) - 3);
853         prg8_cd(machine, (nes.prg_chunks << 1) - 2);
854         prg8_ef(machine, (nes.prg_chunks << 1) - 1);
846855         break;
847856      case 10:
848857         /* Reset VROM latches */
849858         MMC2_regs[0] = MMC2_regs[2] = 0;
850859         MMC2_regs[1] = MMC2_regs[3] = 0;
851860         mmc_cmd1 = mmc_cmd2 = 0xfe;
852         prg16_89ab(space->machine, 0);
853         prg16_cdef(space->machine, nes.prg_chunks - 1);
861         prg16_89ab(machine, 0);
862         prg16_cdef(machine, nes.prg_chunks - 1);
854863         break;
855864      case 11:
856865         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;   // NINA-07 has no CHRROM
857         prg32(space->machine, 0);
866         prg32(machine, 0);
858867         break;
859868      case 14:
860869         extra_bank[2] = 0xfe;
r6152r6153
869878         mmc_prg_base = mmc_chr_base = 0;
870879         mmc_prg_mask = mmc_chr_mask = 0xff;
871880         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
872         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
873         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
881         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
882         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
874883         break;
875884      case 15:
876885         set_nt_mirroring(PPU_MIRROR_VERT);
877         prg32(space->machine, 0);
886         prg32(machine, 0);
878887         break;
879888      case 16:
880889      case 17:
r6152r6153
882891      case 157:
883892      case 159:
884893         mmc_cmd1 = 0;
885         prg16_89ab(space->machine, 0);
886         prg16_cdef(space->machine, nes.prg_chunks - 1);
894         prg16_89ab(machine, 0);
895         prg16_cdef(machine, nes.prg_chunks - 1);
887896         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
888897         break;
889898      case 19:
890899         mmc_cmd1 = 0;
891         prg16_89ab(space->machine, 0);
892         prg16_cdef(space->machine, nes.prg_chunks - 1);
900         prg16_89ab(machine, 0);
901         prg16_cdef(machine, nes.prg_chunks - 1);
893902         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
894903         set_nt_mirroring(PPU_MIRROR_VERT);
895904         break;
r6152r6153
922931      case 222:
923932      case 252:
924933         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
925         prg16_89ab(space->machine, 0);
926         prg16_cdef(space->machine, nes.prg_chunks - 1);
934         prg16_89ab(machine, 0);
935         prg16_cdef(machine, nes.prg_chunks - 1);
927936         break;
928937      case 32:
929938         mmc_cmd1 = 0;
930         prg16_89ab(space->machine, 0);
931         prg16_cdef(space->machine, nes.prg_chunks - 1);
939         prg16_89ab(machine, 0);
940         prg16_cdef(machine, nes.prg_chunks - 1);
932941         if (nes.crc_hack)
933942            set_nt_mirroring(PPU_MIRROR_HIGH);  // needed by Major League
934943         break;
935944      case 34:
936         prg32(space->machine, 0);
945         prg32(machine, 0);
937946         break;
947      case 35:
948         prg32(machine, 0xff);
949         break;
938950      case 37:
939951         prg_bank[0] = prg_bank[2] = 0xfe;
940952         prg_bank[1] = prg_bank[3] = 0xff;
r6152r6153
944956         mmc_prg_mask = 0x07;
945957         mmc_chr_mask = 0x7f;
946958         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
947         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
948         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
959         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
960         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
949961         break;
950962      case 40:
951         prg8_67(space->machine, 0xfe);
952         prg8_89(space->machine, 0xfc);
953         prg8_ab(space->machine, 0xfd);
954         prg8_cd(space->machine, 0xfe);
955         prg8_ef(space->machine, 0xff);
963         prg8_67(machine, 0xfe);
964         prg8_89(machine, 0xfc);
965         prg8_ab(machine, 0xfd);
966         prg8_cd(machine, 0xfe);
967         prg8_ef(machine, 0xff);
956968         break;
957969      case 41:
958970         mmc_cmd1 = 0;
959         prg32(space->machine, 0);
971         prg32(machine, 0);
960972         break;
961973      case 42:
962         prg32(space->machine, nes.prg_chunks - 1);
974         prg32(machine, nes.prg_chunks - 1);
963975         break;
964976      case 43:
965         prg32(space->machine, 0);
977         prg32(machine, 0);
966978         memset(nes.wram, 0x2000, 0xff);
967979         break;
968980      case 44:
r6152r6153
976988         mmc_prg_mask = 0x0f;
977989         mmc_chr_mask = 0x7f;
978990         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
979         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
980         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
991         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
992         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
981993         break;
982994      case 45:
983995         prg_bank[0] = prg_bank[2] = 0xfe;
r6152r6153
9901002         mmc_prg_mask = 0x3f;
9911003         mmc_chr_base = 0;
9921004         mmc_chr_mask = 0x7f;
993         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
994         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
995         memory_set_bankptr(space->machine, 5, nes.wram);
1005         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1006         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
1007         memory_set_bankptr(machine, 5, nes.wram);
9961008         break;
9971009      case 46:
998         prg32(space->machine, 0);
999         chr8(space->machine, 0, CHRROM);
1010         prg32(machine, 0);
1011         chr8(machine, 0, CHRROM);
10001012         break;
1013      case 54:
1014         prg32(machine, 0);
1015         chr8(machine, 0, CHRROM);
1016         set_nt_mirroring(PPU_MIRROR_VERT);
1017         break;
10011018      case 50:
1002         prg8_67(space->machine, 0x0f);
1003         prg8_89(space->machine, 0x08);
1004         prg8_ab(space->machine, 0x09);
1005         prg8_cd(space->machine, 0);
1006         prg8_ef(space->machine, 0x0b);
1019         prg8_67(machine, 0x0f);
1020         prg8_89(machine, 0x08);
1021         prg8_ab(machine, 0x09);
1022         prg8_cd(machine, 0);
1023         prg8_ef(machine, 0x0b);
10071024         break;
10081025      case 51:
10091026         mapper51_reg[0] = 0x01;
10101027         mapper51_reg[1] = 0x00;
1011         mapper51_set_banks(space->machine);
1028         mapper51_set_banks(machine);
10121029         break;
10131030      case 52:
10141031         prg_bank[0] = 0xfe;
r6152r6153
10231040         mmc_prg_mask = 0x1f;
10241041         mmc_chr_base = 0;
10251042         mmc_chr_mask = 0xff;
1026         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1027         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
1028         memory_set_bankptr(space->machine, 5, nes.wram);
1043         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1044         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
1045         memory_set_bankptr(machine, 5, nes.wram);
10291046         break;
10301047      case 57:
10311048         mmc_cmd1 = 0x00;
10321049         mmc_cmd2 = 0x00;
1033         prg16_89ab(space->machine, 0);
1034         prg16_cdef(space->machine, 0);
1035         chr8(space->machine, 0, CHRROM);
1050         prg16_89ab(machine, 0);
1051         prg16_cdef(machine, 0);
1052         chr8(machine, 0, CHRROM);
10361053         break;
10371054      case 58:
1038         prg32(space->machine, 0);
1039         chr8(space->machine, 0, CHRROM);
1055         prg32(machine, 0);
1056         chr8(machine, 0, CHRROM);
10401057         break;
10411058      case 61:
10421059      case 62:
10431060      case 86:
1044         prg32(space->machine, 0);
1061         prg32(machine, 0);
10451062         break;
10461063      case 64:
10471064      case 158:
10481065         mmc_cmd1 = 0;
1049         prg16_89ab(space->machine, nes.prg_chunks - 1);
1050         prg16_cdef(space->machine, nes.prg_chunks - 1);
1066         prg16_89ab(machine, nes.prg_chunks - 1);
1067         prg16_cdef(machine, nes.prg_chunks - 1);
10511068         break;
10521069      case 65:
10531070      case 67:
r6152r6153
10551072      case 72:
10561073      case 78:
10571074      case 92:
1058         prg16_89ab(space->machine, 0);
1059         prg16_cdef(space->machine, nes.prg_chunks - 1);
1075         prg16_89ab(machine, 0);
1076         prg16_cdef(machine, nes.prg_chunks - 1);
10601077         break;
10611078      case 68:
10621079         m68_mirror = m0 = m1 = 0;
1063         prg16_89ab(space->machine, 0);
1064         prg16_cdef(space->machine, nes.prg_chunks - 1);
1080         prg16_89ab(machine, 0);
1081         prg16_cdef(machine, nes.prg_chunks - 1);
10651082         break;
10661083      case 70:
1067         prg16_89ab(space->machine, nes.prg_chunks - 2);
1068         prg16_cdef(space->machine, nes.prg_chunks - 1);
1084         prg16_89ab(machine, nes.prg_chunks - 2);
1085         prg16_cdef(machine, nes.prg_chunks - 1);
10691086         break;
10701087      case 71:
10711088         set_nt_mirroring(PPU_MIRROR_HORZ);
1072         prg16_89ab(space->machine, 0);
1073         prg16_cdef(space->machine, nes.prg_chunks - 1);
1089         prg16_89ab(machine, 0);
1090         prg16_cdef(machine, nes.prg_chunks - 1);
10741091         break;
10751092      case 76:
1076         prg8_89(space->machine, 0);
1077         prg8_ab(space->machine, 1);
1093         prg8_89(machine, 0);
1094         prg8_ab(machine, 1);
10781095         //cd is bankable, but this should init all banks just fine.
1079         prg16_cdef(space->machine, nes.prg_chunks - 1);
1080         chr2_0(space->machine, 0, CHRROM);
1081         chr2_2(space->machine, 1, CHRROM);
1082         chr2_4(space->machine, 2, CHRROM);
1083         chr2_6(space->machine, 3, CHRROM);
1096         prg16_cdef(machine, nes.prg_chunks - 1);
1097         chr2_0(machine, 0, CHRROM);
1098         chr2_2(machine, 1, CHRROM);
1099         chr2_4(machine, 2, CHRROM);
1100         chr2_6(machine, 3, CHRROM);
10841101         mmc_cmd1 = 0;
10851102         break;
10861103      case 77:
1087         prg32(space->machine, 0);
1088         chr2_2(space->machine, 0, CHRROM);
1089         chr2_4(space->machine, 1, CHRROM);
1090         chr2_6(space->machine, 2, CHRROM);
1104         prg32(machine, 0);
1105         chr2_2(machine, 0, CHRROM);
1106         chr2_4(machine, 1, CHRROM);
1107         chr2_6(machine, 2, CHRROM);
10911108         break;
10921109      case 79:
10931110      case 146:
10941111         /* Mirroring always horizontal...? */
10951112//          Mirroring = 1;
10961113         set_nt_mirroring(PPU_MIRROR_HORZ);
1097         chr8(space->machine, 0, CHRROM);
1098         prg32(space->machine, 0);
1114         chr8(machine, 0, CHRROM);
1115         prg32(machine, 0);
10991116         break;
11001117      case 228:
1101         chr8(space->machine, 0, CHRROM);
1102         prg32(space->machine, 0);
1118         chr8(machine, 0, CHRROM);
1119         prg32(machine, 0);
11031120         break;
11041121      case 83:
11051122         mapper83_reg[9] = 0x0f;
1106         prg8_cd(space->machine, 0x1e);
1107         prg8_ef(space->machine, 0x1f);
1123         prg8_cd(machine, 0x1e);
1124         prg8_ef(machine, 0x1f);
11081125         break;
11091126      case 88:
1110         prg8_89(space->machine, 0xc);
1111         prg8_ab(space->machine, 0xd);
1112         prg8_cd(space->machine, 0xe);
1113         prg8_ef(space->machine, 0xf);
1127         prg8_89(machine, 0xc);
1128         prg8_ab(machine, 0xd);
1129         prg8_cd(machine, 0xe);
1130         prg8_ef(machine, 0xf);
11141131         break;
11151132      case 89:
1116         prg16_89ab(space->machine, 0);
1117         prg16_cdef(space->machine, nes.prg_chunks - 1);
1133         prg16_89ab(machine, 0);
1134         prg16_cdef(machine, nes.prg_chunks - 1);
11181135         set_nt_mirroring(PPU_MIRROR_LOW);
11191136         break;
11201137      case 91:
11211138         set_nt_mirroring(PPU_MIRROR_VERT);
1122         prg16_89ab(space->machine, nes.prg_chunks - 1);
1123         prg16_cdef(space->machine, nes.prg_chunks - 1);
1139         prg16_89ab(machine, nes.prg_chunks - 1);
1140         prg16_cdef(machine, nes.prg_chunks - 1);
11241141         break;
11251142      case 93:
11261143      case 94:
11271144      case 95:
11281145      case 101:
1129         prg16_89ab(space->machine, 0);
1130         prg16_cdef(space->machine, nes.prg_chunks - 1);
1146         prg16_89ab(machine, 0);
1147         prg16_cdef(machine, nes.prg_chunks - 1);
11311148         break;
11321149      case 97:
1133         prg16_89ab(space->machine, nes.prg_chunks - 1);
1134         prg16_cdef(space->machine, nes.prg_chunks - 1);
1150         prg16_89ab(machine, nes.prg_chunks - 1);
1151         prg16_cdef(machine, nes.prg_chunks - 1);
11351152         break;
11361153      case 112:
11371154         mmc_cmd1 = 0;
1138         prg16_89ab(space->machine, 0);
1139         prg16_cdef(space->machine, nes.prg_chunks - 1);
1155         prg16_89ab(machine, 0);
1156         prg16_cdef(machine, nes.prg_chunks - 1);
11401157         break;
11411158      case 36:
11421159      case 38:
r6152r6153
11531170      case 241:
11541171      case 242:
11551172      case 244:
1156         prg32(space->machine, 0);
1173         prg32(machine, 0);
11571174         break;
11581175      case 104:
1159         prg16_89ab(space->machine, 0x00);
1160         prg16_cdef(space->machine, 0x0f);
1176         prg16_89ab(machine, 0x00);
1177         prg16_cdef(machine, 0x0f);
11611178         break;
11621179      case 106:
1163         prg8_89(space->machine, (nes.prg_chunks << 1) - 1);
1164         prg8_ab(space->machine, 0);
1165         prg8_cd(space->machine, 0);
1166         prg8_ef(space->machine, (nes.prg_chunks << 1) - 1);
1180         prg8_89(machine, (nes.prg_chunks << 1) - 1);
1181         prg8_ab(machine, 0);
1182         prg8_cd(machine, 0);
1183         prg8_ef(machine, (nes.prg_chunks << 1) - 1);
11671184         break;
11681185      case 114:
11691186         map114_reg = map114_reg_enabled = 0;
r6152r6153
11741191         mmc_prg_base = mmc_chr_base = 0;
11751192         mmc_prg_mask = mmc_chr_mask = 0xff;
11761193         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1177         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1178         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
1194         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1195         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
11791196         break;
11801197      case 115:
11811198         mapper115_reg[0] = 0;
r6152r6153
11861203         mmc_prg_base = mmc_chr_base = 0;
11871204         mmc_prg_mask = mmc_chr_mask = 0xff;
11881205         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1189         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1190         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
1206         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1207         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
11911208         break;
11921209      case 121:
11931210         prg_bank[0] = prg_bank[2] = 0xfe;
r6152r6153
11981215         mmc_prg_base = mmc_chr_base = 0;
11991216         mmc_prg_mask = mmc_chr_mask = 0xff;
12001217         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1201         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1202         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
1218         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1219         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
12031220         break;
12041221      case 132:
12051222      case 172:
12061223      case 173:
12071224         txc_reg[0] = txc_reg[1] = txc_reg[2] = txc_reg[3] = 0;
1208         prg32(space->machine, 0);
1225         prg32(machine, 0);
12091226         break;
12101227      case 134:
12111228         prg_bank[0] = prg_bank[2] = 0xfe;
r6152r6153
12161233         mmc_prg_mask = 0x1f;
12171234         mmc_chr_mask = 0xff;
12181235         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1219         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1220         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
1236         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1237         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
12211238         break;
12221239      case 166:
12231240         subor_reg[0] = subor_reg[1] = subor_reg[2] = subor_reg[3] = 0;
1224         prg16_89ab(space->machine, 0);
1225         prg16_cdef(space->machine, 0x07);
1241         prg16_89ab(machine, 0);
1242         prg16_cdef(machine, 0x07);
12261243         break;
12271244      case 167:
12281245         subor_reg[0] = subor_reg[1] = subor_reg[2] = subor_reg[3] = 0;
1229         prg16_89ab(space->machine, 0);
1230         prg16_cdef(space->machine, 0x20);
1246         prg16_89ab(machine, 0);
1247         prg16_cdef(machine, 0x20);
12311248         break;
12321249      case 136:
12331250         mmc_cmd1 = 0;
1234         prg32(space->machine, 0);
1251         prg32(machine, 0);
12351252         break;
12361253      case 137:
12371254         mmc_cmd1 = 0;
1238         prg32(space->machine, 0);
1239         chr8(space->machine, nes.chr_chunks - 1, CHRROM);
1255         prg32(machine, 0);
1256         chr8(machine, nes.chr_chunks - 1, CHRROM);
12401257         set_nt_mirroring(PPU_MIRROR_VERT);
12411258         break;
12421259      case 138:
r6152r6153
12441261      case 141:
12451262         mmc_cmd1 = 0;
12461263         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1247         prg32(space->machine, 0);
1248         chr8(space->machine, 0, mmc_chr_source);
1264         prg32(machine, 0);
1265         chr8(machine, 0, mmc_chr_source);
12491266         set_nt_mirroring(PPU_MIRROR_VERT);
12501267         break;
12511268      case 143:
1252         prg16_89ab(space->machine, 0);
1253         prg16_cdef(space->machine, 1);
1254         chr8(space->machine, 0, CHRROM);
1269         prg16_89ab(machine, 0);
1270         prg16_cdef(machine, 1);
1271         chr8(machine, 0, CHRROM);
12551272         break;
12561273      case 133:
12571274      case 145:
r6152r6153
12591276      case 148:
12601277      case 149:
12611278      case 171:
1262         prg32(space->machine, 0);
1263         chr8(space->machine, 0, CHRROM);
1279         prg32(machine, 0);
1280         chr8(machine, 0, CHRROM);
12641281         break;
12651282      case 150:
12661283         mmc_cmd1 = 0;
1267         prg32(space->machine, 0);
1268         chr8(space->machine, 0, CHRROM);
1284         prg32(machine, 0);
1285         chr8(machine, 0, CHRROM);
12691286         set_nt_mirroring(PPU_MIRROR_VERT);
12701287         break;
12711288      case 152:
1272         prg16_89ab(space->machine, 0);
1273         prg16_cdef(space->machine, nes.prg_chunks - 1);
1274         chr8(space->machine, 0, CHRROM);
1289         prg16_89ab(machine, 0);
1290         prg16_cdef(machine, nes.prg_chunks - 1);
1291         chr8(machine, 0, CHRROM);
12751292         break;
12761293      case 153:
12771294         mmc_cmd1 = 0;
1278         prg16_89ab(space->machine, 0);
1279         prg16_cdef(space->machine, nes.prg_chunks - 1);
1295         prg16_89ab(machine, 0);
1296         prg16_cdef(machine, nes.prg_chunks - 1);
12801297         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
12811298         // Famicom Jump II needs also the following!
12821299         for (i = 0; i < 8; i++)
r6152r6153
12841301
12851302         map153_bank_latch = 0;
12861303         if (nes.crc_hack)
1287            mapper153_set_prg(space->machine);
1304            mapper153_set_prg(machine);
12881305         break;
12891306      case 154:
1290         prg16_89ab(space->machine, nes.prg_chunks - 2);
1291         prg16_cdef(space->machine, nes.prg_chunks - 1);
1307         prg16_89ab(machine, nes.prg_chunks - 2);
1308         prg16_cdef(machine, nes.prg_chunks - 1);
12921309         break;
12931310      case 156:
1294         prg16_89ab(space->machine, nes.prg_chunks - 2);
1295         prg16_cdef(space->machine, nes.prg_chunks - 1);
1311         prg16_89ab(machine, nes.prg_chunks - 2);
1312         prg16_cdef(machine, nes.prg_chunks - 1);
12961313         set_nt_mirroring(PPU_MIRROR_LOW);
12971314         break;
12981315      case 164:
1299         prg32(space->machine, 0xff);
1316         prg32(machine, 0xff);
13001317         nes.mid_ram_enable = 1;
13011318         break;
13021319      case 176:
1303         prg32(space->machine, (nes.prg_chunks - 1) >> 1);
1320         prg32(machine, (nes.prg_chunks - 1) >> 1);
13041321         break;
13051322      case 178:
13061323         mmc_cmd1 = 0;
1307         prg32(space->machine, 0);
1324         prg32(machine, 0);
13081325         break;
13091326      case 180:
1310         prg16_89ab(space->machine, 0);
1311         prg16_cdef(space->machine, 0);
1327         prg16_89ab(machine, 0);
1328         prg16_cdef(machine, 0);
13121329         break;
13131330      case 182:
1314         prg32(space->machine, (nes.prg_chunks - 1) >> 1);
1331         prg32(machine, (nes.prg_chunks - 1) >> 1);
13151332         break;
13161333      case 188:
1317         prg16_89ab(space->machine, 0);
1318         prg16_cdef(space->machine, (nes.prg_chunks - 1) ^ 0x08);
1334         prg16_89ab(machine, 0);
1335         prg16_cdef(machine, (nes.prg_chunks - 1) ^ 0x08);
13191336         break;
13201337      case 187:
13211338         prg_bank[0] = prg_bank[2] = 0xfe;
r6152r6153
13261343         mmc_prg_base = mmc_chr_base = 0;
13271344         mmc_prg_mask = mmc_chr_mask = 0xff;
13281345         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1329         mapper187_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1330         mapper187_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
1346         mapper187_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1347         mapper187_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
13311348         break;
13321349      case 189:
13331350         mmc_cmd1 = 0;
r6152r6153
13351352         mmc_chr_base = 0;
13361353         mmc_chr_mask = 0xff;
13371354         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1338         prg32(space->machine, 0);
1339         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
1355         prg32(machine, 0);
1356         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
13401357         break;
13411358      case 193:
1342         prg32(space->machine, (nes.prg_chunks - 1) >> 1);
1359         prg32(machine, (nes.prg_chunks - 1) >> 1);
13431360         set_nt_mirroring(PPU_MIRROR_VERT);
13441361         break;
13451362      case 197:
r6152r6153
13501367         mmc_prg_base = mmc_chr_base = 0;
13511368         mmc_prg_mask = mmc_chr_mask = 0xff;
13521369         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1353         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1354         mapper197_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
1370         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1371         mapper197_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
13551372         break;
13561373      case 198:
13571374         prg_bank[0] = 0x00;
r6152r6153
13631380         mmc_prg_base = mmc_chr_base = 0;
13641381         mmc_prg_mask = mmc_chr_mask = 0xff;
13651382         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1366         mapper198_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1367         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
1383         mapper198_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1384         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
13681385         break;
13691386      case 199:
13701387         prg_bank[0] = 0x00;
r6152r6153
13761393         mmc_prg_base = mmc_chr_base = 0;
13771394         mmc_prg_mask = mmc_chr_mask = 0xff;
13781395         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1379         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1380         mapper199_set_chr(space->machine, mmc_chr_base, mmc_chr_mask);
1396         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1397         mapper199_set_chr(machine, mmc_chr_base, mmc_chr_mask);
13811398         break;
13821399      case 200:
1383         prg16_89ab(space->machine, nes.prg_chunks - 1);
1384         prg16_cdef(space->machine, nes.prg_chunks - 1);
1400         prg16_89ab(machine, nes.prg_chunks - 1);
1401         prg16_cdef(machine, nes.prg_chunks - 1);
13851402         break;
13861403      case 201:
13871404      case 213:
1388         prg32(space->machine, 0);
1389         chr8(space->machine, 0, CHRROM);
1405         prg32(machine, 0);
1406         chr8(machine, 0, CHRROM);
13901407         break;
13911408      case 202:
13921409      case 203:
13931410      case 204:
13941411      case 214:
1395         prg16_89ab(space->machine, 0);
1396         prg16_cdef(space->machine, 0);
1397         chr8(space->machine, 0, CHRROM);
1412         prg16_89ab(machine, 0);
1413         prg16_cdef(machine, 0);
1414         chr8(machine, 0, CHRROM);
13981415         break;
13991416      case 205:
14001417         prg_bank[0] = prg_bank[2] = 0xfe;
r6152r6153
14061423         mmc_chr_base = 0;
14071424         mmc_chr_mask = 0xff;
14081425         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1409         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1410         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
1426         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1427         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
14111428         break;
14121429      case 208:
14131430         prg_bank[0] = prg_bank[2] = 0xfe;
r6152r6153
14181435         mmc_prg_base = mmc_chr_base = 0;
14191436         mmc_prg_mask = mmc_chr_mask = 0xff;
14201437         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1421         mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1422         mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
1438         mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1439         mapper4_set_chr(machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask);
14231440         break;
14241441      case 212:
1425         chr8(space->machine, 0xff, CHRROM);
1426         prg32(space->machine, 0xff);
1442         chr8(machine, 0xff, CHRROM);
1443         prg32(machine, 0xff);
14271444         break;
14281445      case 215:
14291446         prg_bank[0] = 0x00;
r6152r6153
14391456         mmc_prg_base = 0;
14401457         mmc_prg_mask = 0x1f;
14411458         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1442         mapper215_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1443         mapper215_set_chr(space->machine, mmc_chr_source);
1459         mapper215_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1460         mapper215_set_chr(machine, mmc_chr_source);
14441461         break;
14451462      case 216:
14461463         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1447         prg32(space->machine, 0);
1448         chr8(space->machine, 0, mmc_chr_source);
1464         prg32(machine, 0);
1465         chr8(machine, 0, mmc_chr_source);
14491466         break;
14501467      case 217:
14511468         map217_reg[0] = 0x00;
r6152r6153
14591476         mmc_prg_base = mmc_chr_base = 0;
14601477         mmc_prg_mask = mmc_chr_mask = 0xff;
14611478         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1462         mapper217_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1463         mapper217_set_chr(space->machine, mmc_chr_source);
1479         mapper217_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1480         mapper217_set_chr(machine, mmc_chr_source);
14641481         break;
14651482      case 221:
14661483         mmc_cmd1 = 0;
14671484         mmc_cmd2 = 0;
1468         prg16_89ab(space->machine, 0);
1469         prg16_cdef(space->machine, 0);
1485         prg16_89ab(machine, 0);
1486         prg16_cdef(machine, 0);
14701487         break;
14711488      case 225:
1472         prg32(space->machine, 0);
1489         prg32(machine, 0);
14731490         break;
14741491      case 226:
14751492         mmc_cmd1 = 0;
14761493         mmc_cmd2 = 0;
1477         prg32(space->machine, 0);
1494         prg32(machine, 0);
14781495         break;
14791496      case 227:
1480         prg16_89ab(space->machine, 0);
1481         prg16_cdef(space->machine, 0);
1497         prg16_89ab(machine, 0);
1498         prg16_cdef(machine, 0);
14821499         break;
14831500      case 229:
14841501      case 255:
1485         prg16_89ab(space->machine, 0);
1486         prg16_cdef(space->machine, 1);
1487         chr8(space->machine, 0, CHRROM);
1502         prg16_89ab(machine, 0);
1503         prg16_cdef(machine, 1);
1504         chr8(machine, 0, CHRROM);
14881505         set_nt_mirroring(PPU_MIRROR_VERT);
14891506         break;
14901507      case 230:
1491         prg16_89ab(space->machine, 0);
1492         prg16_cdef(space->machine, 7);
1508         prg16_89ab(machine, 0);
1509         prg16_cdef(machine, 7);
14931510         break;
14941511      case 231:
1495         prg16_89ab(space->machine, 0);
1496         prg16_cdef(space->machine, nes.prg_chunks - 1);
1512         prg16_89ab(machine, 0);
1513         prg16_cdef(machine, nes.prg_chunks - 1);
14971514         set_nt_mirroring(PPU_MIRROR_VERT);
14981515         break;
14991516      case 232:
15001517         mmc_cmd1 = 0x18;
15011518         mmc_cmd2 = 0x00;
1502         mapper232_set_prg(space->machine);
1519         mapper232_set_prg(machine);
15031520         break;
15041521      case 243:
15051522         vrom_bank[0] = 3;
15061523         mmc_cmd1 = 0;
1507         chr8(space->machine, 3, CHRROM);
1508         prg32(space->machine, 0);
1524         chr8(machine, 3, CHRROM);
1525         prg32(machine, 0);
15091526         set_nt_mirroring(PPU_MIRROR_VERT);
15101527         break;
15111528      case 246:
1512         prg32(space->machine, 0xff);
1529         prg32(machine, 0xff);
15131530         break;
15141531      case 249:
15151532         prg_bank[0] = prg_bank[2] = 0xfe;
r6152r6153
15201537         mmc_prg_base = mmc_chr_base = 0;
15211538         mmc_prg_mask = mmc_chr_mask = 0xff;
15221539         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1523         mapper249_set_prg(space->machine, mmc_prg_base, mmc_prg_mask);
1524         mapper249_set_chr(space->machine, mmc_chr_base, mmc_chr_mask);
1540         mapper249_set_prg(machine, mmc_prg_base, mmc_prg_mask);
1541         mapper249_set_chr(machine, mmc_chr_base, mmc_chr_mask);
15251542         break;
15261543      default:
15271544         /* Mapper not supported */
r6152r6153
15481565
15491566int mapper_reset( running_machine *machine, int mmc_num )
15501567{
1551   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
15521568   nes_state *state = machine->driver_data;
15531569   int err = 0, i;
15541570   const mmc *mapper;
r6152r6153
15781594
15791595   /* Point the WRAM/battery area to the first RAM bank */
15801596   if (mmc_num != 20)
1581      memory_set_bankptr(space->machine, 5, &nes.wram[0x0000]);
1597      memory_set_bankptr(machine, 5, &nes.wram[0x0000]);
15821598
15831599   /* Here, we init a few helpers: 4 prg banks and 16 chr banks - some mappers use them */
15841600   for (i = 0; i < 4; i++)
r6152r6153
16101626// WIP code
16111627int unif_reset( running_machine *machine, const char *board )
16121628{
1613   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
16141629   nes_state *state = machine->driver_data;
16151630   int err = 0;
16161631   const unif *unif_board;
r6152r6153
16331648      nes_irq_timer = timer_alloc(machine, nes_irq_callback, NULL);
16341649
16351650   /* Point the WRAM/battery area to the first RAM bank */
1636   memory_set_bankptr(space->machine, 5, &nes.wram[0x0000]);
1651   memory_set_bankptr(machine, 5, &nes.wram[0x0000]);
16371652
16381653   switch (unif_board->board_idx)
16391654   {
1655      case BMC_64IN1NR:
1656         bmc_64in1nr_reg[0] = 0x80;
1657         bmc_64in1nr_reg[1] = 0x43;
1658         bmc_64in1nr_reg[2] = bmc_64in1nr_reg[3] = 0;
1659         bmc_64in1nr_set_prg(machine);
1660         set_nt_mirroring(PPU_MIRROR_VERT);
1661         chr8(machine, 0, CHRROM);
1662         break;
1663      case BMC_190IN1:
1664         prg16_89ab(machine, 0);
1665         prg16_cdef(machine, 0);
1666         chr8(machine, 0, CHRROM);
1667         break;
1668      case BMC_A65AS:
1669         prg16_89ab(machine, 0);
1670         prg16_cdef(machine, 7);
1671         set_nt_mirroring(PPU_MIRROR_VERT);
1672         break;
1673      case BMC_GS2004:
1674      case BMC_GS2013:
1675         prg32(machine, 0xff);
1676         chr8(machine, 0, CHRRAM);
1677         break;
1678      case BMC_S24IN1SC03:
1679         bmc_s24in1sc03_reg[0] = 0x24;
1680         bmc_s24in1sc03_reg[1] = 0x9f;
1681         bmc_s24in1sc03_reg[2] = 0;
1682         prg_bank[0] = 0xfe;
1683         prg_bank[1] = 0xff;
1684         prg_bank[2] = 0xfe;
1685         prg_bank[3] = 0xff;
1686         mmc_cmd1 = 0;
1687         mmc_cmd2 = 0x80;
1688         bmc_s24in1sc03_set_prg(machine);
1689         bmc_s24in1sc03_set_chr(machine);
1690         break;
1691      case BMC_T262:
1692         mmc_cmd1 = 0;
1693         mmc_cmd2 = 0;
1694         prg16_89ab(machine, 0);
1695         prg16_cdef(machine, 7);
1696         break;
1697      case BMC_WS:
1698         mmc_cmd1 = 0;
1699         prg32(machine, 0);
1700         break;
1701      case DREAMTECH:
1702         prg16_89ab(machine, 0);
1703         prg16_cdef(machine, 8);
1704         chr8(machine, 0, CHRRAM);
1705         break;
1706      case UNL_8237:
1707         unl_8237_reg[0] = unl_8237_reg[1] = unl_8237_reg[2] = 0;
1708         prg_bank[0] = 0x00;
1709         prg_bank[1] = 0x01;
1710         prg_bank[2] = 0xfe;
1711         prg_bank[3] = 0xff;
1712         mmc_cmd1 = 0;
1713         mmc_cmd2 = 0x80;
1714         unl_8237_set_prg(machine);
1715         unl_8237_set_chr(machine);
1716         break;
1717      case UNL_AX5705:
1718         prg_bank[0] = 0;
1719         prg_bank[1] = 1;
1720         prg8_89(machine, prg_bank[0]);
1721         prg8_ab(machine, prg_bank[1]);
1722         prg8_cd(machine, 0xfe);
1723         prg8_ef(machine, 0xff);
1724         break;
1725      case UNL_CC21:
1726         prg32(machine, 0);
1727         chr8(machine, 0, CHRROM);
1728         break;
1729      case UNL_KOF97:
1730         mapper_initialize(machine, 4);
1731         break;
1732      case UNL_T230:
1733         mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM;
1734         prg16_89ab(machine, 0);
1735         prg16_cdef(machine, nes.prg_chunks - 1);
1736         break;
1737      /* For the Boards corresponding to a Mapper, fall back to the mapper init */
16401738      case STD_NROM:
16411739      case HVC_FAMBASIC:
16421740      case JALECO_JF01:
r6152r6153
17591857      case AVE_NINA02:
17601858         mapper_initialize(machine, 34);
17611859         break;
1860      case UNL_SC127:
1861         mapper_initialize(machine, 35);
1862         break;
17621863      case NES_ZZ:
17631864         mapper_initialize(machine, 37);
17641865         break;
r6152r6153
17741875      case TAITO_TC0190FMCP:
17751876         mapper_initialize(machine, 48);
17761877         break;
1878      case BMC_NOVELDIAMOND:
1879         mapper_initialize(machine, 54);
1880         break;
17771881      case TENGEN_800032:
17781882         mapper_initialize(machine, 64);
17791883         break;
r6152r6153
19472051      case STD_DE1ROM:
19482052      case STD_DRROM:
19492053      case TENGEN_800002:
1950      case TENGEN_800004:
2054      case TENGEN_800004:
19512055      case TENGEN_800030:
19522056         mapper_initialize(machine, 206);
19532057         break;
src/mess/machine/nes_ines.c
r6152r6153
7171{
7272   UINT8 chr_mode = MMC1_regs[0] & 0x10;
7373
74   if (nes.chr_chunks)
74   if (chr_mode)
7575   {
76      if (chr_mode)
77      {
78         chr4_0(machine, MMC1_regs[1] & 0x1f, CHRROM);
79         chr4_4(machine, MMC1_regs[2] & 0x1f, CHRROM);
80      }
81      else
82         chr8(machine, (MMC1_regs[1] & 0x1f) >> 1, CHRROM);
76      chr4_0(machine, MMC1_regs[1] & 0x1f, mmc_chr_source);
77      chr4_4(machine, MMC1_regs[2] & 0x1f, mmc_chr_source);
8378   }
79   else
80      chr8(machine, (MMC1_regs[1] & 0x1f) >> 1, mmc_chr_source);
8481}
8582
8683static WRITE8_HANDLER( mapper1_w )
r6152r6153
25962593
25972594    Mapper 35
25982595
2599    Known Boards: Undocumented / Unused ?!?
2600    Games: ----------
2596    Known Boards: SC-127 Board
2597    Games: Wario World II (Kirby Hack)
26012598
2602    In MESS: ----------
2599    In MESS: Supported
26032600
26042601*************************************************************/
26052602
2603static void mapper35_irq( const device_config *device, int scanline, int vblank, int blanked )
2604{
2605   if (scanline < PPU_BOTTOM_VISIBLE_SCANLINE && IRQ_enable)
2606   {
2607      IRQ_count--;
2608
2609      if (!blanked && (IRQ_count == 0))
2610      {
2611         LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline,
2612               video_screen_get_vpos(device->machine->primary_screen), video_screen_get_hpos(device->machine->primary_screen)));
2613         cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE);
2614         IRQ_enable = 0;
2615      }
2616   }
2617}
2618
2619static WRITE8_HANDLER( mapper35_w )
2620{
2621   LOG_MMC(("mapper35_w, offset: %04x, data: %02x\n", offset, data));
2622
2623   switch (offset)
2624   {
2625   case 0x0000:
2626      prg8_89(space->machine, data);
2627      break;
2628   case 0x0001:
2629      prg8_ab(space->machine, data);
2630      break;
2631   case 0x0002:
2632//      prg_bank[offset & 0x02] = data;
2633      prg8_cd(space->machine, data);
2634      break;
2635   case 0x1000:
2636   case 0x1001:
2637   case 0x1002:
2638   case 0x1003:
2639   case 0x1004:
2640   case 0x1005:
2641   case 0x1006:
2642   case 0x1007:
2643//      vrom_bank[offset & 0x07] = data;
2644      chr1_x(space->machine, offset & 0x07, data, CHRROM);
2645      break;
2646   case 0x4002:
2647      IRQ_enable = 0;
2648      break;
2649   case 0x4003:
2650      IRQ_enable = 1;
2651      break;
2652   case 0x4005:
2653      IRQ_count = data;
2654      break;
2655   case 0x5001:
2656      set_nt_mirroring(data & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
2657      break;
2658   }
2659}
2660
26062661/*************************************************************
26072662
26082663    Mapper 36
r6152r6153
32673322    Mapper 54
32683323
32693324    Known Boards: Unknown Multigame Bootleg Board
3270    Games: [no games in nes.hsi]
3325    Games: I only found 'Novel Diamond 999999-in-1.unf' using
3326        this mapper (hence the code is used for BMC_NOVELDIAMOND
3327        board). The code is included here in case a mapper 54
3328        dump arises.
32713329
3272    In MESS: Unsupported.
3330    In MESS: Partial Support.
32733331
32743332*************************************************************/
32753333
3334static WRITE8_HANDLER( mapper54_w )
3335{
3336   LOG_MMC(("mapper54_w, offset: %04x, data: %02x\n", offset, data));
3337
3338   prg32(space->machine, offset & 0x03);
3339   chr8(space->machine, offset & 0x07, CHRROM);
3340}
3341
32763342/*************************************************************
32773343
32783344    Mapper 55
r6152r6153
40374103    Games: Linus Spacehead's Cosmic Crusade, Micro Machines,
40384104          Mig-29, Stunt Kids
40394105
4040    We currently do not emulate NT mirroring for BF9097 board
4041    (missing in BF9093). As a result Fire Hawk is broken.
4106    To emulate NT mirroring for BF9097 board (missing in BF9093)
4107    we use crc_hack, however Fire Hawk is broken (but without
4108    mirroring there would be no helicopter graphics).
40424109
40434110    In MESS: Partially Supported.
40444111
r6152r6153
1037910446   { 32, "Irem G-101",                NULL, NULL, NULL, mapper32_w, NULL, NULL, NULL },
1038010447   { 33, "Taito TC0190FMC",           NULL, NULL, NULL, mapper33_w, NULL, NULL, NULL },
1038110448   { 34, "Nina-001",                  NULL, NULL, mapper34_m_w, mapper34_w, NULL, NULL, NULL },
10449   { 35, "SC-127",                    NULL, NULL, NULL, mapper35_w, NULL, NULL, mapper35_irq },
1038210450// 35 Unused
1038310451   { 36, "TXC Policeman",             NULL, NULL, NULL, mapper36_w, NULL, NULL, NULL },
1038410452   { 37, "ZZ Board",                  NULL, NULL, mapper37_m_w, mapper4_w, NULL, NULL, mapper4_irq },
r6152r6153
1039810466   { 51, "Ballgames 11-in-1",         NULL, NULL, mapper51_m_w, mapper51_w, NULL, NULL, NULL },
1039910467   { 52, "Mario 7-in-1",              NULL, NULL, mapper52_m_w, mapper4_w, NULL, NULL, mapper4_irq },
1040010468// 53 Supervision 16-in-1
10401// 54 Novel Diamond X-in-1
10469   { 54, "Novel Diamond X-in-1",      NULL, NULL, NULL, mapper54_w, NULL, NULL, NULL },
1040210470// 55 Genius SMB
1040310471// 56 Kaiser KS202
1040410472   { 57, "GKA 6-in-1",                NULL, NULL, NULL, mapper57_w, NULL, NULL, NULL },

Previous 15994 Revisions Next


© 1998-2018 The MESS Team