Exemple #1
0
bool plus4_expansion_slot_device::call_load()
{
	if (m_card)
	{
		size_t size = 0;

		if (software_entry() == NULL)
		{
			// TODO
		}
		else
		{
			size = get_software_region_length("c1l");
			if (size) memcpy(m_card->plus4_c1l_pointer(machine(), size), get_software_region("c1l"), size);

			size = get_software_region_length("c1h");
			if (size) memcpy(m_card->plus4_c1h_pointer(machine(), size), get_software_region("c1h"), size);

			size = get_software_region_length("c2l");
			if (size) memcpy(m_card->plus4_c2l_pointer(machine(), size), get_software_region("c2l"), size);

			size = get_software_region_length("c2h");
			if (size) memcpy(m_card->plus4_c2h_pointer(machine(), size), get_software_region("c2h"), size);

			size = get_software_region_length("ram");
			if (size) memset(m_card->plus4_ram_pointer(machine(), size), 0, size);

			size = get_software_region_length("nvram");
			if (size) memset(m_card->plus4_nvram_pointer(machine(), size), 0, size);
		}
	}

	return IMAGE_INIT_PASS;
}
Exemple #2
0
bool vic10_expansion_slot_device::call_load()
{
	if (m_cart)
	{
		size_t size = 0;

		if (software_entry() == NULL)
		{
			size = length();

			if (!mame_stricmp(filetype(), "80"))
			{
				fread(m_cart->vic10_lorom_pointer(machine(), 0x2000), 0x2000);

				if (size == 0x4000)
				{
					fread(m_cart->vic10_uprom_pointer(machine(), 0x2000), 0x2000);
				}
			}
			else if (!mame_stricmp(filetype(), "e0")) fread(m_cart->vic10_uprom_pointer(machine(), size), size);
			else if (!mame_stricmp(filetype(), "crt"))
			{
				size_t roml_size = 0;
				size_t romh_size = 0;
				int exrom = 1;
				int game = 1;

				if (cbm_crt_read_header(m_file, &roml_size, &romh_size, &exrom, &game))
				{
					UINT8 *roml = NULL;
					UINT8 *romh = NULL;

					if (roml_size) roml = m_cart->vic10_lorom_pointer(machine(), roml_size);
					if (romh_size) romh = m_cart->vic10_uprom_pointer(machine(), romh_size);

					cbm_crt_read_data(m_file, roml, romh);
				}
			}
		}
		else
		{
			size = get_software_region_length("lorom");
			if (size) memcpy(m_cart->vic10_lorom_pointer(machine(), size), get_software_region("lorom"), size);

			size = get_software_region_length("uprom");
			if (size) memcpy(m_cart->vic10_uprom_pointer(machine(), size), get_software_region("uprom"), size);

			size = get_software_region_length("exram");
			if (size) m_cart->vic10_exram_pointer(machine(), size);
		}
	}

	return IMAGE_INIT_PASS;
}
Exemple #3
0
bool vc4000_cart_slot_device::call_load()
{
	if (m_cart)
	{
		UINT32 size = (software_entry() == NULL) ? length() : get_software_region_length("rom");

		if (size > 0x1800)
		{
			seterror(IMAGE_ERROR_UNSPECIFIED, "Image extends beyond the expected size for a VC4000 cart");
			return IMAGE_INIT_FAIL;
		}

		m_cart->rom_alloc(size, tag());

		if (software_entry() == NULL)
			fread(m_cart->get_rom_base(), size);
		else
			memcpy(m_cart->get_rom_base(), get_software_region("rom"), size);

		if (software_entry() == NULL)
		{
			m_type = VC4000_STD;
			// attempt to identify the non-standard types
			if (size > 0x1000)  // 6k rom + 1k ram - Chess2 only
				m_type = VC4000_CHESS2;
			else if (size > 0x0800) // some 4k roms have 1k of mirrored ram (those who don't still work with RAM emulated luckily)
				m_type = VC4000_RAM1K;

			if (m_type == VC4000_RAM1K || m_type == VC4000_CHESS2)
				m_cart->ram_alloc(0x400);
		}
		else
		{
			const char *pcb_name = get_feature("slot");
			if (pcb_name)
				m_type = vc4000_get_pcb_id(pcb_name);

			if (get_software_region("ram"))
				m_cart->ram_alloc(get_software_region_length("ram"));
		}

		//printf("Type: %s\n", vc4000_get_slot(m_type));

		return IMAGE_INIT_PASS;
	}

	return IMAGE_INIT_PASS;
}
Exemple #4
0
bool apf_cart_slot_device::call_load()
{
	if (m_cart)
	{
		UINT32 size = (software_entry() == NULL) ? length() : get_software_region_length("rom");

		if (size > 0x3800)
		{
			seterror(IMAGE_ERROR_UNSPECIFIED, "Image extends beyond the expected size for an APF cart");
			return IMAGE_INIT_FAIL;
		}

		m_cart->rom_alloc(size, tag());

		if (software_entry() == NULL)
			fread(m_cart->get_rom_base(), size);
		else
			memcpy(m_cart->get_rom_base(), get_software_region("rom"), size);

		if (software_entry() == NULL)
		{
			m_type = APF_STD;
			// attempt to identify Space Destroyer, which needs 1K of additional RAM
			if (size == 0x1800)
			{
				m_type = APF_SPACEDST;
				m_cart->ram_alloc(0x400);
			}
			if (size > 0x2000)
				m_type = APF_BASIC;
		}
		else
		{
			const char *pcb_name = get_feature("slot");
			if (pcb_name)
				m_type = apf_get_pcb_id(pcb_name);

			if (get_software_region("ram"))
				m_cart->ram_alloc(get_software_region_length("ram"));
		}

		//printf("Type: %s\n", apf_get_slot(m_type));

		return IMAGE_INIT_PASS;
	}

	return IMAGE_INIT_PASS;
}
Exemple #5
0
image_init_result scv_cart_slot_device::call_load()
{
	if (m_cart)
	{
		UINT8 *ROM;
		UINT32 len = (software_entry() == nullptr) ? length() : get_software_region_length("rom");
		bool has_ram = (software_entry() != nullptr) && get_software_region("ram");

		if (len > 0x20000)
		{
			seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
			return image_init_result::FAIL;
		}

		m_cart->rom_alloc(len, tag());
		if (has_ram)
			m_cart->ram_alloc(get_software_region_length("ram"));

		ROM = m_cart->get_rom_base();

		if (software_entry() == nullptr)
			fread(ROM, len);
		else
			memcpy(ROM, get_software_region("rom"), len);

		if (software_entry() == nullptr)
			m_type = get_cart_type(ROM, len);
		else
		{
			const char *pcb_name = get_feature("slot");
			if (pcb_name)
				m_type = scv_get_pcb_id(pcb_name);
		}

		// for the moment we only support RAM from softlist and in the following configurations
		// 1) 32K ROM + 8K RAM; 2) 128K ROM + 4K RAM
		if (m_type == SCV_32K && has_ram)
			m_type = SCV_32K_RAM;
		if (m_type == SCV_128K && has_ram)
			m_type = SCV_128K_RAM;

		//printf("Type: %s\n", scv_get_slot(m_type));

		return image_init_result::PASS;
	}

	return image_init_result::PASS;
}
Exemple #6
0
image_init_result nes_kstudio_slot_device::call_load()
{
	if (m_cart)
	{
		uint8_t *ROM = m_cart->get_cart_base();

		if (!ROM)
			return image_init_result::FAIL;

		// Existing exapnsion carts are all 128K, so we only load files of this size
		if (software_entry() == nullptr)
		{
			if (length() != 0x20000)
				return image_init_result::FAIL;

			fread(&ROM, 0x20000);
		}
		else
		{
			if (get_software_region_length("rom") != 0x20000)
				return image_init_result::FAIL;

			memcpy(ROM, get_software_region("rom"), 0x20000);
		}
	}

	return image_init_result::PASS;
}
Exemple #7
0
image_init_result ekara_cart_slot_device::call_load()
{
	if (m_cart)
	{
		uint8_t *ROM;
		uint32_t len = !loaded_through_softlist() ? length() : get_software_region_length("rom");

		m_cart->rom_alloc(len, tag());

		ROM = m_cart->get_rom_base();

		if (!loaded_through_softlist())
			fread(ROM, len);
		else
			memcpy(ROM, get_software_region("rom"), len);

		if (!loaded_through_softlist())
		{
			// attempt to detect cart type without softlist assistance
			m_type = get_cart_type(ROM, len);
		}
		else
		{
			// or for softlist loading, use the type specified
			const char *pcb_name = get_feature("slot");
			if (pcb_name)
				m_type = ekara_get_pcb_id(pcb_name);
		}

		return image_init_result::PASS;
	}

	return image_init_result::PASS;
}
Exemple #8
0
image_init_result nes_ntb_slot_device::call_load()
{
	if (m_cart)
	{
		uint8_t *ROM = m_cart->get_cart_base();

		if (!ROM)
			return image_init_result::FAIL;

		if (!loaded_through_softlist())
		{
			if (length() != 0x4000)
				return image_init_result::FAIL;

			fread(&ROM, 0x4000);
		}
		else
		{
			if (get_software_region_length("rom") != 0x4000)
				return image_init_result::FAIL;

			memcpy(ROM, get_software_region("rom"), 0x4000);
		}
	}

	return image_init_result::PASS;
}
Exemple #9
0
image_init_result z88cart_slot_device::call_load()
{
	if (m_cart)
	{
		offs_t read_length;
		uint8_t *cart_base = m_cart->get_cart_base();

		if (cart_base != nullptr)
		{
			if (software_entry() == nullptr)
			{
				read_length = length();
				fread(cart_base + (m_cart->get_cart_size() - read_length), read_length);
			}
			else
			{
				read_length = get_software_region_length("rom");
				memcpy(cart_base + (m_cart->get_cart_size() - read_length), get_software_region("rom"), read_length);
			}
		}
		else
			return image_init_result::FAIL;
	}

	// open the flap
	m_out_flp_cb(ASSERT_LINE);

	// setup the timer for close the flap
	m_flp_timer->adjust(CLOSE_FLAP_TIME);

	return image_init_result::PASS;
}
Exemple #10
0
image_init_result iq151cart_slot_device::call_load()
{
	if (m_cart)
	{
		offs_t read_length;
		uint8_t *cart_base = m_cart->get_cart_base();

		if (cart_base != nullptr)
		{
			if (!loaded_through_softlist())
			{
				read_length = length();
				fread(m_cart->get_cart_base(), read_length);
			}
			else
			{
				read_length = get_software_region_length("rom");
				memcpy(m_cart->get_cart_base(), get_software_region("rom"), read_length);
			}
		}
		else
			return image_init_result::FAIL;
	}

	return image_init_result::PASS;
}
Exemple #11
0
bool sat_cart_slot_device::call_load()
{
	if (m_cart)
	{
		UINT32 *ROM;
		UINT32 len;

		if (software_entry() != NULL)
			len = get_software_region_length("cart");
		else
			len = length();

		m_cart->rom_alloc(machine(), len);
		ROM = m_cart->get_rom_base();

		if (software_entry() != NULL)
			memcpy(ROM, get_software_region("cart"), len);
		else
			fread(ROM, len);

		// fix endianness....
		for (int i = 0; i < len/4; i ++)
			ROM[i] = BITSWAP32(ROM[i],7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24);
//          UINT8 tempa = ROM[i+0];
//          UINT8 tempb = ROM[i+1];
//          ROM[i+1] = ROM[i+2];
//          ROM[i+0] = ROM[i+3];
//          ROM[i+3] = tempa;
//          ROM[i+2] = tempb;
//      }
		return IMAGE_INIT_PASS;
	}

	return IMAGE_INIT_PASS;
}
Exemple #12
0
image_init_result o2_cart_slot_device::call_load()
{
	if (m_cart)
	{
		UINT32 size = (software_entry() == nullptr) ? length() : get_software_region_length("rom");
		m_cart->rom_alloc(size, tag());

		if (software_entry() == nullptr)
			fread(m_cart->get_rom_base(), size);
		else
			memcpy(m_cart->get_rom_base(), get_software_region("rom"), size);

		if (software_entry() == nullptr)
		{
			m_type = O2_STD;
			if (size == 12288)
				m_type = O2_ROM12;
			if (size == 16384)
				m_type = O2_ROM16;
		}
		else
		{
			const char *pcb_name = get_feature("slot");
			if (pcb_name)
				m_type = o2_get_pcb_id(pcb_name);
		}

		//printf("Type: %s\n", o2_get_slot(m_type));

		return image_init_result::PASS;
	}

	return image_init_result::PASS;
}
Exemple #13
0
bool nes_ntb_slot_device::call_load()
{
	if (m_cart)
	{
		UINT8 *ROM = m_cart->get_cart_base();

		if (!ROM)
			return IMAGE_INIT_FAIL;

		if (software_entry() == nullptr)
		{
			if (length() != 0x4000)
				return IMAGE_INIT_FAIL;

			fread(&ROM, 0x4000);
		}
		else
		{
			if (get_software_region_length("rom") != 0x4000)
				return IMAGE_INIT_FAIL;

			memcpy(ROM, get_software_region("rom"), 0x4000);
		}
	}

	return IMAGE_INIT_PASS;
}
Exemple #14
0
bool z88cart_slot_device::call_load()
{
	if (m_cart)
	{
		offs_t read_length = 0;
		UINT8 *cart_base = m_cart->get_cart_base();

		if (cart_base != NULL)
		{
			if (software_entry() == NULL)
			{
				read_length = length();
				fread(cart_base + (m_cart->get_cart_size() - read_length), read_length);
			}
			else
			{
				read_length = get_software_region_length("rom");
				memcpy(cart_base + (m_cart->get_cart_size() - read_length), get_software_region("rom"), read_length);
			}
		}
		else
			return IMAGE_INIT_FAIL;
	}

	// open the flap
	m_out_flp_func(ASSERT_LINE);

	// setup the timer for close the flap
	m_flp_timer->adjust(CLOSE_FLAP_TIME);

	return IMAGE_INIT_PASS;
}
Exemple #15
0
bool nes_kstudio_slot_device::call_load()
{
	if (m_cart)
	{
		UINT8 *ROM = m_cart->get_cart_base();

		if (!ROM)
			return IMAGE_INIT_FAIL;

		// Existing exapnsion carts are all 128K, so we only load files of this size
		if (software_entry() == NULL)
		{
			if (length() != 0x20000)
				return IMAGE_INIT_FAIL;

			fread(&ROM, 0x20000);
		}
		else
		{
			if (get_software_region_length("rom") != 0x20000)
				return IMAGE_INIT_FAIL;

			memcpy(ROM, get_software_region("rom"), 0x20000);
		}
	}

	return IMAGE_INIT_PASS;
}
Exemple #16
0
bool iq151cart_slot_device::call_load()
{
	if (m_cart)
	{
		offs_t read_length = 0;
		UINT8 *cart_base = m_cart->get_cart_base();

		if (cart_base != NULL)
		{
			if (software_entry() == NULL)
			{
				read_length = length();
				fread(m_cart->get_cart_base(), read_length);
			}
			else
			{
				read_length = get_software_region_length("rom");
				memcpy(m_cart->get_cart_base(), get_software_region("rom"), read_length);
			}
		}
		else
			return IMAGE_INIT_FAIL;
	}

	return IMAGE_INIT_PASS;
}
Exemple #17
0
bool astrocade_cart_slot_device::call_load()
{
	if (m_cart)
	{
		UINT32 size = (software_entry() == nullptr) ? length() : get_software_region_length("rom");
		m_cart->rom_alloc(size, tag());

		if (software_entry() == nullptr)
			fread(m_cart->get_rom_base(), size);
		else
			memcpy(m_cart->get_rom_base(), get_software_region("rom"), size);

		if (software_entry() == nullptr)
		{
			m_type = ASTROCADE_STD;

			if (size == 0x40000)
				m_type = ASTROCADE_256K;
			if (size == 0x80000)
				m_type = ASTROCADE_512K;
		}
		else
		{
			const char *pcb_name = get_feature("slot");
			if (pcb_name)
				m_type = astrocade_get_pcb_id(pcb_name);
		}

		//printf("Type: %s\n", astrocade_get_slot(m_type));

		return IMAGE_INIT_PASS;
	}

	return IMAGE_INIT_PASS;
}
Exemple #18
0
image_init_result sat_cart_slot_device::call_load()
{
	if (m_cart)
	{
		bool is_rom = (!loaded_through_softlist() || (loaded_through_softlist() && get_software_region("rom")));

		if (is_rom)
		{
			// from fullpath, only ROM carts
			uint32_t len = loaded_through_softlist() ? get_software_region_length("rom") : length();
			uint32_t *ROM;

			m_cart->rom_alloc(len, tag());
			ROM = m_cart->get_rom_base();

			if (loaded_through_softlist())
				memcpy(ROM, get_software_region("rom"), len);
			else
				fread(ROM, len);

			// fix endianness....
			for (int i = 0; i < len/4; i ++)
				ROM[i] = bitswap<32>(ROM[i],7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24);
//          {
//              uint8_t tempa = ROM[i+0];
//              uint8_t tempb = ROM[i+1];
//              ROM[i+1] = ROM[i+2];
//              ROM[i+0] = ROM[i+3];
//              ROM[i+3] = tempa;
//              ROM[i+2] = tempb;
//          }
		}
		else
		{
			// DRAM or BRAM carts from softlist
			if (get_software_region("bram"))
				m_cart->bram_alloc(get_software_region_length("bram"));
			if (get_software_region("dram0"))
				m_cart->dram0_alloc(get_software_region_length("dram0"));
			if (get_software_region("dram1"))
				m_cart->dram1_alloc(get_software_region_length("dram1"));
		}
		return image_init_result::PASS;
	}

	return image_init_result::PASS;
}
Exemple #19
0
bool sat_cart_slot_device::call_load()
{
	if (m_cart)
	{
		bool is_rom = ((software_entry() == NULL) || ((software_entry() != NULL) && get_software_region("rom")));

		if (is_rom)
		{
			// from fullpath, only ROM carts
			UINT32 len = (software_entry() != NULL) ? get_software_region_length("rom") : length();
			UINT32 *ROM;
			
			m_cart->rom_alloc(len, tag());
			ROM = m_cart->get_rom_base();
			
			if (software_entry() != NULL)
				memcpy(ROM, get_software_region("rom"), len);
			else
				fread(ROM, len);
			
			// fix endianness....
			for (int i = 0; i < len/4; i ++)
				ROM[i] = BITSWAP32(ROM[i],7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24);
//          {
//              UINT8 tempa = ROM[i+0];
//              UINT8 tempb = ROM[i+1];
//              ROM[i+1] = ROM[i+2];
//              ROM[i+0] = ROM[i+3];
//              ROM[i+3] = tempa;
//              ROM[i+2] = tempb;
//          }
		}
		else
		{
			// DRAM or BRAM carts from softlist
			if (get_software_region("bram"))
				m_cart->bram_alloc(get_software_region_length("bram"));
			if (get_software_region("dram0"))
				m_cart->dram0_alloc(get_software_region_length("dram0"));
			if (get_software_region("dram1"))
				m_cart->dram1_alloc(get_software_region_length("dram1"));
		}
		return IMAGE_INIT_PASS;
	}

	return IMAGE_INIT_PASS;
}
Exemple #20
0
bool vboy_cart_slot_device::call_load()
{
	if (m_cart)
	{
		UINT8 *ROM;
		UINT32 len = (software_entry() == NULL) ? length() : get_software_region_length("rom");
		bool has_eeprom = (software_entry() != NULL) && get_software_region("eeprom");

		if (len > 0x200000)
		{
			seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
			return IMAGE_INIT_FAIL;
		}

		// always alloc 0x200000 so to be able to directly map the region
		// to the address map (speeding up emulation a bit)
		m_cart->rom_alloc(0x200000, tag());
		if (has_eeprom)
			m_cart->eeprom_alloc(get_software_region_length("eeprom"));

		ROM = (UINT8 *)m_cart->get_rom_base();

		if (software_entry() == NULL)
			fread(ROM, len);
		else
			memcpy(ROM, get_software_region("rom"), len);

		if (len < 0x080000) { memcpy(ROM + 0x040000, ROM, 0x040000); }
		if (len < 0x100000) { memcpy(ROM + 0x080000, ROM, 0x080000); }
		if (len < 0x200000) { memcpy(ROM + 0x100000, ROM, 0x100000); }

		if (software_entry() == NULL)
			m_type = vboy_get_pcb_id("vb_rom");
		else
		{
			const char *pcb_name = get_feature("slot");
			if (pcb_name)
				m_type = vboy_get_pcb_id(pcb_name);
		}

		//printf("Type: %s\n", vboy_get_slot(m_type));

		return IMAGE_INIT_PASS;
	}

	return IMAGE_INIT_PASS;
}
Exemple #21
0
image_init_result a800_cart_slot_device::call_load()
{
	if (m_cart)
	{
		uint32_t len;

		if (software_entry() != nullptr)
		{
			const char *pcb_name;
			len = get_software_region_length("rom");

			m_cart->rom_alloc(len, tag());
			memcpy(m_cart->get_rom_base(), get_software_region("rom"), len);

			if ((pcb_name = get_feature("slot")) != nullptr)
				m_type = a800_get_pcb_id(pcb_name);
			else
				m_type = A800_8K;
		}
		else
		{
			len = length();

			// check whether there is an header, to identify the cart type
			if ((len % 0x1000) == 0x10)
			{
				uint8_t header[16];
				fread(header, 0x10);
				m_type = identify_cart_type(header);
				len -= 0x10;    // in identify_cart_type the first 0x10 bytes are read, so we need to adjust here
			}
			else    // otherwise try to guess based on size
			{
				if (len == 0x8000)
					m_type = A5200_32K;
				if (len == 0x4000)
					m_type = A800_16K;
				if (len == 0x2000)
					m_type = A800_8K;
				if (len == 0x1000)
					m_type = A5200_4K;
				// also make a try with .hsi file (for .a52 files)
				std::string info;
				if (hashfile_extrainfo(*this, info) && info.compare("A13MIRRORING")==0)
					m_type = A5200_16K_2CHIPS;
			}

			m_cart->rom_alloc(len, tag());
			fread(m_cart->get_rom_base(), len);
		}
		if (m_type == A800_TELELINK2)
			m_cart->nvram_alloc(0x100);

		logerror("%s loaded cartridge '%s' size %dK\n", machine().system().name, filename(), len/1024);
	}
	return image_init_result::PASS;
}
Exemple #22
0
bool cbm2_expansion_slot_device::call_load()
{
	size_t size = 0;

	if (m_card)
	{
		if (software_entry() == NULL)
		{
			size = length();

			if (!mame_stricmp(filetype(), "20"))
			{
				fread(m_card->cbm2_bank1_pointer(machine(), size), size);
			}
			else if (!mame_stricmp(filetype(), "40"))
			{
				fread(m_card->cbm2_bank2_pointer(machine(), size), size);
			}
			else if (!mame_stricmp(filetype(), "60"))
			{
				fread(m_card->cbm2_bank3_pointer(machine(), size), size);
			}
		}
		else
		{
			size = get_software_region_length("bank1");
			if (size) memcpy(m_card->cbm2_bank1_pointer(machine(), size), get_software_region("bank1"), size);

			size = get_software_region_length("bank2");
			if (size) memcpy(m_card->cbm2_bank2_pointer(machine(), size), get_software_region("bank2"), size);

			size = get_software_region_length("bank3");
			if (size) memcpy(m_card->cbm2_bank3_pointer(machine(), size), get_software_region("bank3"), size);

			size = get_software_region_length("ram");
			if (size) memset(m_card->cbm2_ram_pointer(machine(), size), 0, size);

			size = get_software_region_length("nvram");
			if (size) memset(m_card->cbm2_nvram_pointer(machine(), size), 0, size);
		}
	}

	return IMAGE_INIT_PASS;
}
Exemple #23
0
image_init_result hp_optrom_slot_device::call_load()
{
    logerror("hp_optrom: call_load\n");
    if (m_cart == nullptr || !loaded_through_softlist()) {
        logerror("hp_optrom: must be loaded from sw list\n");
        return image_init_result::FAIL;
    }

    const char *base_feature = get_feature("base");
    if (base_feature == nullptr) {
        logerror("hp_optrom: no 'base' feature\n");
        return image_init_result::FAIL;
    }

    offs_t base_addr;
    if (base_feature[ 0 ] != '0' || base_feature[ 1 ] != 'x' || sscanf(&base_feature[ 2 ] , "%x" , &base_addr) != 1) {
        logerror("hp_optrom: can't parse 'base' feature\n");
        return image_init_result::FAIL;
    }

    // Valid BSC values for ROMs on LPU drawer: 0x07 0x0b .... 0x3b
    // Valid BSC values for ROMs on PPU drawer: 0x09 0x0d .... 0x3d
    // (BSC is field in bits 16..21 of base address)
    // Bit 15 of base address must be 0
    // Base address must be multiple of 0x1000
    if ((base_addr & ~0x3f7000UL) != 0 || ((base_addr & 0x30000) != 0x10000 && (base_addr & 0x30000) != 0x30000) || base_addr < 0x70000) {
        logerror("hp_optrom: illegal base address (%x)\n" , base_addr);
        return image_init_result::FAIL;
    }

    auto length = get_software_region_length("rom") / 2;

    if (length < 0x1000 || length > 0x8000 || (length & 0xfff) != 0 || ((base_addr & 0x7000) + length) > 0x8000) {
        logerror("hp_optrom: illegal region length (%x)\n" , length);
        return image_init_result::FAIL;
    }

    offs_t end_addr = base_addr + length - 1;
    logerror("hp_optrom: base_addr = %06x end_addr = %06x\n" , base_addr , end_addr);

    m_content.resize(length * 2);
    uint8_t *buffer = m_content.data();
    memcpy(buffer , get_software_region("rom") , length * 2);

    // Install ROM in address space of every CPU
    for (hp_hybrid_cpu_device& cpu : device_interface_iterator<hp_hybrid_cpu_device>(machine().root_device())) {
        logerror("hp_optrom: install in %s AS\n" , cpu.tag());
        cpu.space(AS_PROGRAM).install_rom(base_addr , end_addr , buffer);
    }

    m_base_addr = base_addr;
    m_end_addr = end_addr;

    return image_init_result::PASS;
}
Exemple #24
0
bool a800_cart_slot_device::call_load()
{
	if (m_cart)
	{
		UINT32 len;

		if (software_entry() != nullptr)
		{
			const char *pcb_name;
			len = get_software_region_length("rom");

			m_cart->rom_alloc(len, tag());
			memcpy(m_cart->get_rom_base(), get_software_region("rom"), len);

			if ((pcb_name = get_feature("slot")) != nullptr)
				m_type = a800_get_pcb_id(pcb_name);
			else
				m_type = A800_8K;
		}
		else
		{
			len = length();

			// check whether there is an header, to identify the cart type
			if ((len % 0x1000) == 0x10)
			{
				UINT8 header[16];
				fread(header, 0x10);
				m_type = identify_cart_type(header);
				len -= 0x10;    // in identify_cart_type the first 0x10 bytes are read, so we need to adjust here
			}
			else    // otherwise try to guess based on size
			{
				if (len == 0x8000)
					m_type = A5200_32K;
				if (len == 0x4000)
					m_type = A800_16K;
				if (len == 0x2000)
					m_type = A800_8K;
				if (len == 0x1000)
					m_type = A5200_4K;
			}

			m_cart->rom_alloc(len, tag());
			fread(m_cart->get_rom_base(), len);
		}
		if (m_type == A800_TELELINK2)
			m_cart->nvram_alloc(0x100);

		printf("%s loaded cartridge '%s' size %dK\n", machine().system().name, filename(), len/1024);
	}
	return IMAGE_INIT_PASS;
}
Exemple #25
0
bool vic20_expansion_slot_device::call_load()
{
	if (m_cart)
	{
		size_t size = 0;

		if (software_entry() == NULL)
		{
			if (!mame_stricmp(filetype(), "20")) fread(m_cart->vic20_blk1_pointer(machine(), 0x2000), 0x2000);
			else if (!mame_stricmp(filetype(), "40")) fread(m_cart->vic20_blk2_pointer(machine(), 0x2000), 0x2000);
			else if (!mame_stricmp(filetype(), "60")) fread(m_cart->vic20_blk3_pointer(machine(), 0x2000), 0x2000);
			else if (!mame_stricmp(filetype(), "70")) fread(m_cart->vic20_blk3_pointer(machine(), 0x2000) + 0x1000, 0x1000);
			else if (!mame_stricmp(filetype(), "a0")) fread(m_cart->vic20_blk5_pointer(machine(), 0x2000), 0x2000);
			else if (!mame_stricmp(filetype(), "b0")) fread(m_cart->vic20_blk5_pointer(machine(), 0x2000) + 0x1000, 0x1000);
			else if (!mame_stricmp(filetype(), "crt"))
			{
				// read the header
				UINT8 header[2];
				fread(&header, 2);
				UINT16 address = pick_integer_le(header, 0, 2);

				if (LOG) logerror("Address %04x\n", address);

				switch (address)
				{
				case 0x2000: fread(m_cart->vic20_blk1_pointer(machine(), 0x2000), 0x2000); break;
				case 0x4000: fread(m_cart->vic20_blk2_pointer(machine(), 0x2000), 0x2000); break;
				case 0x6000: fread(m_cart->vic20_blk3_pointer(machine(), 0x2000), 0x2000); break;
				case 0x7000: fread(m_cart->vic20_blk3_pointer(machine(), 0x2000) + 0x1000, 0x1000); break;
				case 0xa000: fread(m_cart->vic20_blk5_pointer(machine(), 0x2000), 0x2000); break;
				case 0xb000: fread(m_cart->vic20_blk5_pointer(machine(), 0x2000) + 0x1000, 0x1000); break;
				default: return IMAGE_INIT_FAIL;
				}
			}
		}
		else
		{
			size = get_software_region_length("blk1");
			if (size) memcpy(m_cart->vic20_blk1_pointer(machine(), size), get_software_region("blk1"), size);

			size = get_software_region_length("blk2");
			if (size) memcpy(m_cart->vic20_blk2_pointer(machine(), size), get_software_region("blk2"), size);

			size = get_software_region_length("blk3");
			if (size) memcpy(m_cart->vic20_blk3_pointer(machine(), size), get_software_region("blk3"), size);

			size = get_software_region_length("blk5");
			if (size) memcpy(m_cart->vic20_blk5_pointer(machine(), size), get_software_region("blk5"), size);

			size = get_software_region_length("ram");
			if (size) memcpy(m_cart->vic20_ram_pointer(machine(), size), get_software_region("ram"), size);

			size = get_software_region_length("nvram");
			if (size) memcpy(m_cart->vic20_nvram_pointer(machine(), size), get_software_region("nvram"), size);

		}
	}

	return IMAGE_INIT_PASS;
}
Exemple #26
0
bool channelf_cart_slot_device::call_load()
{
	if (m_cart)
	{
		UINT32 len = (software_entry() == NULL) ? length() : get_software_region_length("rom");
		m_cart->rom_alloc(len, tag());

		if (software_entry() == NULL)
			fread(m_cart->get_rom_base(), len);
		else
			memcpy(m_cart->get_rom_base(), get_software_region("rom"), len);

		if (software_entry() == NULL)
		{
			// we default to "chess" slot because some homebrew programs have been written to run
			// on PCBs with RAM at $2000-$2800 as Saba Schach!
			if (len == 0x40000)
				m_type = CF_MULTI;  // TODO1: differentiate multicart final and earlier from fullpath
			else
				m_type = CF_CHESS;  // TODO2: is there any way to detect Maze and Hangman from fullpath?

			m_cart->ram_alloc(0x800);
		}
		else
		{
			const char *pcb_name = get_feature("slot");
			if (pcb_name)
				m_type = chanf_get_pcb_id(pcb_name);

			if (get_software_region("ram"))
				m_cart->ram_alloc(get_software_region_length("ram"));
		}

		//printf("Type: %s\n", chanf_get_slot(m_type));

		return IMAGE_INIT_PASS;
	}

	return IMAGE_INIT_PASS;
}
Exemple #27
0
bool vectrex_cart_slot_device::call_load()
{
	if (m_cart)
	{
		UINT32 size = (software_entry() == nullptr) ? length() : get_software_region_length("rom");
		UINT8 *ROM;

		if (size > 0x10000)
		{
			seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
			return IMAGE_INIT_FAIL;
		}

		m_cart->rom_alloc((size < 0x1000) ? 0x1000 : size, tag());
		ROM = m_cart->get_rom_base();

		if (software_entry() == nullptr)
			fread(ROM, size);
		else
			memcpy(ROM, get_software_region("rom"), size);

		// Verify the file is accepted by the Vectrex bios
		if (memcmp(ROM, "g GCE", 5))
		{
			seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid image");
			return IMAGE_INIT_FAIL;
		}

		// determine type
		m_type = VECTREX_STD;
		if (!memcmp(ROM + 0x06, "SRAM", 4))
			m_type = VECTREX_SRAM;
		if (size > 0x8000)
			m_type = VECTREX_64K;

		//printf("Type: %s\n", vectrex_get_slot(m_type));

		// determine 3D setup (to help video setup at machine_start)
		if (!memcmp(ROM + 0x11, "NARROW", 6) && (ROM[0x39] == 0x0c))
			m_vec3d = VEC3D_NARROW;

		if (!memcmp(ROM + 0x11, "CRAZY COASTER", 13))
			m_vec3d = VEC3D_CCOAST;

		if (!memcmp(ROM + 0x11, "3D MINE STORM", 13))
			m_vec3d = VEC3D_MINEST;

		return IMAGE_INIT_PASS;
	}

	return IMAGE_INIT_PASS;
}
Exemple #28
0
void generic_slot_device::common_load_rom(uint8_t *ROM, uint32_t len, const char *region)
{
	// basic sanity check
	assert((ROM != nullptr) && (len > 0));

	// if we are loading from softlist, you have to specify a region
	assert(!loaded_through_softlist() || (region != nullptr));

	if (!loaded_through_softlist())
		fread(ROM, len);
	else
		memcpy(ROM, get_software_region(region), len);
}
Exemple #29
0
void generic_slot_device::common_load_rom(UINT8 *ROM, UINT32 len, const char *region)
{
	// basic sanity check
	assert((ROM != NULL) && (len > 0));

	// if we are loading from softlist, you have to specify a region
	assert((software_entry() == NULL) || (region != NULL));

	if (software_entry() == NULL)
		fread(ROM, len);
	else
		memcpy(ROM, get_software_region(region), len);
}
Exemple #30
0
bool device_image_interface::load_software_region(const char *tag, optional_shared_ptr<UINT8> &ptr)
{
	size_t size = get_software_region_length(tag);

	if (size)
	{
		ptr.allocate(size);

		memcpy(ptr, get_software_region(tag), size);
	}

	return size > 0;
}