Previous 15994 Revisions Next

r8177 Wednesday 26th May, 2010 at 19:50:19 UTC by Curt Coder
[ATOM] Added software list support. [Fabio Priuli]
[src/mess/drivers]atom.c

src/mess/drivers/atom.c
r8176r8177
729729    MACHINE DRIVERS
730730***************************************************************************/
731731
732struct atom_cart_range
733{
734   const char *tag;
735   int offset;
736   const char *region;
737};
738
739static const struct atom_cart_range atom_cart_table[] =
740{
741   { "cart", 0x0000, "a000" },
742   { "a0",   0x0000, "a000" },
743   { "a1",   0x1000, "a000" },
744   { "a2",   0x2000, "a000" },
745   { "a3",   0x3000, "a000" },
746   { "a4",   0x4000, "a000" },
747   { "a5",   0x5000, "a000" },
748   { "a6",   0x6000, "a000" },
749   { "a7",   0x7000, "a000" },
750   { "a8",   0x8000, "a000" },
751   { "a9",   0x9000, "a000" },
752   { "aa",   0xa000, "a000" },
753   { "ab",   0xb000, "a000" },
754   { "ac",   0xc000, "a000" },
755   { "ad",   0xd000, "a000" },
756   { "ae",   0xe000, "a000" },
757   { "af",   0xf000, "a000" },
758   { "e0",   0x0000, "e000" },
759   { "e1",   0x1000, "e000" },
760   { 0 }
761};
762
763static DEVICE_IMAGE_LOAD( atom_cart )
764{
765   UINT32 size;
766   UINT8 *temp_copy;
767   int mirror, i;
768   const struct atom_cart_range *atom_cart = &atom_cart_table[0], *this_cart;
769   
770   /* First, determine where this cart has to be loaded */
771   while (atom_cart->tag)
772   {
773      if (strcmp(atom_cart->tag, image->tag()) == 0)
774         break;
775     
776      atom_cart++;
777   }
778   
779   this_cart = atom_cart;
780     
781   if (image_software_entry(image) == NULL)
782   {
783      size = image_length(image);
784      temp_copy = auto_alloc_array(image->machine, UINT8, size);
785     
786      if (size > 0x1000)
787      {
788         image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
789         auto_free(image->machine, temp_copy);
790         return INIT_FAIL;
791      }
792     
793      if (image_fread(image, temp_copy, size) != size)
794      {
795         image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file");
796         auto_free(image->machine, temp_copy);
797         return INIT_FAIL;
798      }
799   }
800   else
801   {
802      size = image_get_software_region_length(image, "rom");
803      temp_copy = auto_alloc_array(image->machine, UINT8, size);
804      memcpy(temp_copy, image_get_software_region(image, "rom"), size);
805   }
806   
807   mirror = 0x1000 / size;
808   
809   /* With the following, we mirror the cart in the whole memory region */
810   for (i = 0; i < mirror; i++)
811      memcpy(memory_region(image->machine, this_cart->region) + this_cart->offset + i * size, temp_copy, size);
812   
813   auto_free(image->machine, temp_copy);
814   
815   return INIT_PASS;
816}
817
818
732819/*-------------------------------------------------
733820    MACHINE_DRIVER( atom )
734821-------------------------------------------------*/
735822
736823#define MDRV_ATOM_CARTSLOT_ADD(_tag) \
737824   MDRV_CARTSLOT_ADD(_tag) \
738   MDRV_CARTSLOT_EXTENSION_LIST("bin,rom")
825   MDRV_CARTSLOT_EXTENSION_LIST("bin,rom") \
826   MDRV_CARTSLOT_INTERFACE("atom_cart") \
827   MDRV_CARTSLOT_LOAD(atom_cart)
739828
829
740830static MACHINE_DRIVER_START( atom )
741831   MDRV_DRIVER_DATA(atom_state)
742832
r8176r8177
780870   MDRV_RAM_ADD("messram")
781871   MDRV_RAM_DEFAULT_SIZE("2K")
782872   MDRV_RAM_EXTRA_OPTIONS("4K,6K,8K,10K,12K")
873
874   /* Software lists */
875   MDRV_SOFTWARE_LIST_ADD("atom")
783876MACHINE_DRIVER_END
784877
785878/*-------------------------------------------------
r8176r8177
794887   MDRV_MACHINE_START(atomeb)
795888
796889   /* cartridges */
890   MDRV_DEVICE_REMOVE("cart")
797891   MDRV_ATOM_CARTSLOT_ADD("a0")
798892   MDRV_ATOM_CARTSLOT_ADD("a1")
799893   MDRV_ATOM_CARTSLOT_ADD("a2")
r8176r8177
805899   MDRV_ATOM_CARTSLOT_ADD("a8")
806900   MDRV_ATOM_CARTSLOT_ADD("a9")
807901   MDRV_ATOM_CARTSLOT_ADD("aa")
808   MDRV_ATOM_CARTSLOT_ADD("an")
902   MDRV_ATOM_CARTSLOT_ADD("ab")
809903   MDRV_ATOM_CARTSLOT_ADD("ac")
810904   MDRV_ATOM_CARTSLOT_ADD("ad")
811905   MDRV_ATOM_CARTSLOT_ADD("ae")
r8176r8177
830924   ROM_LOAD( "afloat.ic21", 0x1000, 0x1000, CRC(81d86af7) SHA1(ebcde5b36cb3a3344567cbba4c7b9fde015f4802) )
831925   ROM_LOAD( "dosrom.u15",  0x2000, 0x1000, CRC(c431a9b7) SHA1(71ea0a4b8d9c3caf9718fc7cc279f4306a23b39c) )
832926
833   ROM_REGION( 0x1000, "a000", 0 )
834   ROM_CART_LOAD( "cart", 0x0000, 0x1000, ROM_MIRROR )
927   ROM_REGION( 0x1000, "a000", ROMREGION_ERASEFF )
835928ROM_END
836929
837930/*-------------------------------------------------
r8176r8177
845938   ROM_LOAD( "afloat.ic21", 0x1000, 0x1000, CRC(81d86af7) SHA1(ebcde5b36cb3a3344567cbba4c7b9fde015f4802) )
846939   ROM_LOAD( "dosrom.u15",  0x2000, 0x1000, CRC(c431a9b7) SHA1(71ea0a4b8d9c3caf9718fc7cc279f4306a23b39c) )
847940
848   ROM_REGION( 0x10000, "a000", 0 )
849   ROM_CART_LOAD( "a0", 0x0000, 0x1000, ROM_MIRROR )
850   ROM_CART_LOAD( "a1", 0x1000, 0x1000, ROM_MIRROR )
851   ROM_CART_LOAD( "a2", 0x2000, 0x1000, ROM_MIRROR )
852   ROM_CART_LOAD( "a3", 0x3000, 0x1000, ROM_MIRROR )
853   ROM_CART_LOAD( "a4", 0x4000, 0x1000, ROM_MIRROR )
854   ROM_CART_LOAD( "a5", 0x5000, 0x1000, ROM_MIRROR )
855   ROM_CART_LOAD( "a6", 0x6000, 0x1000, ROM_MIRROR )
856   ROM_CART_LOAD( "a7", 0x7000, 0x1000, ROM_MIRROR )
857   ROM_CART_LOAD( "a8", 0x8000, 0x1000, ROM_MIRROR )
858   ROM_CART_LOAD( "a9", 0x9000, 0x1000, ROM_MIRROR )
859   ROM_CART_LOAD( "aa", 0xa000, 0x1000, ROM_MIRROR )
860   ROM_CART_LOAD( "ab", 0xb000, 0x1000, ROM_MIRROR )
861   ROM_CART_LOAD( "ac", 0xc000, 0x1000, ROM_MIRROR )
862   ROM_CART_LOAD( "ad", 0xd000, 0x1000, ROM_MIRROR )
863   ROM_CART_LOAD( "ae", 0xe000, 0x1000, ROM_MIRROR )
864   ROM_CART_LOAD( "af", 0xf000, 0x1000, ROM_MIRROR )
941   ROM_REGION( 0x10000, "a000", ROMREGION_ERASEFF )
865942
866   ROM_REGION( 0x2000, "e000", 0)
867   ROM_CART_LOAD( "e0", 0x0000, 0x1000, ROM_MIRROR )
868   ROM_CART_LOAD( "e1", 0x1000, 0x1000, ROM_MIRROR )
943   ROM_REGION( 0x2000, "e000", ROMREGION_ERASEFF )
869944ROM_END
870945
871946/***************************************************************************

Previous 15994 Revisions Next


© 1998-2018 The MESS Team