Пример #1
0
static const multicartslot_pcb_type *identify_pcb(device_image_interface &image)
{
	const multicartslot_config *config = get_config(&image.device());
	astring pcb_name;
	const multicartslot_pcb_type *pcb_type = NULL;
	multicart_t *mc;
	int i;

	if (image.exists())
	{
		/* try opening this as if it were a multicart */
		multicart_open_error me = multicart_open(image.device().machine().options(), image.filename(), image.device().machine().system().name, MULTICART_FLAGS_DONT_LOAD_RESOURCES, &mc);
		if (me == MCERR_NONE)
		{
			/* this was a multicart - read from it */
			astring_cpyc(&pcb_name, mc->pcb_type);
			multicart_close(image.device().machine().options(), mc);
		}
		else
		{
			if (me != MCERR_NOT_MULTICART)
				fatalerror("multicart error: %s", multicart_error_text(me));
		}

		/* look for PCB type with matching name */
		for (i = 0; (i < ARRAY_LENGTH(config->pcb_types)) && (config->pcb_types[i].name != NULL); i++)
		{
			if ((config->pcb_types[i].name[0] == '\0') || !strcmp(astring_c(&pcb_name), config->pcb_types[i].name))
			{
				pcb_type = &config->pcb_types[i];
				break;
			}
		}

		/* check for unknown PCB type */
		if ((mc != NULL) && (pcb_type == NULL))
			fatalerror("Unknown PCB type \"%s\"", astring_c(&pcb_name));
	}
	else
	{
		/* no device loaded; use the default */
		pcb_type = (config->pcb_types[0].name != NULL) ? &config->pcb_types[0] : NULL;
	}
	return pcb_type;
}
Пример #2
0
/*
    Load the cartridge image files. Apart from reading, we set pointers
    to the image files so that during runtime we do not need search
    operations.
*/
static DEVICE_IMAGE_LOAD( aes_cartridge )
{
	device_t *pcbdev = cartslot_get_pcb(image);
	aes_pcb_t *pcb;
	cartslot_t *cart;
	multicart_open_error me;
	UINT32 size;
	device_t* ym = image.device().machine().device("ymsnd");

	// first check software list
	if(image.software_entry() != NULL)
	{
		// create memory regions
		size = image.get_software_region_length("maincpu");
		image.device().machine().region_free("maincpu");
		image.device().machine().region_alloc("maincpu",size,1, ENDIANNESS_LITTLE);
		memcpy(image.device().machine().region("maincpu")->base(),image.get_software_region("maincpu"),size);
		size = image.get_software_region_length("fixed");
		image.device().machine().region_free("fixed");
		image.device().machine().region_alloc("fixed",size,1, ENDIANNESS_LITTLE);
		memcpy(image.device().machine().region("fixed")->base(),image.get_software_region("fixed"),size);
		size = image.get_software_region_length("audiocpu");
		image.device().machine().region_free("audiocpu");
		image.device().machine().region_alloc("audiocpu",size,1, ENDIANNESS_LITTLE);
		memcpy(image.device().machine().region("audiocpu")->base(),image.get_software_region("audiocpu"),size);
		size = image.get_software_region_length("ymsnd");
		image.device().machine().region_free("ymsnd");
		image.device().machine().region_alloc("ymsnd",size,1, ENDIANNESS_LITTLE);
		memcpy(image.device().machine().region("ymsnd")->base(),image.get_software_region("ymsnd"),size);
		if(image.get_software_region("ymsnd.deltat") != NULL)
		{
			size = image.get_software_region_length("ymsnd.deltat");
			image.device().machine().region_free("ymsnd.deltat");
			image.device().machine().region_alloc("ymsnd.deltat",size,1, ENDIANNESS_LITTLE);
			memcpy(image.device().machine().region("ymsnd.deltat")->base(),image.get_software_region("ymsnd.deltat"),size);
		}
		else
			image.device().machine().region_free("ymsnd.deltat");  // removing the region will fix sound glitches in non-Delta-T games
		ym->reset();
		size = image.get_software_region_length("sprites");
		image.device().machine().region_free("sprites");
		image.device().machine().region_alloc("sprites",size,1, ENDIANNESS_LITTLE);
		memcpy(image.device().machine().region("sprites")->base(),image.get_software_region("sprites"),size);
		if(image.get_software_region("audiocrypt") != NULL)  // encrypted Z80 code
		{
			size = image.get_software_region_length("audiocrypt");
			image.device().machine().region_alloc("audiocrypt",size,1, ENDIANNESS_LITTLE);
			memcpy(image.device().machine().region("audiocrypt")->base(),image.get_software_region("audiocrypt"),size);
		}

		// setup cartridge ROM area
		image.device().machine().device("maincpu")->memory().space(AS_PROGRAM)->install_read_bank(0x000080,0x0fffff,"cart_rom");
		memory_set_bankptr(image.device().machine(),"cart_rom",&image.device().machine().region("maincpu")->base()[0x80]);

		// handle possible protection
		install_protection(image);

		return IMAGE_INIT_PASS;
	}

	if (pcbdev == NULL)
		fatalerror("Error loading multicart: no pcb found.");

	/* If we are here, we have a multicart. */
	pcb = get_safe_pcb_token(pcbdev);
	cart = get_safe_cartslot_token(&image.device());

	/* try opening this as a multicart */
	/* This line requires that cartslot_t be included in cartslot.h,
    otherwise one cannot make use of multicart handling within such a
    custom LOAD function. */
	me = multicart_open(image.device().machine().options(), image.filename(), image.device().machine().system().name, MULTICART_FLAGS_LOAD_RESOURCES, &cart->mc);

	/* Now that we have loaded the image files, let the PCB put them all
    together. This means we put the images in a structure which allows
    for a quick access by the memory handlers. Every PCB defines an
    own assembly method. */
    if (me != MCERR_NONE)
		fatalerror("Error loading multicart: %s", multicart_error_text(me));

	return pcb->assemble(pcbdev->machine(), image);
}